aboutsummaryrefslogtreecommitdiff
path: root/lib/progress.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2017-06-07 13:16:56 +0200
committerDaniel Stenberg <daniel@haxx.se>2017-06-14 15:46:39 +0100
commitadef394ac5390e80227c949cbea4a7c22a114677 (patch)
tree182b36490d31233aff436b329d3d33ae13f9d4bf /lib/progress.c
parent11c2fb04467520b82f2251629710e6d4a0798700 (diff)
timers: store internal time stamps as time_t instead of doubles
This gives us accurate precision and it allows us to avoid storing "no time" for systems with too low timer resolution as we then bump the time up to 1 microsecond. Should fix test 573 on windows. Remove the now unused curlx_tvdiff_secs() function. Maintains the external getinfo() API with using doubles. Fixes #1531
Diffstat (limited to 'lib/progress.c')
-rw-r--r--lib/progress.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/progress.c b/lib/progress.c
index cfaf4049e..1996d78dc 100644
--- a/lib/progress.c
+++ b/lib/progress.c
@@ -152,10 +152,10 @@ int Curl_pgrsDone(struct connectdata *conn)
/* reset all times except redirect, and reset the known transfer sizes */
void Curl_pgrsResetTimesSizes(struct Curl_easy *data)
{
- data->progress.t_nslookup = 0.0;
- data->progress.t_connect = 0.0;
- data->progress.t_pretransfer = 0.0;
- data->progress.t_starttransfer = 0.0;
+ data->progress.t_nslookup = 0;
+ data->progress.t_connect = 0;
+ data->progress.t_pretransfer = 0;
+ data->progress.t_starttransfer = 0;
Curl_pgrsSetDownloadSize(data, -1);
Curl_pgrsSetUploadSize(data, -1);
@@ -164,6 +164,7 @@ void Curl_pgrsResetTimesSizes(struct Curl_easy *data)
void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
{
struct timeval now = Curl_tvnow();
+ time_t *delta = NULL;
switch(timer) {
default:
@@ -178,38 +179,37 @@ void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
/* This is set at the start of each single fetch */
data->progress.t_startsingle = now;
break;
-
case TIMER_STARTACCEPT:
- data->progress.t_acceptdata = Curl_tvnow();
+ data->progress.t_acceptdata = now;
break;
-
case TIMER_NAMELOOKUP:
- data->progress.t_nslookup =
- Curl_tvdiff_secs(now, data->progress.t_startsingle);
+ delta = &data->progress.t_nslookup;
break;
case TIMER_CONNECT:
- data->progress.t_connect =
- Curl_tvdiff_secs(now, data->progress.t_startsingle);
+ delta = &data->progress.t_connect;
break;
case TIMER_APPCONNECT:
- data->progress.t_appconnect =
- Curl_tvdiff_secs(now, data->progress.t_startsingle);
+ delta = &data->progress.t_appconnect;
break;
case TIMER_PRETRANSFER:
- data->progress.t_pretransfer =
- Curl_tvdiff_secs(now, data->progress.t_startsingle);
+ delta = &data->progress.t_pretransfer;
break;
case TIMER_STARTTRANSFER:
- data->progress.t_starttransfer =
- Curl_tvdiff_secs(now, data->progress.t_startsingle);
+ delta = &data->progress.t_starttransfer;
break;
case TIMER_POSTRANSFER:
/* this is the normal end-of-transfer thing */
break;
case TIMER_REDIRECT:
- data->progress.t_redirect = Curl_tvdiff_secs(now, data->progress.start);
+ data->progress.t_redirect = Curl_tvdiff_us(now, data->progress.start);
break;
}
+ if(delta) {
+ time_t us = Curl_tvdiff_us(now, data->progress.t_startsingle);
+ if(!us)
+ us++; /* make sure at least one microsecond passed */
+ *delta = us;
+ }
}
void Curl_pgrsStartNow(struct Curl_easy *data)
@@ -361,17 +361,17 @@ int Curl_pgrsUpdate(struct connectdata *conn)
now = Curl_tvnow(); /* what time is it */
/* The time spent so far (from the start) */
- data->progress.timespent = curlx_tvdiff_secs(now, data->progress.start);
+ data->progress.timespent = Curl_tvdiff_us(now, data->progress.start);
timespent = (curl_off_t)data->progress.timespent;
/* The average download speed this far */
data->progress.dlspeed = (curl_off_t)
- ((double)data->progress.downloaded/
+ (data->progress.downloaded/
(data->progress.timespent>0?data->progress.timespent:1));
/* The average upload speed this far */
data->progress.ulspeed = (curl_off_t)
- ((double)data->progress.uploaded/
+ (data->progress.uploaded/
(data->progress.timespent>0?data->progress.timespent:1));
/* Calculations done at most once a second, unless end is reached */