aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/curl/curl.c2
-rw-r--r--src/util/benchmark.c22
-rw-r--r--src/util/benchmark.h10
3 files changed, 29 insertions, 5 deletions
diff --git a/src/curl/curl.c b/src/curl/curl.c
index 9284d7b45..07f31970a 100644
--- a/src/curl/curl.c
+++ b/src/curl/curl.c
@@ -511,7 +511,7 @@ GNUNET_CURL_perform (struct GNUNET_CURL_Context *ctx)
511 res = curl_easy_getinfo (cmsg->easy_handle, CURLINFO_TOTAL_TIME, &total); 511 res = curl_easy_getinfo (cmsg->easy_handle, CURLINFO_TOTAL_TIME, &total);
512 GNUNET_break (CURLE_OK == res); 512 GNUNET_break (CURLE_OK == res);
513 curl_easy_getinfo (cmsg->easy_handle, CURLINFO_EFFECTIVE_URL, &url); 513 curl_easy_getinfo (cmsg->easy_handle, CURLINFO_EFFECTIVE_URL, &url);
514 urd = get_url_benchmark_data (url); 514 urd = get_url_benchmark_data (url, (unsigned int) response_code);
515 urd->count++; 515 urd->count++;
516 urd->time.rel_value_us += total * 1000 * 1000; 516 urd->time.rel_value_us += total * 1000 * 1000;
517 } 517 }
diff --git a/src/util/benchmark.c b/src/util/benchmark.c
index 78f62a96e..daed7cd2b 100644
--- a/src/util/benchmark.c
+++ b/src/util/benchmark.c
@@ -88,8 +88,9 @@ write_benchmark_data (struct BenchmarkData *bd)
88 for (unsigned int i = 0; i < bd->urd_len; i++) 88 for (unsigned int i = 0; i < bd->urd_len; i++)
89 { 89 {
90 struct UrlRequestData *urd = &bd->urd[i]; 90 struct UrlRequestData *urd = &bd->urd[i];
91 GNUNET_asprintf (&s, "url %s count %lld time_us %lld\n", 91 GNUNET_asprintf (&s, "url %s status %u count %llu time_us %llu\n",
92 urd->request_url, 92 urd->request_url,
93 urd->status,
93 (unsigned long long) urd->count, 94 (unsigned long long) urd->count,
94 (unsigned long long) urd->time.rel_value_us); 95 (unsigned long long) urd->time.rel_value_us);
95 GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s, strlen (s))); 96 GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s, strlen (s)));
@@ -173,10 +174,13 @@ get_benchmark_data (void)
173 * Get benchmark data for a URL. If the URL is too long, it's truncated 174 * Get benchmark data for a URL. If the URL is too long, it's truncated
174 * before looking up the correspoding benchmark data. 175 * before looking up the correspoding benchmark data.
175 * 176 *
177 * Statistics are bucketed by URL and status code.
178 *
176 * @param url url to get request data for 179 * @param url url to get request data for
180 * @param status http status code
177 */ 181 */
178struct UrlRequestData * 182struct UrlRequestData *
179get_url_benchmark_data (char *url) 183get_url_benchmark_data (char *url, unsigned int status)
180{ 184{
181 char trunc[MAX_BENCHMARK_URL_LEN]; 185 char trunc[MAX_BENCHMARK_URL_LEN];
182 struct BenchmarkData *bd; 186 struct BenchmarkData *bd;
@@ -191,13 +195,24 @@ get_url_benchmark_data (char *url)
191 memcpy (trunc, url, MAX_BENCHMARK_URL_LEN); 195 memcpy (trunc, url, MAX_BENCHMARK_URL_LEN);
192 trunc[MAX_BENCHMARK_URL_LEN - 1] = 0; 196 trunc[MAX_BENCHMARK_URL_LEN - 1] = 0;
193 197
198 /* We're not interested in what's after the query string */
199 for (size_t i = 0; i < strlen (trunc); i++)
200 {
201 if (trunc[i] == '?')
202 {
203 trunc[i] = 0;
204 break;
205 }
206 }
207
194 bd = get_benchmark_data (); 208 bd = get_benchmark_data ();
195 209
196 GNUNET_assert (bd->urd_len <= bd->urd_capacity); 210 GNUNET_assert (bd->urd_len <= bd->urd_capacity);
197 211
198 for (unsigned int i = 0; i < bd->urd_len; i++) 212 for (unsigned int i = 0; i < bd->urd_len; i++)
199 { 213 {
200 if (0 == strcmp (trunc, bd->urd[i].request_url)) 214 if ( (0 == strcmp (trunc, bd->urd[i].request_url)) &&
215 (bd->urd[i].status == status) )
201 return &bd->urd[i]; 216 return &bd->urd[i];
202 } 217 }
203 218
@@ -205,6 +220,7 @@ get_url_benchmark_data (char *url)
205 struct UrlRequestData urd = { 0 }; 220 struct UrlRequestData urd = { 0 };
206 221
207 memcpy (&urd.request_url, trunc, MAX_BENCHMARK_URL_LEN); 222 memcpy (&urd.request_url, trunc, MAX_BENCHMARK_URL_LEN);
223 urd.status = status;
208 224
209 if (bd->urd_len == bd->urd_capacity) 225 if (bd->urd_len == bd->urd_capacity)
210 { 226 {
diff --git a/src/util/benchmark.h b/src/util/benchmark.h
index ec00cb0d3..6e00906c4 100644
--- a/src/util/benchmark.h
+++ b/src/util/benchmark.h
@@ -43,6 +43,11 @@ struct UrlRequestData
43 * Request URL, truncated (but 0-terminated). 43 * Request URL, truncated (but 0-terminated).
44 */ 44 */
45 char request_url[MAX_BENCHMARK_URL_LEN]; 45 char request_url[MAX_BENCHMARK_URL_LEN];
46
47 /**
48 * HTTP status code.
49 */
50 unsigned int status;
46 51
47 /** 52 /**
48 * How often was the URL requested? 53 * How often was the URL requested?
@@ -101,9 +106,12 @@ get_benchmark_data (void);
101 * Get benchmark data for a URL. If the URL is too long, it's truncated 106 * Get benchmark data for a URL. If the URL is too long, it's truncated
102 * before looking up the correspoding benchmark data. 107 * before looking up the correspoding benchmark data.
103 * 108 *
109 * Statistics are bucketed by URL and status code.
110 *
104 * @param url url to get request data for 111 * @param url url to get request data for
112 * @param status http status code
105 */ 113 */
106struct UrlRequestData * 114struct UrlRequestData *
107get_url_benchmark_data (char *url); 115get_url_benchmark_data (char *url, unsigned int status);
108 116
109#endif /* BENCHMARK_H_ */ 117#endif /* BENCHMARK_H_ */