2 This file is part of GNUnet.
3 Copyright (C) 2020 GNUnet e.V.
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.
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.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
21 * @author Christian Grothoff
22 * @file util/perf_scheduler.c
23 * @brief measure performance of scheduler functions
26 #include "gnunet_util_lib.h"
29 #define RUNS (1024 * 1024)
31 static struct GNUNET_SCHEDULER_Task *task;
37 uint64_t *count = cls;
43 GNUNET_SCHEDULER_shutdown ();
46 task = GNUNET_SCHEDULER_add_now (&run,
52 do_shutdown (void *cls)
55 GNUNET_SCHEDULER_cancel (task);
62 uint64_t *count = cls;
65 task = GNUNET_SCHEDULER_add_now (&run,
67 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
77 GNUNET_SCHEDULER_run (&first,
84 main (int argc, char *argv[])
86 struct GNUNET_TIME_Absolute start;
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),
95 GAUGER ("UTIL", "Scheduler",
97 + GNUNET_TIME_absolute_get_duration
98 (start).rel_value_us / 1000LL), "tasks/ms");
103 /* end of perf_scheduler.c */