GNUnet  0.10.x
benchmark.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2018 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
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/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19 */
20 
27 #ifndef BENCHMARK_H_
28 #define BENCHMARK_H_
29 
30 #include "gnunet_time_lib.h"
31 
36 #define MAX_BENCHMARK_URL_LEN 128
37 
38 #if ENABLE_BENCHMARK
39 #define BENCHMARK_START(opname) \
40  struct GNUNET_TIME_Absolute _benchmark_##opname##_start = GNUNET_TIME_absolute_get ()
41 #define BENCHMARK_END(opname) do { \
42  { \
43  struct GNUNET_TIME_Absolute _benchmark_##opname##_end = GNUNET_TIME_absolute_get (); \
44  struct BenchmarkData *bd = get_benchmark_data (); \
45  bd->opname##_count++; \
46  bd->opname##_time = \
47  GNUNET_TIME_relative_add (bd->opname##_time, \
48  GNUNET_TIME_absolute_get_difference (_benchmark_##opname##_start, \
49  _benchmark_##opname##_end)); \
50  } \
51 } while (0)
52 #else
53 #define BENCHMARK_START(opname) do { } while (0)
54 #define BENCHMARK_END(opname) do { } while (0)
55 #endif
56 
57 
62 {
67 
71  unsigned int status;
72 
76  uint64_t count;
77 
81  uint64_t bytes_sent;
82 
86  uint64_t bytes_received;
87 
92 
97 
102 };
103 
104 #define GNUNET_DECLARE_BENCHMARK_OP(opname) \
105  uint64_t opname##_count; \
106  struct GNUNET_TIME_Relative opname##_time
107 
112 {
115  GNUNET_DECLARE_BENCHMARK_OP (ecdhe_key_create);
116  GNUNET_DECLARE_BENCHMARK_OP (ecdhe_key_get_public);
118  GNUNET_DECLARE_BENCHMARK_OP (ecdsa_key_create);
119  GNUNET_DECLARE_BENCHMARK_OP (ecdsa_key_get_public);
123  GNUNET_DECLARE_BENCHMARK_OP (eddsa_key_create);
124  GNUNET_DECLARE_BENCHMARK_OP (eddsa_key_get_public);
128  GNUNET_DECLARE_BENCHMARK_OP (hash_context_finish);
129  GNUNET_DECLARE_BENCHMARK_OP (hash_context_read);
130  GNUNET_DECLARE_BENCHMARK_OP (hash_context_start);
133  GNUNET_DECLARE_BENCHMARK_OP (rsa_private_key_create);
134  GNUNET_DECLARE_BENCHMARK_OP (rsa_private_key_get_public);
135  GNUNET_DECLARE_BENCHMARK_OP (rsa_sign_blinded);
138 
140 
141  unsigned int urd_len;
142 
143  unsigned int urd_capacity;
144 };
145 
146 #undef GNUNET_DECLARE_BENCHMARK_OP
147 
148 
155 struct BenchmarkData *
156 get_benchmark_data (void);
157 
167 struct UrlRequestData *
168 get_url_benchmark_data (char *url, unsigned int status);
169 
170 #endif /* BENCHMARK_H_ */
Struct for benchmark data for one URL.
Definition: benchmark.h:61
struct GNUNET_TIME_Relative time_max
Slowest time to response.
Definition: benchmark.h:96
uint64_t count
How often was the URL requested?
Definition: benchmark.h:76
struct GNUNET_TIME_Relative time_min
Fastest time to response.
Definition: benchmark.h:101
struct UrlRequestData * urd
Definition: benchmark.h:139
#define GNUNET_DECLARE_BENCHMARK_OP(opname)
Definition: benchmark.h:104
Thread-local struct for benchmarking data.
Definition: benchmark.h:111
uint64_t bytes_sent
How many bytes were sent in total to request the URL.
Definition: benchmark.h:81
struct GNUNET_TIME_Relative time
Total time spent requesting this URL.
Definition: benchmark.h:91
unsigned int urd_len
Definition: benchmark.h:141
uint64_t bytes_received
How many bytes were received in total as response to requesting this URL.
Definition: benchmark.h:86
#define MAX_BENCHMARK_URL_LEN
Maximum length of URLs considered for benchmarking.
Definition: benchmark.h:36
struct BenchmarkData * get_benchmark_data(void)
Acquire the benchmark data for the current thread, allocate if necessary.
Definition: benchmark.c:206
struct UrlRequestData * get_url_benchmark_data(char *url, unsigned int status)
Get benchmark data for a URL.
Definition: benchmark.c:236
unsigned int urd_capacity
Definition: benchmark.h:143
unsigned int status
HTTP status code.
Definition: benchmark.h:71
char request_url[128]
Request URL, truncated (but 0-terminated).
Definition: benchmark.h:66
Time for relative time used by GNUnet, in microseconds.