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 
66 
70  unsigned int status;
71 
75  uint64_t count;
76 
80  uint64_t bytes_sent;
81 
85  uint64_t bytes_received;
86 
91 
96 
101 };
102 
103 #define GNUNET_DECLARE_BENCHMARK_OP(opname) \
104  uint64_t opname ## _count; \
105  struct GNUNET_TIME_Relative opname ## _time
106 
113  GNUNET_DECLARE_BENCHMARK_OP(ecdhe_key_create);
114  GNUNET_DECLARE_BENCHMARK_OP(ecdhe_key_get_public);
116  GNUNET_DECLARE_BENCHMARK_OP(ecdsa_key_create);
117  GNUNET_DECLARE_BENCHMARK_OP(ecdsa_key_get_public);
121  GNUNET_DECLARE_BENCHMARK_OP(eddsa_key_create);
122  GNUNET_DECLARE_BENCHMARK_OP(eddsa_key_get_public);
126  GNUNET_DECLARE_BENCHMARK_OP(hash_context_finish);
127  GNUNET_DECLARE_BENCHMARK_OP(hash_context_read);
128  GNUNET_DECLARE_BENCHMARK_OP(hash_context_start);
131  GNUNET_DECLARE_BENCHMARK_OP(rsa_private_key_create);
132  GNUNET_DECLARE_BENCHMARK_OP(rsa_private_key_get_public);
133  GNUNET_DECLARE_BENCHMARK_OP(rsa_sign_blinded);
136 
138 
139  unsigned int urd_len;
140 
141  unsigned int urd_capacity;
142 };
143 
144 #undef GNUNET_DECLARE_BENCHMARK_OP
145 
146 
153 struct BenchmarkData *
154 get_benchmark_data(void);
155 
165 struct UrlRequestData *
166 get_url_benchmark_data(char *url, unsigned int status);
167 
168 #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:95
uint64_t count
How often was the URL requested?
Definition: benchmark.h:75
struct GNUNET_TIME_Relative time_min
Fastest time to response.
Definition: benchmark.h:100
struct UrlRequestData * urd
Definition: benchmark.h:137
#define GNUNET_DECLARE_BENCHMARK_OP(opname)
Definition: benchmark.h:103
Thread-local struct for benchmarking data.
Definition: benchmark.h:110
uint64_t bytes_sent
How many bytes were sent in total to request the URL.
Definition: benchmark.h:80
struct GNUNET_TIME_Relative time
Total time spent requesting this URL.
Definition: benchmark.h:90
unsigned int urd_len
Definition: benchmark.h:139
uint64_t bytes_received
How many bytes were received in total as response to requesting this URL.
Definition: benchmark.h:85
#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:141
unsigned int status
HTTP status code.
Definition: benchmark.h:70
char request_url[128]
Request URL, truncated (but 0-terminated).
Definition: benchmark.h:65
Time for relative time used by GNUnet, in microseconds.