diff options
author | Philip Prindeville <philipp@redfish-solutions.com> | 2018-05-17 13:37:36 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-05-17 13:41:04 +0200 |
commit | ce2140a8c12299f17bee406bad374e310daa94ed (patch) | |
tree | d762462ea05f6187ad9e00468b2087ffb2fd80a0 /docs/examples/chkspeed.c | |
parent | c5fe86804cce21db3b9902a44ea8903b3b211db0 (diff) | |
download | curl-ce2140a8c12299f17bee406bad374e310daa94ed.tar.gz |
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
Diffstat (limited to 'docs/examples/chkspeed.c')
-rw-r--r-- | docs/examples/chkspeed.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/docs/examples/chkspeed.c b/docs/examples/chkspeed.c index f3dd1e944..0b0ba72a0 100644 --- a/docs/examples/chkspeed.c +++ b/docs/examples/chkspeed.c @@ -165,33 +165,37 @@ int main(int argc, char *argv[]) res = curl_easy_perform(curl_handle); if(CURLE_OK == res) { - double val; + curl_off_t val; /* check for bytes downloaded */ - res = curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD, &val); + res = curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD_T, &val); if((CURLE_OK == res) && (val>0)) - printf("Data downloaded: %0.0f bytes.\n", val); + printf("Data downloaded: %" CURL_FORMAT_CURL_OFF_T " bytes.\n", val); /* check for total download time */ - res = curl_easy_getinfo(curl_handle, CURLINFO_TOTAL_TIME, &val); + res = curl_easy_getinfo(curl_handle, CURLINFO_TOTAL_TIME_T, &val); if((CURLE_OK == res) && (val>0)) - printf("Total download time: %0.3f sec.\n", val); + printf("Total download time: %" CURL_FORMAT_CURL_OFF_T ".%06ld sec.\n", + (val / 1000000), (long)(val % 1000000)); /* check for average download speed */ - res = curl_easy_getinfo(curl_handle, CURLINFO_SPEED_DOWNLOAD, &val); + res = curl_easy_getinfo(curl_handle, CURLINFO_SPEED_DOWNLOAD_T, &val); if((CURLE_OK == res) && (val>0)) - printf("Average download speed: %0.3f kbyte/sec.\n", val / 1024); + printf("Average download speed: %" CURL_FORMAT_CURL_OFF_T + " kbyte/sec.\n", val / 1024); if(prtall) { /* check for name resolution time */ - res = curl_easy_getinfo(curl_handle, CURLINFO_NAMELOOKUP_TIME, &val); + res = curl_easy_getinfo(curl_handle, CURLINFO_NAMELOOKUP_TIME_T, &val); if((CURLE_OK == res) && (val>0)) - printf("Name lookup time: %0.3f sec.\n", val); + printf("Name lookup time: %" CURL_FORMAT_CURL_OFF_T ".%06ld sec.\n", + (val / 1000000), (long)(val % 1000000)); /* check for connect time */ - res = curl_easy_getinfo(curl_handle, CURLINFO_CONNECT_TIME, &val); + res = curl_easy_getinfo(curl_handle, CURLINFO_CONNECT_TIME_T, &val); if((CURLE_OK == res) && (val>0)) - printf("Connect time: %0.3f sec.\n", val); + printf("Connect time: %" CURL_FORMAT_CURL_OFF_T ".%06ld sec.\n", + (val / 1000000), (long)(val % 1000000)); } } else { |