[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: missing files
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: missing files |
Date: |
Sat, 18 Aug 2018 01:37:54 +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 f9c758837 missing files
f9c758837 is described below
commit f9c7588373cb3a047345e68377158965d8e8d08a
Author: Florian Dold <address@hidden>
AuthorDate: Sat Aug 18 01:36:37 2018 +0200
missing files
---
src/curl/curl.c | 4 ++
src/util/benchmark.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/util/benchmark.h | 55 +++++++++++++++++++
src/util/crypto_ecc.c | 1 -
4 files changed, 203 insertions(+), 1 deletion(-)
diff --git a/src/curl/curl.c b/src/curl/curl.c
index a0a027995..0d9342b60 100644
--- a/src/curl/curl.c
+++ b/src/curl/curl.c
@@ -30,6 +30,10 @@
#include <jansson.h>
#include "gnunet_curl_lib.h"
+#if ENABLE_BENCHMARK
+#include "../util/benchmark.h"
+#endif
+
/**
* Log error related to CURL operations.
diff --git a/src/util/benchmark.c b/src/util/benchmark.c
new file mode 100644
index 000000000..4a0c9b7c8
--- /dev/null
+++ b/src/util/benchmark.c
@@ -0,0 +1,144 @@
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2018 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file util/benchmark.c
+ * @brief benchmarking for various operations
+ * @author Florian Dold <address@hidden>
+ */
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "benchmark.h"
+#include <pthread.h>
+#include <sys/syscall.h>
+
+/**
+ * Thread-local storage key for the benchmark data.
+ */
+static pthread_key_t key;
+
+/**
+ * One-time initialization marker for key.
+ */
+static pthread_once_t key_once = PTHREAD_ONCE_INIT;
+
+
+/**
+ * Write benchmark data to a file.
+ *
+ * @param bd the benchmark data
+ */
+static void
+write_benchmark_data (struct BenchmarkData *bd)
+{
+ struct GNUNET_DISK_FileHandle *fh;
+ pid_t pid = getpid ();
+ pid_t tid = syscall (SYS_gettid);
+ char *s;
+
+ GNUNET_asprintf (&s, "gnunet-benchmark-%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);
+
+ GNUNET_asprintf (&s, "eddsa_sign_count %llu",
+ (unsigned long long) bd->eddsa_sign_count);
+ 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));
+}
+
+
+/**
+ * Called when the main thread exits and benchmark data for it was created.
+ */
+static void
+main_thread_destructor ()
+{
+ struct BenchmarkData *bd;
+
+ bd = pthread_getspecific (key);
+ if (NULL != bd)
+ write_benchmark_data (bd);
+}
+
+
+/**
+ * Called when a thread exits and benchmark data for it was created.
+ *
+ * @param cls closure
+ */
+static void
+thread_destructor (void *cls)
+{
+ struct BenchmarkData *bd = cls;
+
+ // main thread will be handled by atexit
+ if (getpid () == (pid_t) syscall (SYS_gettid))
+ return;
+
+ GNUNET_assert (NULL != bd);
+
+}
+
+
+/**
+ * Initialize the thread-local variable key for benchmark data.
+ */
+static void
+make_key()
+{
+ (void) pthread_key_create (&key, &thread_destructor);
+}
+
+
+/**
+ * Acquire the benchmark data for the current thread, allocate if necessary.
+ * Installs handler to collect the benchmark data on thread termination.
+ *
+ * @return benchmark data for the current thread
+ */
+struct BenchmarkData *
+get_benchmark_data (void)
+{
+ struct BenchmarkData *bd;
+
+ (void) pthread_once (&key_once, &make_key);
+
+ if (NULL == (bd = pthread_getspecific (key)))
+ {
+ bd = GNUNET_new (struct BenchmarkData);
+ (void) pthread_setspecific (key, bd);
+ if (getpid () == (pid_t) syscall (SYS_gettid))
+ {
+ // We're the main thread!
+ atexit (main_thread_destructor);
+ }
+ }
+ return bd;
+}
diff --git a/src/util/benchmark.h b/src/util/benchmark.h
new file mode 100644
index 000000000..eec9c9c8a
--- /dev/null
+++ b/src/util/benchmark.h
@@ -0,0 +1,55 @@
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2018 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file util/benchmark.h
+ * @brief benchmarking for various operations
+ * @author Florian Dold <address@hidden>
+ */
+
+#ifndef BENCHMARK_H_
+#define BENCHMARK_H_
+
+#include "gnunet_time_lib.h"
+
+/**
+ * Thread-local struct for benchmarking data.
+ */
+struct BenchmarkData {
+ /**
+ * Number of eddsa_sign operations.
+ */
+ uint64_t eddsa_sign_count;
+
+ /**
+ * Time spent in eddsa_sign.
+ */
+ struct GNUNET_TIME_Relative eddsa_sign_time;
+};
+
+
+/**
+ * Acquire the benchmark data for the current thread, allocate if necessary.
+ * Installs handler to collect the benchmark data on thread termination.
+ *
+ * @return benchmark data for the current thread
+ */
+struct BenchmarkData *
+get_benchmark_data (void);
+
+#endif /* BENCHMARK_H_ */
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c
index ed20fa2c8..ca2aa40ad 100644
--- a/src/util/crypto_ecc.c
+++ b/src/util/crypto_ecc.c
@@ -877,7 +877,6 @@ GNUNET_CRYPTO_eddsa_sign (const struct
GNUNET_CRYPTO_EddsaPrivateKey *priv,
#if ENABLE_BENCHMARK
struct BenchmarkData *bd = get_benchmark_data ();
bd->eddsa_sign_count++;
- printf("crypto eddsa sign\n");
#endif
priv_sexp = decode_private_eddsa_key (priv);
--
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: missing files,
gnunet <=