mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
Dirk Manske increased the resolution for what the CURLINFO_*_TIME return.
This commit is contained in:
parent
de8660a96a
commit
2fd463e979
@ -148,26 +148,26 @@ void Curl_pgrsTime(struct SessionHandle *data, timerid timer)
|
|||||||
|
|
||||||
case TIMER_NAMELOOKUP:
|
case TIMER_NAMELOOKUP:
|
||||||
data->progress.t_nslookup =
|
data->progress.t_nslookup =
|
||||||
(double)Curl_tvdiff(Curl_tvnow(), data->progress.t_startsingle)/1000.0;
|
Curl_tvdiff_secs(Curl_tvnow(), data->progress.t_startsingle);
|
||||||
break;
|
break;
|
||||||
case TIMER_CONNECT:
|
case TIMER_CONNECT:
|
||||||
data->progress.t_connect =
|
data->progress.t_connect =
|
||||||
(double)Curl_tvdiff(Curl_tvnow(), data->progress.t_startsingle)/1000.0;
|
Curl_tvdiff_secs(Curl_tvnow(), data->progress.t_startsingle);
|
||||||
break;
|
break;
|
||||||
case TIMER_PRETRANSFER:
|
case TIMER_PRETRANSFER:
|
||||||
data->progress.t_pretransfer =
|
data->progress.t_pretransfer =
|
||||||
(double)Curl_tvdiff(Curl_tvnow(), data->progress.t_startsingle)/1000.0;
|
Curl_tvdiff_secs(Curl_tvnow(), data->progress.t_startsingle);
|
||||||
break;
|
break;
|
||||||
case TIMER_STARTTRANSFER:
|
case TIMER_STARTTRANSFER:
|
||||||
data->progress.t_starttransfer =
|
data->progress.t_starttransfer =
|
||||||
(double)Curl_tvdiff(Curl_tvnow(), data->progress.t_startsingle)/1000.0;
|
Curl_tvdiff_secs(Curl_tvnow(), data->progress.t_startsingle);
|
||||||
break;
|
break;
|
||||||
case TIMER_POSTRANSFER:
|
case TIMER_POSTRANSFER:
|
||||||
/* this is the normal end-of-transfer thing */
|
/* this is the normal end-of-transfer thing */
|
||||||
break;
|
break;
|
||||||
case TIMER_REDIRECT:
|
case TIMER_REDIRECT:
|
||||||
data->progress.t_redirect =
|
data->progress.t_redirect =
|
||||||
(double)Curl_tvdiff(Curl_tvnow(), data->progress.start)/1000.0;
|
Curl_tvdiff_secs(Curl_tvnow(), data->progress.start);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,8 +249,8 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
|||||||
now = Curl_tvnow(); /* what time is it */
|
now = Curl_tvnow(); /* what time is it */
|
||||||
|
|
||||||
/* The time spent so far (from the start) */
|
/* The time spent so far (from the start) */
|
||||||
data->progress.timespent = Curl_tvdiff(now, data->progress.start)/1000.0;
|
data->progress.timespent = Curl_tvdiff_secs(now, data->progress.start);
|
||||||
timespent = (long)data->progress.timespent;
|
timespent = (long)data->progress.timespent*1000.0;
|
||||||
|
|
||||||
/* The average download speed this far */
|
/* The average download speed this far */
|
||||||
data->progress.dlspeed =
|
data->progress.dlspeed =
|
||||||
|
@ -98,6 +98,17 @@ long curlx_tvdiff(struct timeval newer, struct timeval older)
|
|||||||
(newer.tv_usec-older.tv_usec)/1000;
|
(newer.tv_usec-older.tv_usec)/1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Same as curlx_tvdiff but with full usec resolution.
|
||||||
|
*
|
||||||
|
* Returns: the time difference in seconds with subsecond resolution.
|
||||||
|
*/
|
||||||
|
double curlx_tvdiff_secs(struct timeval newer, struct timeval older)
|
||||||
|
{
|
||||||
|
return (double)(newer.tv_sec-older.tv_sec)+
|
||||||
|
(double)(newer.tv_usec-older.tv_usec)/1000000.0;
|
||||||
|
}
|
||||||
|
|
||||||
/* return the number of seconds in the given input timeval struct */
|
/* return the number of seconds in the given input timeval struct */
|
||||||
long Curl_tvlong(struct timeval t1)
|
long Curl_tvlong(struct timeval t1)
|
||||||
{
|
{
|
||||||
|
@ -54,11 +54,20 @@ struct timeval curlx_tvnow(void);
|
|||||||
* Returns: the time difference in number of milliseconds.
|
* Returns: the time difference in number of milliseconds.
|
||||||
*/
|
*/
|
||||||
long curlx_tvdiff(struct timeval t1, struct timeval t2);
|
long curlx_tvdiff(struct timeval t1, struct timeval t2);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Same as curlx_tvdiff but with full usec resolution.
|
||||||
|
*
|
||||||
|
* Returns: the time difference in seconds with subsecond resolution.
|
||||||
|
*/
|
||||||
|
double curlx_tvdiff_secs(struct timeval t1, struct timeval t2);
|
||||||
|
|
||||||
long Curl_tvlong(struct timeval t1);
|
long Curl_tvlong(struct timeval t1);
|
||||||
|
|
||||||
/* These two defines below exist to provide the older API for library
|
/* These two defines below exist to provide the older API for library
|
||||||
internals only. */
|
internals only. */
|
||||||
#define Curl_tvnow() curlx_tvnow()
|
#define Curl_tvnow() curlx_tvnow()
|
||||||
#define Curl_tvdiff(x,y) curlx_tvdiff(x,y)
|
#define Curl_tvdiff(x,y) curlx_tvdiff(x,y)
|
||||||
|
#define Curl_tvdiff_secs(x,y) curlx_tvdiff_secs(x,y)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user