summaryrefslogtreecommitdiff
path: root/lib/progress.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-05-06 09:06:24 +0200
committerDaniel Stenberg <daniel@haxx.se>2021-05-07 08:29:15 +0200
commit68027623e2dbecae80183008275e106b4b12e54f (patch)
tree581b8713dd00bbceff8de33596fdd43880c74abe /lib/progress.c
parent04cc27460ea15943873de6dac4983e52e3645756 (diff)
downloadcurl-68027623e2dbecae80183008275e106b4b12e54f.tar.gz
progress: when possible, calculate transfer speeds with microseconds
... this improves precision, especially for transfers in the few or even sub millisecond range. Reported-by: J. Bromley Fixes #7017 Closes #7020
Diffstat (limited to 'lib/progress.c')
-rw-r--r--lib/progress.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/progress.c b/lib/progress.c
index cc040a873..756b00397 100644
--- a/lib/progress.c
+++ b/lib/progress.c
@@ -384,13 +384,19 @@ static bool progress_calc(struct Curl_easy *data, struct curltime now)
timespent_ms = (curl_off_t)data->progress.timespent/1000; /* ms */
/* The average download speed this far */
- if(dl < CURL_OFF_T_MAX/1000)
+ if(dl < CURL_OFF_T_MAX/1000000)
+ data->progress.dlspeed =
+ (dl * 1000000 / (data->progress.timespent?data->progress.timespent:1));
+ else if(dl < CURL_OFF_T_MAX/1000)
data->progress.dlspeed = (dl * 1000 / (timespent_ms>0?timespent_ms:1));
else
data->progress.dlspeed = (dl / (timespent>0?timespent:1));
/* The average upload speed this far */
- if(ul < CURL_OFF_T_MAX/1000)
+ if(ul < CURL_OFF_T_MAX/1000000)
+ data->progress.ulspeed =
+ (ul * 1000000 / (data->progress.timespent?data->progress.timespent:1));
+ else if(ul < CURL_OFF_T_MAX/1000)
data->progress.ulspeed = (ul * 1000 / (timespent_ms>0?timespent_ms:1));
else
data->progress.ulspeed = (ul / (timespent>0?timespent:1));