[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: URL benchmarking
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: URL benchmarking |
Date: |
Sat, 18 Aug 2018 02:30:28 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new adc9f7dc9 URL benchmarking
adc9f7dc9 is described below
commit adc9f7dc9978dd38d14c925e3e38d658f9300753
Author: Florian Dold <address@hidden>
AuthorDate: Sat Aug 18 02:29:14 2018 +0200
URL benchmarking
---
src/curl/curl.c | 14 +++++++++++
src/util/benchmark.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/util/benchmark.h | 56 ++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 136 insertions(+), 1 deletion(-)
diff --git a/src/curl/curl.c b/src/curl/curl.c
index 0d9342b60..9284d7b45 100644
--- a/src/curl/curl.c
+++ b/src/curl/curl.c
@@ -502,6 +502,20 @@ GNUNET_CURL_perform (struct GNUNET_CURL_Context *ctx)
j = download_get_result (&job->db,
job->easy_handle,
&response_code);
+#if ENABLE_BENCHMARK
+ {
+ char *url = NULL;
+ double total = 0;
+ struct UrlRequestData *urd;
+ CURLcode res;
+ res = curl_easy_getinfo (cmsg->easy_handle, CURLINFO_TOTAL_TIME, &total);
+ GNUNET_break (CURLE_OK == res);
+ curl_easy_getinfo (cmsg->easy_handle, CURLINFO_EFFECTIVE_URL, &url);
+ urd = get_url_benchmark_data (url);
+ urd->count++;
+ urd->time.rel_value_us += total * 1000 * 1000;
+ }
+#endif
job->jcc (job->jcc_cls,
response_code,
j);
diff --git a/src/util/benchmark.c b/src/util/benchmark.c
index 4a0c9b7c8..421cafbef 100644
--- a/src/util/benchmark.c
+++ b/src/util/benchmark.c
@@ -71,6 +71,33 @@ write_benchmark_data (struct BenchmarkData *bd)
GNUNET_free (s);
GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
+
+ GNUNET_asprintf (&s, "gnunet-benchmark-urls-%llu-%llu.txt",
+ (unsigned long long) pid,
+ (unsigned long long) tid);
+
+ fh = GNUNET_DISK_file_open (s,
+ (GNUNET_DISK_OPEN_WRITE |
+ GNUNET_DISK_OPEN_TRUNCATE |
+ GNUNET_DISK_OPEN_CREATE),
+ (GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE));
+ GNUNET_assert (NULL != fh);
+ GNUNET_free (s);
+
+ for (unsigned int i = 0; i < bd->urd_len; i++)
+ {
+ struct UrlRequestData *urd = &bd->urd[i];
+ GNUNET_asprintf (&s, "url %s count %lld time_us %lld\n",
+ urd->request_url,
+ (unsigned long long) urd->count,
+ (unsigned long long) urd->time.rel_value_us);
+ GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s,
strlen (s)));
+ GNUNET_free (s);
+ }
+
+
+ GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
}
@@ -142,3 +169,43 @@ get_benchmark_data (void)
}
return bd;
}
+
+
+/**
+ * Get benchmark data for a URL. If the URL is too long, it's truncated
+ * before looking up the correspoding benchmark data.
+ *
+ * @param url url to get request data for
+ */
+struct UrlRequestData *
+get_url_benchmark_data (char *url)
+{
+ char trunc[MAX_BENCHMARK_URL_LEN];
+ struct BenchmarkData *bd;
+
+ memcpy (trunc, url, MAX_BENCHMARK_URL_LEN);
+ trunc[MAX_BENCHMARK_URL_LEN - 1] = 0;
+
+ bd = get_benchmark_data ();
+
+ for (unsigned int i = 0; i < bd->urd_len; i++)
+ {
+ if (0 == strcmp (trunc, bd->urd[i].request_url))
+ return &bd->urd[i];
+ }
+
+ {
+ struct UrlRequestData urd = { 0 };
+
+ memcpy (&urd.request_url, trunc, MAX_BENCHMARK_URL_LEN);
+
+ if (bd->urd_len == bd->urd_capacity)
+ {
+ bd->urd_capacity = 2 * (bd->urd_capacity + 1);
+ bd->urd = GNUNET_realloc (bd->urd, bd->urd_capacity * sizeof (struct
UrlRequestData));
+ }
+
+ bd->urd[bd->urd_len++] = urd;
+ return &bd->urd[bd->urd_len - 1];
+ }
+}
diff --git a/src/util/benchmark.h b/src/util/benchmark.h
index eec9c9c8a..ec00cb0d3 100644
--- a/src/util/benchmark.h
+++ b/src/util/benchmark.h
@@ -28,9 +28,48 @@
#include "gnunet_time_lib.h"
/**
+ * Maximum length of URLs considered for benchmarking.
+ * Shorter URLs are simply truncated.
+ */
+#define MAX_BENCHMARK_URL_LEN 128
+
+
+/**
+ * Struct for benchmark data for one URL.
+ */
+struct UrlRequestData
+{
+ /**
+ * Request URL, truncated (but 0-terminated).
+ */
+ char request_url[MAX_BENCHMARK_URL_LEN];
+
+ /**
+ * How often was the URL requested?
+ */
+ uint64_t count;
+
+ /**
+ * Total time spent requesting this URL.
+ */
+ struct GNUNET_TIME_Relative time;
+
+ /**
+ * Slowest time to response.
+ */
+ struct GNUNET_TIME_Relative time_max;
+
+ /**
+ * Fastest time to response.
+ */
+ struct GNUNET_TIME_Relative time_min;
+};
+
+/**
* Thread-local struct for benchmarking data.
*/
-struct BenchmarkData {
+struct BenchmarkData
+{
/**
* Number of eddsa_sign operations.
*/
@@ -40,6 +79,12 @@ struct BenchmarkData {
* Time spent in eddsa_sign.
*/
struct GNUNET_TIME_Relative eddsa_sign_time;
+
+ struct UrlRequestData *urd;
+
+ unsigned int urd_len;
+
+ unsigned int urd_capacity;
};
@@ -52,4 +97,13 @@ struct BenchmarkData {
struct BenchmarkData *
get_benchmark_data (void);
+/**
+ * Get benchmark data for a URL. If the URL is too long, it's truncated
+ * before looking up the correspoding benchmark data.
+ *
+ * @param url url to get request data for
+ */
+struct UrlRequestData *
+get_url_benchmark_data (char *url);
+
#endif /* BENCHMARK_H_ */
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: URL benchmarking,
gnunet <=