From ce2140a8c12299f17bee406bad374e310daa94ed Mon Sep 17 00:00:00 2001 From: Philip Prindeville Date: Thu, 17 May 2018 13:37:36 +0200 Subject: 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 --- tests/libtest/lib500.c | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) (limited to 'tests/libtest') diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index 677ab73a7..2a6c58bb5 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -96,36 +96,50 @@ int test(char *URL) if(libtest_arg2) { FILE *moo = fopen(libtest_arg2, "wb"); if(moo) { - double time_namelookup; - double time_connect; - double time_pretransfer; - double time_starttransfer; - double time_total; + curl_off_t time_namelookup; + curl_off_t time_connect; + curl_off_t time_pretransfer; + curl_off_t time_starttransfer; + curl_off_t time_total; fprintf(moo, "IP: %s\n", ipstr); - curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &time_namelookup); - curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &time_connect); - curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &time_pretransfer); - curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, + curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME_T, &time_namelookup); + curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME_T, &time_connect); + curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME_T, + &time_pretransfer); + curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME_T, &time_starttransfer); - curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &time_total); + curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &time_total); /* since the timing will always vary we only compare relative differences between these 5 times */ if(time_namelookup > time_connect) { - fprintf(moo, "namelookup vs connect: %f %f\n", - time_namelookup, time_connect); + fprintf(moo, "namelookup vs connect: %" CURL_FORMAT_CURL_OFF_T + ".%06ld %" CURL_FORMAT_CURL_OFF_T ".%06ld\n", + (time_namelookup / 1000000), + (long)(time_namelookup % 1000000), + (time_connect / 1000000), (long)(time_connect % 1000000)); } if(time_connect > time_pretransfer) { - fprintf(moo, "connect vs pretransfer: %f %f\n", - time_connect, time_pretransfer); + fprintf(moo, "connect vs pretransfer: %" CURL_FORMAT_CURL_OFF_T + ".%06ld %" CURL_FORMAT_CURL_OFF_T ".%06ld\n", + (time_connect / 1000000), (long)(time_connect % 1000000), + (time_pretransfer / 1000000), + (long)(time_pretransfer % 1000000)); } if(time_pretransfer > time_starttransfer) { - fprintf(moo, "pretransfer vs starttransfer: %f %f\n", - time_pretransfer, time_starttransfer); + fprintf(moo, "pretransfer vs starttransfer: %" CURL_FORMAT_CURL_OFF_T + ".%06ld %" CURL_FORMAT_CURL_OFF_T ".%06ld\n", + (time_pretransfer / 1000000), + (long)(time_pretransfer % 1000000), + (time_starttransfer / 1000000), + (long)(time_starttransfer % 1000000)); } if(time_starttransfer > time_total) { - fprintf(moo, "starttransfer vs total: %f %f\n", - time_starttransfer, time_total); + fprintf(moo, "starttransfer vs total: %" CURL_FORMAT_CURL_OFF_T + ".%06ld %" CURL_FORMAT_CURL_OFF_T ".%06ld\n", + (time_starttransfer / 1000000), + (long)(time_starttransfer % 1000000), + (time_total / 1000000), (long)(time_total % 1000000)); } fclose(moo); -- cgit v1.2.3