Skip to content
Snippets Groups Projects
Commit cfb7e809 authored by Guenter Knauf's avatar Guenter Knauf
Browse files

Added dns and connect time to output.

parent c7e56db0
No related branches found
No related tags found
No related merge requests found
......@@ -60,7 +60,7 @@ int main(int argc, char *argv[])
{
CURL *curl_handle;
CURLcode res;
int prtsep = 0, prttime = 0;
int prtall = 0, prtsep = 0, prttime = 0;
const char *url = URL_1M;
char *appname = argv[0];
......@@ -77,6 +77,8 @@ int main(int argc, char *argv[])
fprintf(stderr, "\r%s %s - %s\n",
appname, CHKSPEED_VERSION, curl_version());
exit(1);
} else if (strncasecmp(*argv, "-A", 2) == 0) {
prtall = 1;
} else if (strncasecmp(*argv, "-X", 2) == 0) {
prtsep = 1;
} else if (strncasecmp(*argv, "-T", 2) == 0) {
......@@ -161,6 +163,18 @@ int main(int argc, char *argv[])
if((CURLE_OK == res) && (val>0))
printf("Average download speed: %0.3f kbyte/sec.\n", val / 1024);
if (prtall) {
/* check for name resolution time */
res = curl_easy_getinfo(curl_handle, CURLINFO_NAMELOOKUP_TIME, &val);
if((CURLE_OK == res) && (val>0))
printf("Name lookup time: %0.3f sec.\n", val);
/* check for connect time */
res = curl_easy_getinfo(curl_handle, CURLINFO_CONNECT_TIME, &val);
if((CURLE_OK == res) && (val>0))
printf("Connect time: %0.3f sec.\n", val);
}
} else {
fprintf(stderr, "Error while fetching '%s' : %s\n",
url, curl_easy_strerror(res));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment