curl将哪些单位用于带宽?


17

curl 在命令行上显示如下进度:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  8 1000M    8 85.2M    0     0    57k      0  1:06:13  0:05:38  1:00:35   47k

在此示例中显示的速度为47k。但是,这是什么意思?这是:

  • 47kiB,即47 * 1024字节
  • 47kB,即47 * 1000字节
  • 47kb,即47 * 1000位(这些位通常用于测量速度)

就是:

  • 每秒
  • 或每分钟?

1
wget的类似问题:superuser.com/q/184331/90668
Flimm

Answers:


14

curl将哪些单位用于带宽?

根据该源代码kiB per second


在这里您可以看到定义的使用情况,1024而不是1000

/* The point of this function would be to return a string of the input data,
   but never longer than 5 columns (+ one zero byte).
   Add suffix k, M, G when suitable... */
static char *max5data(curl_off_t bytes, char *max5)
{
#define ONE_KILOBYTE  CURL_OFF_T_C(1024)
#define ONE_MEGABYTE (CURL_OFF_T_C(1024) * ONE_KILOBYTE)
#define ONE_GIGABYTE (CURL_OFF_T_C(1024) * ONE_MEGABYTE)
#define ONE_TERABYTE (CURL_OFF_T_C(1024) * ONE_GIGABYTE)
#define ONE_PETABYTE (CURL_OFF_T_C(1024) * ONE_TERABYTE)

...

}

在这里,您可以看到计算以毫秒为单位,然后除以1000秒。

  /* Calculate the average speed the last 'span_ms' milliseconds */
  {
    curl_off_t amount = data->progress.speeder[nowindex]-
      data->progress.speeder[checkindex];

    if(amount > CURL_OFF_T_C(4294967) /* 0xffffffff/1000 */)
      /* the 'amount' value is bigger than would fit in 32 bits if
         multiplied with 1000, so we use the double math for this */
      data->progress.current_speed = (curl_off_t)
        ((double)amount/((double)span_ms/1000.0));
    else
      /* the 'amount' value is small enough to fit within 32 bits even
         when multiplied with 1000 */
      data->progress.current_speed = amount*CURL_OFF_T_C(1000)/span_ms;
  }

1
我必须进行查找,因此希望可以省去一些人的工作:kiB是一个kibibyte,您可以搜索类似这样的站点以将其转换为其他单元。
SteveLambert
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.