aboutsummaryrefslogtreecommitdiff
path: root/src/util/benchmark.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-08-18 04:20:10 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-08-18 04:20:10 +0200
commitec8162bdf0db6282fbf507e6da72b056119c7805 (patch)
tree29fd296e0c1f928641b629844a2b722ddcc5f5bd /src/util/benchmark.c
parent654f4cd21ebe073eb7d792e19a148f538f2b93df (diff)
downloadgnunet-ec8162bdf0db6282fbf507e6da72b056119c7805.tar.gz
gnunet-ec8162bdf0db6282fbf507e6da72b056119c7805.zip
improved benchmarking
Diffstat (limited to 'src/util/benchmark.c')
-rw-r--r--src/util/benchmark.c22
1 files changed, 19 insertions, 3 deletions
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 {