gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] 01/02: improved benchmarking


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 01/02: improved benchmarking
Date: Sat, 18 Aug 2018 15:11:49 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository gnunet.

commit ec8162bdf0db6282fbf507e6da72b056119c7805
Author: Florian Dold <address@hidden>
AuthorDate: Sat Aug 18 04:20:10 2018 +0200

    improved benchmarking
---
 src/curl/curl.c      |  2 +-
 src/util/benchmark.c | 22 +++++++++++++++++++---
 src/util/benchmark.h | 10 +++++++++-
 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)
     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 = get_url_benchmark_data (url, (unsigned int) response_code);
     urd->count++;
     urd->time.rel_value_us += total * 1000 * 1000;
   }
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)
   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",
+    GNUNET_asprintf (&s, "url %s status %u count %llu time_us %llu\n",
                      urd->request_url,
+                     urd->status,
                      (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)));
@@ -173,10 +174,13 @@ 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.
  *
+ * Statistics are bucketed by URL and status code.
+ *
  * @param url url to get request data for
+ * @param status http status code
  */
 struct UrlRequestData *
-get_url_benchmark_data (char *url)
+get_url_benchmark_data (char *url, unsigned int status)
 {
   char trunc[MAX_BENCHMARK_URL_LEN];
   struct BenchmarkData *bd;
@@ -191,13 +195,24 @@ get_url_benchmark_data (char *url)
   memcpy (trunc, url, MAX_BENCHMARK_URL_LEN);
   trunc[MAX_BENCHMARK_URL_LEN - 1] = 0;
 
+  /* We're not interested in what's after the query string */
+  for (size_t i = 0; i < strlen (trunc); i++)
+  {
+    if (trunc[i] == '?')
+    {
+      trunc[i] = 0;
+      break;
+    }
+  }
+
   bd = get_benchmark_data ();
 
   GNUNET_assert (bd->urd_len <= bd->urd_capacity);
 
   for (unsigned int i = 0; i < bd->urd_len; i++)
   {
-    if (0 == strcmp (trunc, bd->urd[i].request_url))
+    if ( (0 == strcmp (trunc, bd->urd[i].request_url)) &&
+         (bd->urd[i].status == status) )
       return &bd->urd[i];
   }
 
@@ -205,6 +220,7 @@ get_url_benchmark_data (char *url)
     struct UrlRequestData urd = { 0 };
 
     memcpy (&urd.request_url, trunc, MAX_BENCHMARK_URL_LEN);
+    urd.status = status;
 
     if (bd->urd_len == bd->urd_capacity)
     {
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
    * Request URL, truncated (but 0-terminated).
    */
   char request_url[MAX_BENCHMARK_URL_LEN];
+
+  /**
+   * HTTP status code.
+   */
+  unsigned int status;
   
   /**
    * How often was the URL requested?
@@ -101,9 +106,12 @@ 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.
  *
+ * Statistics are bucketed by URL and status code.
+ *
  * @param url url to get request data for
+ * @param status http status code
  */
 struct UrlRequestData *
-get_url_benchmark_data (char *url);
+get_url_benchmark_data (char *url, unsigned int status);
 
 #endif  /* BENCHMARK_H_ */

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]