aboutsummaryrefslogtreecommitdiff
path: root/src/util/benchmark.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/benchmark.c')
-rw-r--r--src/util/benchmark.c59
1 files changed, 52 insertions, 7 deletions
diff --git a/src/util/benchmark.c b/src/util/benchmark.c
index daed7cd2b..f832931ee 100644
--- a/src/util/benchmark.c
+++ b/src/util/benchmark.c
@@ -50,9 +50,22 @@ write_benchmark_data (struct BenchmarkData *bd)
50 struct GNUNET_DISK_FileHandle *fh; 50 struct GNUNET_DISK_FileHandle *fh;
51 pid_t pid = getpid (); 51 pid_t pid = getpid ();
52 pid_t tid = syscall (SYS_gettid); 52 pid_t tid = syscall (SYS_gettid);
53 char *benchmark_dir;
53 char *s; 54 char *s;
54 55
55 GNUNET_asprintf (&s, "gnunet-benchmark-%llu-%llu.txt", 56 benchmark_dir = getenv ("GNUNET_BENCHMARK_DIR");
57
58 if (NULL == benchmark_dir)
59 return;
60
61 if (GNUNET_OK != GNUNET_DISK_directory_create (benchmark_dir))
62 {
63 GNUNET_break (0);
64 return;
65 }
66
67 GNUNET_asprintf (&s, "%s/gnunet-benchmark-ops-%llu-%llu.txt",
68 benchmark_dir,
56 (unsigned long long) pid, 69 (unsigned long long) pid,
57 (unsigned long long) tid); 70 (unsigned long long) tid);
58 71
@@ -65,14 +78,46 @@ write_benchmark_data (struct BenchmarkData *bd)
65 GNUNET_assert (NULL != fh); 78 GNUNET_assert (NULL != fh);
66 GNUNET_free (s); 79 GNUNET_free (s);
67 80
68 GNUNET_asprintf (&s, "eddsa_sign_count %llu", 81#define WRITE_BENCHMARK_OP(opname) do { \
69 (unsigned long long) bd->eddsa_sign_count); 82 GNUNET_asprintf (&s, "op " #opname " count %llu time_us %llu\n", \
70 GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s, strlen (s))); 83 (unsigned long long) bd->opname##_count, \
71 GNUNET_free (s); 84 (unsigned long long) bd->opname##_time.rel_value_us); \
85 GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s, strlen (s))); \
86 GNUNET_free (s); \
87} while (0)
88
89 WRITE_BENCHMARK_OP (ecc_ecdh);
90 WRITE_BENCHMARK_OP (ecdh_eddsa);
91 WRITE_BENCHMARK_OP (ecdhe_key_create);
92 WRITE_BENCHMARK_OP (ecdhe_key_get_public);
93 WRITE_BENCHMARK_OP (ecdsa_ecdh);
94 WRITE_BENCHMARK_OP (ecdsa_key_create);
95 WRITE_BENCHMARK_OP (ecdsa_key_get_public);
96 WRITE_BENCHMARK_OP (ecdsa_sign);
97 WRITE_BENCHMARK_OP (ecdsa_verify);
98 WRITE_BENCHMARK_OP (eddsa_ecdh);
99 WRITE_BENCHMARK_OP (eddsa_key_create);
100 WRITE_BENCHMARK_OP (eddsa_key_get_public);
101 WRITE_BENCHMARK_OP (eddsa_sign);
102 WRITE_BENCHMARK_OP (eddsa_verify);
103 WRITE_BENCHMARK_OP (hash);
104 WRITE_BENCHMARK_OP (hash_context_finish);
105 WRITE_BENCHMARK_OP (hash_context_read);
106 WRITE_BENCHMARK_OP (hash_context_start);
107 WRITE_BENCHMARK_OP (hkdf);
108 WRITE_BENCHMARK_OP (rsa_blind);
109 WRITE_BENCHMARK_OP (rsa_private_key_create);
110 WRITE_BENCHMARK_OP (rsa_private_key_get_public);
111 WRITE_BENCHMARK_OP (rsa_sign_blinded);
112 WRITE_BENCHMARK_OP (rsa_unblind);
113 WRITE_BENCHMARK_OP (rsa_verify);
114
115#undef WRITE_BENCHMARK_OP
72 116
73 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); 117 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh));
74 118
75 GNUNET_asprintf (&s, "gnunet-benchmark-urls-%llu-%llu.txt", 119 GNUNET_asprintf (&s, "%s/gnunet-benchmark-urls-%llu-%llu.txt",
120 benchmark_dir,
76 (unsigned long long) pid, 121 (unsigned long long) pid,
77 (unsigned long long) tid); 122 (unsigned long long) tid);
78 123
@@ -137,7 +182,7 @@ thread_destructor (void *cls)
137 * Initialize the thread-local variable key for benchmark data. 182 * Initialize the thread-local variable key for benchmark data.
138 */ 183 */
139static void 184static void
140make_key() 185make_key ()
141{ 186{
142 (void) pthread_key_create (&key, &thread_destructor); 187 (void) pthread_key_create (&key, &thread_destructor);
143} 188}