aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Knauf <lists@gknw.net>2013-04-01 14:54:01 +0200
committerGuenter Knauf <lists@gknw.net>2013-04-01 14:54:01 +0200
commitcfb7e809913aa4fc5eeec3621273c75a729459b6 (patch)
tree779bffad4308545c61d693db5f259e9268f1f2de
parentc7e56db050fa7b7bebfe41245b97ba7cc763ba05 (diff)
Added dns and connect time to output.
-rw-r--r--docs/examples/chkspeed.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/docs/examples/chkspeed.c b/docs/examples/chkspeed.c
index b5c397ab7..31949b892 100644
--- a/docs/examples/chkspeed.c
+++ b/docs/examples/chkspeed.c
@@ -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));