GNUnet 0.21.0
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 = \
41 GNUNET_TIME_absolute_get ()
42#define BENCHMARK_END(opname) do { \
43 { \
44 struct GNUNET_TIME_Absolute _benchmark_ ## opname ## _end = \
45 GNUNET_TIME_absolute_get (); \
46 struct BenchmarkData *bd = get_benchmark_data (); \
47 bd->opname ## _count++; \
48 bd->opname ## _time = \
49 GNUNET_TIME_relative_add (bd->opname ## _time, \
50 GNUNET_TIME_absolute_get_difference ( \
51 _benchmark_ ## opname ## _start, \
52 _benchmark_ \
53 ## opname ## _end)); \
54 } \
55} while (0)
56#else
57#define BENCHMARK_START(opname) do { } while (0)
58#define BENCHMARK_END(opname) do { } while (0)
59#endif
60
61
66{
71
75 unsigned int status;
76
80 uint64_t count;
81
85 uint64_t bytes_sent;
86
91
96
101
106};
107
108#define GNUNET_DECLARE_BENCHMARK_OP(opname) \
109 uint64_t opname ## _count; \
110 struct GNUNET_TIME_Relative opname ## _time
111
116{
119 GNUNET_DECLARE_BENCHMARK_OP (ecdhe_key_create);
120 GNUNET_DECLARE_BENCHMARK_OP (ecdhe_key_get_public);
122 GNUNET_DECLARE_BENCHMARK_OP (ecdsa_key_create);
123 GNUNET_DECLARE_BENCHMARK_OP (ecdsa_key_get_public);
127 GNUNET_DECLARE_BENCHMARK_OP (eddsa_key_create);
128 GNUNET_DECLARE_BENCHMARK_OP (eddsa_key_get_public);
132 GNUNET_DECLARE_BENCHMARK_OP (hash_context_finish);
133 GNUNET_DECLARE_BENCHMARK_OP (hash_context_read);
134 GNUNET_DECLARE_BENCHMARK_OP (hash_context_start);
137 GNUNET_DECLARE_BENCHMARK_OP (rsa_private_key_create);
138 GNUNET_DECLARE_BENCHMARK_OP (rsa_private_key_get_public);
139 GNUNET_DECLARE_BENCHMARK_OP (rsa_sign_blinded);
142
144
145 unsigned int urd_len;
146
147 unsigned int urd_capacity;
148};
149
150#undef GNUNET_DECLARE_BENCHMARK_OP
151
152
159struct BenchmarkData *
160get_benchmark_data (void);
161
171struct UrlRequestData *
172get_url_benchmark_data (char *url, unsigned int status);
173
174#endif /* BENCHMARK_H_ */
struct UrlRequestData * get_url_benchmark_data(char *url, unsigned int status)
Get benchmark data for a URL.
Definition: benchmark.c:242
struct BenchmarkData * get_benchmark_data(void)
Acquire the benchmark data for the current thread, allocate if necessary.
Definition: benchmark.c:212
#define MAX_BENCHMARK_URL_LEN
Maximum length of URLs considered for benchmarking.
Definition: benchmark.h:36
#define GNUNET_DECLARE_BENCHMARK_OP(opname)
Definition: benchmark.h:108
static int status
The program status; 0 for success.
Definition: gnunet-nse.c:38
Functions related to time.
Thread-local struct for benchmarking data.
Definition: benchmark.h:116
unsigned int urd_capacity
Definition: benchmark.h:147
struct UrlRequestData * urd
Definition: benchmark.h:143
unsigned int urd_len
Definition: benchmark.h:145
Time for relative time used by GNUnet, in microseconds.
Struct for benchmark data for one URL.
Definition: benchmark.h:66
struct GNUNET_TIME_Relative time
Total time spent requesting this URL.
Definition: benchmark.h:95
char request_url[128]
Request URL, truncated (but 0-terminated).
Definition: benchmark.h:70
unsigned int status
HTTP status code.
Definition: benchmark.h:75
struct GNUNET_TIME_Relative time_min
Fastest time to response.
Definition: benchmark.h:105
uint64_t bytes_received
How many bytes were received in total as response to requesting this URL.
Definition: benchmark.h:90
struct GNUNET_TIME_Relative time_max
Slowest time to response.
Definition: benchmark.h:100
uint64_t bytes_sent
How many bytes were sent in total to request the URL.
Definition: benchmark.h:85
uint64_t count
How often was the URL requested?
Definition: benchmark.h:80