mirror of
https://github.com/curl/curl.git
synced 2026-08-26 16:23:32 +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
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue