aboutsummaryrefslogtreecommitdiff
path: root/src/curl/curl.c
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 /src/curl/curl.c
parent98cd2e57b35c8cc1eb94ff7f28c1df63846dd5eb (diff)
downloadgnunet-5a4d49e84c6829741f6e288088e08c7d0332df49.tar.gz
gnunet-5a4d49e84c6829741f6e288088e08c7d0332df49.zip
add bytes recv/sent to URL request benchmarking
Diffstat (limited to 'src/curl/curl.c')
-rw-r--r--src/curl/curl.c53
1 files changed, 49 insertions, 4 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,