aboutsummaryrefslogtreecommitdiff
path: root/src/util/benchmark.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/benchmark.h')
-rw-r--r--src/util/benchmark.h59
1 files changed, 50 insertions, 9 deletions
diff --git a/src/util/benchmark.h b/src/util/benchmark.h
index 6e00906c4..145d7cee7 100644
--- a/src/util/benchmark.h
+++ b/src/util/benchmark.h
@@ -33,6 +33,25 @@
33 */ 33 */
34#define MAX_BENCHMARK_URL_LEN 128 34#define MAX_BENCHMARK_URL_LEN 128
35 35
36#if ENABLE_BENCHMARK
37#define BENCHMARK_START(opname) \
38 struct GNUNET_TIME_Absolute _benchmark_##opname##_start = GNUNET_TIME_absolute_get ()
39#define BENCHMARK_END(opname) do { \
40 { \
41 struct GNUNET_TIME_Absolute _benchmark_##opname##_end = GNUNET_TIME_absolute_get (); \
42 struct BenchmarkData *bd = get_benchmark_data (); \
43 bd->opname##_count++; \
44 bd->opname##_time = \
45 GNUNET_TIME_relative_add (bd->opname##_time, \
46 GNUNET_TIME_absolute_get_difference (_benchmark_##opname##_start, \
47 _benchmark_##opname##_end)); \
48 } \
49} while (0)
50#else
51#define BENCHMARK_START(opname) do { } while (0)
52#define BENCHMARK_END(opname) do { } while (0)
53#endif
54
36 55
37/** 56/**
38 * Struct for benchmark data for one URL. 57 * Struct for benchmark data for one URL.
@@ -70,20 +89,40 @@ struct UrlRequestData
70 struct GNUNET_TIME_Relative time_min; 89 struct GNUNET_TIME_Relative time_min;
71}; 90};
72 91
92#define GNUNET_DECLARE_BENCHMARK_OP(opname) \
93 uint64_t opname##_count; \
94 struct GNUNET_TIME_Relative opname##_time
95
73/** 96/**
74 * Thread-local struct for benchmarking data. 97 * Thread-local struct for benchmarking data.
75 */ 98 */
76struct BenchmarkData 99struct BenchmarkData
77{ 100{
78 /** 101 GNUNET_DECLARE_BENCHMARK_OP (ecc_ecdh);
79 * Number of eddsa_sign operations. 102 GNUNET_DECLARE_BENCHMARK_OP (ecdh_eddsa);
80 */ 103 GNUNET_DECLARE_BENCHMARK_OP (ecdhe_key_create);
81 uint64_t eddsa_sign_count; 104 GNUNET_DECLARE_BENCHMARK_OP (ecdhe_key_get_public);
82 105 GNUNET_DECLARE_BENCHMARK_OP (ecdsa_ecdh);
83 /** 106 GNUNET_DECLARE_BENCHMARK_OP (ecdsa_key_create);
84 * Time spent in eddsa_sign. 107 GNUNET_DECLARE_BENCHMARK_OP (ecdsa_key_get_public);
85 */ 108 GNUNET_DECLARE_BENCHMARK_OP (ecdsa_sign);
86 struct GNUNET_TIME_Relative eddsa_sign_time; 109 GNUNET_DECLARE_BENCHMARK_OP (ecdsa_verify);
110 GNUNET_DECLARE_BENCHMARK_OP (eddsa_ecdh);
111 GNUNET_DECLARE_BENCHMARK_OP (eddsa_key_create);
112 GNUNET_DECLARE_BENCHMARK_OP (eddsa_key_get_public);
113 GNUNET_DECLARE_BENCHMARK_OP (eddsa_sign);
114 GNUNET_DECLARE_BENCHMARK_OP (eddsa_verify);
115 GNUNET_DECLARE_BENCHMARK_OP (hash);
116 GNUNET_DECLARE_BENCHMARK_OP (hash_context_finish);
117 GNUNET_DECLARE_BENCHMARK_OP (hash_context_read);
118 GNUNET_DECLARE_BENCHMARK_OP (hash_context_start);
119 GNUNET_DECLARE_BENCHMARK_OP (hkdf);
120 GNUNET_DECLARE_BENCHMARK_OP (rsa_blind);
121 GNUNET_DECLARE_BENCHMARK_OP (rsa_private_key_create);
122 GNUNET_DECLARE_BENCHMARK_OP (rsa_private_key_get_public);
123 GNUNET_DECLARE_BENCHMARK_OP (rsa_sign_blinded);
124 GNUNET_DECLARE_BENCHMARK_OP (rsa_unblind);
125 GNUNET_DECLARE_BENCHMARK_OP (rsa_verify);
87 126
88 struct UrlRequestData *urd; 127 struct UrlRequestData *urd;
89 128
@@ -92,6 +131,8 @@ struct BenchmarkData
92 unsigned int urd_capacity; 131 unsigned int urd_capacity;
93}; 132};
94 133
134#undef GNUNET_DECLARE_BENCHMARK_OP
135
95 136
96/** 137/**
97 * Acquire the benchmark data for the current thread, allocate if necessary. 138 * Acquire the benchmark data for the current thread, allocate if necessary.