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.h92
1 files changed, 45 insertions, 47 deletions
diff --git a/src/util/benchmark.h b/src/util/benchmark.h
index 4148ac655..6816b47af 100644
--- a/src/util/benchmark.h
+++ b/src/util/benchmark.h
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file util/benchmark.h 22 * @file util/benchmark.h
@@ -37,18 +37,18 @@
37 37
38#if ENABLE_BENCHMARK 38#if ENABLE_BENCHMARK
39#define BENCHMARK_START(opname) \ 39#define BENCHMARK_START(opname) \
40 struct GNUNET_TIME_Absolute _benchmark_##opname##_start = GNUNET_TIME_absolute_get () 40 struct GNUNET_TIME_Absolute _benchmark_ ## opname ## _start = GNUNET_TIME_absolute_get()
41#define BENCHMARK_END(opname) do { \ 41#define BENCHMARK_END(opname) do { \
42 { \ 42 { \
43 struct GNUNET_TIME_Absolute _benchmark_##opname##_end = GNUNET_TIME_absolute_get (); \ 43 struct GNUNET_TIME_Absolute _benchmark_ ## opname ## _end = GNUNET_TIME_absolute_get(); \
44 struct BenchmarkData *bd = get_benchmark_data (); \ 44 struct BenchmarkData *bd = get_benchmark_data(); \
45 bd->opname##_count++; \ 45 bd->opname ## _count++; \
46 bd->opname##_time = \ 46 bd->opname ## _time = \
47 GNUNET_TIME_relative_add (bd->opname##_time, \ 47 GNUNET_TIME_relative_add(bd->opname ## _time, \
48 GNUNET_TIME_absolute_get_difference (_benchmark_##opname##_start, \ 48 GNUNET_TIME_absolute_get_difference(_benchmark_ ## opname ## _start, \
49 _benchmark_##opname##_end)); \ 49 _benchmark_ ## opname ## _end)); \
50 } \ 50 } \
51} while (0) 51 } while (0)
52#else 52#else
53#define BENCHMARK_START(opname) do { } while (0) 53#define BENCHMARK_START(opname) do { } while (0)
54#define BENCHMARK_END(opname) do { } while (0) 54#define BENCHMARK_END(opname) do { } while (0)
@@ -58,8 +58,7 @@
58/** 58/**
59 * Struct for benchmark data for one URL. 59 * Struct for benchmark data for one URL.
60 */ 60 */
61struct UrlRequestData 61struct UrlRequestData {
62{
63 /** 62 /**
64 * Request URL, truncated (but 0-terminated). 63 * Request URL, truncated (but 0-terminated).
65 */ 64 */
@@ -69,7 +68,7 @@ struct UrlRequestData
69 * HTTP status code. 68 * HTTP status code.
70 */ 69 */
71 unsigned int status; 70 unsigned int status;
72 71
73 /** 72 /**
74 * How often was the URL requested? 73 * How often was the URL requested?
75 */ 74 */
@@ -102,39 +101,38 @@ struct UrlRequestData
102}; 101};
103 102
104#define GNUNET_DECLARE_BENCHMARK_OP(opname) \ 103#define GNUNET_DECLARE_BENCHMARK_OP(opname) \
105 uint64_t opname##_count; \ 104 uint64_t opname ## _count; \
106 struct GNUNET_TIME_Relative opname##_time 105 struct GNUNET_TIME_Relative opname ## _time
107 106
108/** 107/**
109 * Thread-local struct for benchmarking data. 108 * Thread-local struct for benchmarking data.
110 */ 109 */
111struct BenchmarkData 110struct BenchmarkData {
112{ 111 GNUNET_DECLARE_BENCHMARK_OP(ecc_ecdh);
113 GNUNET_DECLARE_BENCHMARK_OP (ecc_ecdh); 112 GNUNET_DECLARE_BENCHMARK_OP(ecdh_eddsa);
114 GNUNET_DECLARE_BENCHMARK_OP (ecdh_eddsa); 113 GNUNET_DECLARE_BENCHMARK_OP(ecdhe_key_create);
115 GNUNET_DECLARE_BENCHMARK_OP (ecdhe_key_create); 114 GNUNET_DECLARE_BENCHMARK_OP(ecdhe_key_get_public);
116 GNUNET_DECLARE_BENCHMARK_OP (ecdhe_key_get_public); 115 GNUNET_DECLARE_BENCHMARK_OP(ecdsa_ecdh);
117 GNUNET_DECLARE_BENCHMARK_OP (ecdsa_ecdh); 116 GNUNET_DECLARE_BENCHMARK_OP(ecdsa_key_create);
118 GNUNET_DECLARE_BENCHMARK_OP (ecdsa_key_create); 117 GNUNET_DECLARE_BENCHMARK_OP(ecdsa_key_get_public);
119 GNUNET_DECLARE_BENCHMARK_OP (ecdsa_key_get_public); 118 GNUNET_DECLARE_BENCHMARK_OP(ecdsa_sign);
120 GNUNET_DECLARE_BENCHMARK_OP (ecdsa_sign); 119 GNUNET_DECLARE_BENCHMARK_OP(ecdsa_verify);
121 GNUNET_DECLARE_BENCHMARK_OP (ecdsa_verify); 120 GNUNET_DECLARE_BENCHMARK_OP(eddsa_ecdh);
122 GNUNET_DECLARE_BENCHMARK_OP (eddsa_ecdh); 121 GNUNET_DECLARE_BENCHMARK_OP(eddsa_key_create);
123 GNUNET_DECLARE_BENCHMARK_OP (eddsa_key_create); 122 GNUNET_DECLARE_BENCHMARK_OP(eddsa_key_get_public);
124 GNUNET_DECLARE_BENCHMARK_OP (eddsa_key_get_public); 123 GNUNET_DECLARE_BENCHMARK_OP(eddsa_sign);
125 GNUNET_DECLARE_BENCHMARK_OP (eddsa_sign); 124 GNUNET_DECLARE_BENCHMARK_OP(eddsa_verify);
126 GNUNET_DECLARE_BENCHMARK_OP (eddsa_verify); 125 GNUNET_DECLARE_BENCHMARK_OP(hash);
127 GNUNET_DECLARE_BENCHMARK_OP (hash); 126 GNUNET_DECLARE_BENCHMARK_OP(hash_context_finish);
128 GNUNET_DECLARE_BENCHMARK_OP (hash_context_finish); 127 GNUNET_DECLARE_BENCHMARK_OP(hash_context_read);
129 GNUNET_DECLARE_BENCHMARK_OP (hash_context_read); 128 GNUNET_DECLARE_BENCHMARK_OP(hash_context_start);
130 GNUNET_DECLARE_BENCHMARK_OP (hash_context_start); 129 GNUNET_DECLARE_BENCHMARK_OP(hkdf);
131 GNUNET_DECLARE_BENCHMARK_OP (hkdf); 130 GNUNET_DECLARE_BENCHMARK_OP(rsa_blind);
132 GNUNET_DECLARE_BENCHMARK_OP (rsa_blind); 131 GNUNET_DECLARE_BENCHMARK_OP(rsa_private_key_create);
133 GNUNET_DECLARE_BENCHMARK_OP (rsa_private_key_create); 132 GNUNET_DECLARE_BENCHMARK_OP(rsa_private_key_get_public);
134 GNUNET_DECLARE_BENCHMARK_OP (rsa_private_key_get_public); 133 GNUNET_DECLARE_BENCHMARK_OP(rsa_sign_blinded);
135 GNUNET_DECLARE_BENCHMARK_OP (rsa_sign_blinded); 134 GNUNET_DECLARE_BENCHMARK_OP(rsa_unblind);
136 GNUNET_DECLARE_BENCHMARK_OP (rsa_unblind); 135 GNUNET_DECLARE_BENCHMARK_OP(rsa_verify);
137 GNUNET_DECLARE_BENCHMARK_OP (rsa_verify);
138 136
139 struct UrlRequestData *urd; 137 struct UrlRequestData *urd;
140 138
@@ -153,7 +151,7 @@ struct BenchmarkData
153 * @return benchmark data for the current thread 151 * @return benchmark data for the current thread
154 */ 152 */
155struct BenchmarkData * 153struct BenchmarkData *
156get_benchmark_data (void); 154get_benchmark_data(void);
157 155
158/** 156/**
159 * Get benchmark data for a URL. If the URL is too long, it's truncated 157 * Get benchmark data for a URL. If the URL is too long, it's truncated
@@ -165,6 +163,6 @@ get_benchmark_data (void);
165 * @param status http status code 163 * @param status http status code
166 */ 164 */
167struct UrlRequestData * 165struct UrlRequestData *
168get_url_benchmark_data (char *url, unsigned int status); 166get_url_benchmark_data(char *url, unsigned int status);
169 167
170#endif /* BENCHMARK_H_ */ 168#endif /* BENCHMARK_H_ */