mirror of
https://github.com/curl/curl.git
synced 2026-07-07 17:17:15 +03:00
getinfo: add microsecond precise timers for various intervals
Provide a set of new timers that return the time intervals using integer number of microseconds instead of floats. The new info names are as following: CURLINFO_APPCONNECT_TIME_T CURLINFO_CONNECT_TIME_T CURLINFO_NAMELOOKUP_TIME_T CURLINFO_PRETRANSFER_TIME_T CURLINFO_REDIRECT_TIME_T CURLINFO_STARTTRANSFER_TIME_T CURLINFO_TOTAL_TIME_T Closes #2495
This commit is contained in:
parent
c5fe86804c
commit
ce2140a8c1
23 changed files with 585 additions and 56 deletions
|
|
@ -28,10 +28,10 @@
|
|||
#include <curl/curl.h>
|
||||
|
||||
#define STOP_DOWNLOAD_AFTER_THIS_MANY_BYTES 6000
|
||||
#define MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL 3
|
||||
#define MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL 3000000
|
||||
|
||||
struct myprogress {
|
||||
double lastruntime;
|
||||
curl_off_t lastruntime;
|
||||
CURL *curl;
|
||||
};
|
||||
|
||||
|
|
@ -42,16 +42,17 @@ static int xferinfo(void *p,
|
|||
{
|
||||
struct myprogress *myp = (struct myprogress *)p;
|
||||
CURL *curl = myp->curl;
|
||||
double curtime = 0;
|
||||
curl_off_t curtime = 0;
|
||||
|
||||
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &curtime);
|
||||
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &curtime);
|
||||
|
||||
/* under certain circumstances it may be desirable for certain functionality
|
||||
to only run every N seconds, in order to do this the transaction time can
|
||||
be used */
|
||||
if((curtime - myp->lastruntime) >= MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL) {
|
||||
myp->lastruntime = curtime;
|
||||
fprintf(stderr, "TOTAL TIME: %f \r\n", curtime);
|
||||
fprintf(stderr, "TOTAL TIME: %" CURL_FORMAT_CURL_OFF_T ".%06ld\r\n",
|
||||
(curtime / 1000000), (long)(curtime % 1000000));
|
||||
}
|
||||
|
||||
fprintf(stderr, "UP: %" CURL_FORMAT_CURL_OFF_T " of %" CURL_FORMAT_CURL_OFF_T
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue