aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-02-28 18:13:49 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-02-28 18:13:58 +0100
commit5a4d49e84c6829741f6e288088e08c7d0332df49 (patch)
tree5c22071d970b79dc950ad8856fb22c6c3d53e38f
parent98cd2e57b35c8cc1eb94ff7f28c1df63846dd5eb (diff)
downloadgnunet-5a4d49e84c6829741f6e288088e08c7d0332df49.tar.gz
gnunet-5a4d49e84c6829741f6e288088e08c7d0332df49.zip
add bytes recv/sent to URL request benchmarking
-rw-r--r--src/curl/curl.c53
-rw-r--r--src/util/benchmark.c6
-rw-r--r--src/util/benchmark.h10
3 files changed, 63 insertions, 6 deletions
diff --git a/src/curl/curl.c b/src/curl/curl.c
index e413d1cf5..10475fe2e 100644
--- a/src/curl/curl.c
+++ b/src/curl/curl.c
@@ -489,15 +489,60 @@ GNUNET_CURL_perform2 (struct GNUNET_CURL_Context *ctx,
489 double total_as_double = 0; 489 double total_as_double = 0;
490 struct GNUNET_TIME_Relative total; 490 struct GNUNET_TIME_Relative total;
491 struct UrlRequestData *urd; 491 struct UrlRequestData *urd;
492 CURLcode res; 492 /* Some care required, as curl is using data types (long vs curl_off_t vs
493 res = curl_easy_getinfo (cmsg->easy_handle, CURLINFO_TOTAL_TIME, &total_as_double); 493 * double) inconsistently to store byte count. */
494 GNUNET_break (CURLE_OK == res); 494 curl_off_t size_curl = 0;
495 curl_easy_getinfo (cmsg->easy_handle, CURLINFO_EFFECTIVE_URL, &url); 495 long size_long = 0;
496 uint64_t bytes_sent = 0;
497 uint64_t bytes_received = 0;
498
499 GNUNET_break (CURLE_OK ==
500 curl_easy_getinfo (cmsg->easy_handle,
501 CURLINFO_TOTAL_TIME,
502 &total_as_double));
496 total.rel_value_us = total_as_double * 1000 * 1000; 503 total.rel_value_us = total_as_double * 1000 * 1000;
504
505 GNUNET_break (CURLE_OK ==
506 curl_easy_getinfo (cmsg->easy_handle,
507 CURLINFO_EFFECTIVE_URL,
508 &url));
509
510 /* HEADER_SIZE + SIZE_DOWNLOAD_T is hopefully the total
511 number of bytes received, not clear from curl docs. */
512
513 GNUNET_break (CURLE_OK ==
514 curl_easy_getinfo (cmsg->easy_handle,
515 CURLINFO_HEADER_SIZE,
516 &size_long));
517 bytes_received += size_long;
518
519 GNUNET_break (CURLE_OK ==
520 curl_easy_getinfo (cmsg->easy_handle,
521 CURLINFO_SIZE_DOWNLOAD_T,
522 &size_curl));
523 bytes_received += size_curl;
524
525 /* REQUEST_SIZE + SIZE_UPLOAD_T is hopefully the total number of bytes
526 sent, again docs are not completely clear. */
527
528 GNUNET_break (CURLE_OK ==
529 curl_easy_getinfo (cmsg->easy_handle,
530 CURLINFO_REQUEST_SIZE,
531 &size_long));
532 bytes_sent += size_long;
533
534 GNUNET_break (CURLE_OK ==
535 curl_easy_getinfo (cmsg->easy_handle,
536 CURLINFO_SIZE_UPLOAD_T,
537 &size_curl));
538 bytes_sent += size_curl;
539
497 urd = get_url_benchmark_data (url, (unsigned int) response_code); 540 urd = get_url_benchmark_data (url, (unsigned int) response_code);
498 urd->count++; 541 urd->count++;
499 urd->time = GNUNET_TIME_relative_add (urd->time, total); 542 urd->time = GNUNET_TIME_relative_add (urd->time, total);
500 urd->time_max = GNUNET_TIME_relative_max (total, urd->time_max); 543 urd->time_max = GNUNET_TIME_relative_max (total, urd->time_max);
544 urd->bytes_sent = bytes_sent;
545 urd->bytes_received = bytes_received;
501 } 546 }
502#endif 547#endif
503 job->jcc (job->jcc_cls, 548 job->jcc (job->jcc_cls,
diff --git a/src/util/benchmark.c b/src/util/benchmark.c
index bb1c3c79a..caf6cd64a 100644
--- a/src/util/benchmark.c
+++ b/src/util/benchmark.c
@@ -137,12 +137,14 @@ write_benchmark_data (struct BenchmarkData *bd)
137 for (unsigned int i = 0; i < bd->urd_len; i++) 137 for (unsigned int i = 0; i < bd->urd_len; i++)
138 { 138 {
139 struct UrlRequestData *urd = &bd->urd[i]; 139 struct UrlRequestData *urd = &bd->urd[i];
140 GNUNET_asprintf (&s, "url %s status %u count %llu time_us %llu time_us_max %llu\n", 140 GNUNET_asprintf (&s, "url %s status %u count %llu time_us %llu time_us_max %llu bytes_sent %llu bytes_received %llu\n",
141 urd->request_url, 141 urd->request_url,
142 urd->status, 142 urd->status,
143 (unsigned long long) urd->count, 143 (unsigned long long) urd->count,
144 (unsigned long long) urd->time.rel_value_us, 144 (unsigned long long) urd->time.rel_value_us,
145 (unsigned long long) urd->time_max.rel_value_us); 145 (unsigned long long) urd->time_max.rel_value_us,
146 (unsigned long long) urd->bytes_sent,
147 (unsigned long long) urd->bytes_received);
146 GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s, strlen (s))); 148 GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s, strlen (s)));
147 GNUNET_free (s); 149 GNUNET_free (s);
148 } 150 }
diff --git a/src/util/benchmark.h b/src/util/benchmark.h
index 36f57febe..4148ac655 100644
--- a/src/util/benchmark.h
+++ b/src/util/benchmark.h
@@ -76,6 +76,16 @@ struct UrlRequestData
76 uint64_t count; 76 uint64_t count;
77 77
78 /** 78 /**
79 * How many bytes were sent in total to request the URL.
80 */
81 uint64_t bytes_sent;
82
83 /**
84 * How many bytes were received in total as response to requesting this URL.
85 */
86 uint64_t bytes_received;
87
88 /**
79 * Total time spent requesting this URL. 89 * Total time spent requesting this URL.
80 */ 90 */
81 struct GNUNET_TIME_Relative time; 91 struct GNUNET_TIME_Relative time;