diff options
Diffstat (limited to 'src/util/perf_scheduler.c')
-rw-r--r-- | src/util/perf_scheduler.c | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/src/util/perf_scheduler.c b/src/util/perf_scheduler.c deleted file mode 100644 index 4d4d0a228..000000000 --- a/src/util/perf_scheduler.c +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2020 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 | /** | ||
21 | * @author Christian Grothoff | ||
22 | * @file util/perf_scheduler.c | ||
23 | * @brief measure performance of scheduler functions | ||
24 | */ | ||
25 | #include "platform.h" | ||
26 | #include "gnunet_util_lib.h" | ||
27 | #include <gauger.h> | ||
28 | |||
29 | #define RUNS (1024 * 1024) | ||
30 | |||
31 | static struct GNUNET_SCHEDULER_Task *task; | ||
32 | |||
33 | |||
34 | static void | ||
35 | run (void *cls) | ||
36 | { | ||
37 | uint64_t *count = cls; | ||
38 | |||
39 | task = NULL; | ||
40 | (*count)++; | ||
41 | if (*count >= RUNS) | ||
42 | { | ||
43 | GNUNET_SCHEDULER_shutdown (); | ||
44 | return; | ||
45 | } | ||
46 | task = GNUNET_SCHEDULER_add_now (&run, | ||
47 | count); | ||
48 | } | ||
49 | |||
50 | |||
51 | static void | ||
52 | do_shutdown (void *cls) | ||
53 | { | ||
54 | if (NULL != task) | ||
55 | GNUNET_SCHEDULER_cancel (task); | ||
56 | } | ||
57 | |||
58 | |||
59 | static void | ||
60 | first (void *cls) | ||
61 | { | ||
62 | uint64_t *count = cls; | ||
63 | |||
64 | (*count)++; | ||
65 | task = GNUNET_SCHEDULER_add_now (&run, | ||
66 | count); | ||
67 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | ||
68 | NULL); | ||
69 | } | ||
70 | |||
71 | |||
72 | static uint64_t | ||
73 | perf_scheduler () | ||
74 | { | ||
75 | uint64_t count = 0; | ||
76 | |||
77 | GNUNET_SCHEDULER_run (&first, | ||
78 | &count); | ||
79 | return count; | ||
80 | } | ||
81 | |||
82 | |||
83 | int | ||
84 | main (int argc, char *argv[]) | ||
85 | { | ||
86 | struct GNUNET_TIME_Absolute start; | ||
87 | uint64_t tasks; | ||
88 | |||
89 | start = GNUNET_TIME_absolute_get (); | ||
90 | tasks = perf_scheduler (); | ||
91 | printf ("Scheduler perf took %s\n", | ||
92 | GNUNET_STRINGS_relative_time_to_string ( | ||
93 | GNUNET_TIME_absolute_get_duration (start), | ||
94 | GNUNET_YES)); | ||
95 | GAUGER ("UTIL", "Scheduler", | ||
96 | tasks / 1024 / (1 | ||
97 | + GNUNET_TIME_absolute_get_duration | ||
98 | (start).rel_value_us / 1000LL), "tasks/ms"); | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | |||
103 | /* end of perf_scheduler.c */ | ||