2 This file is part of GNUnet.
3 Copyright (C) 2011-2013 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/>.
19 * @file util/test_speedup.c
20 * @brief testcase for speedup.c
23 #include "gnunet_util_lib.h"
26 * Start time of the testcase
28 static struct GNUNET_TIME_Absolute start;
31 * End-time of the testcase (affected by speed-up)
33 static struct GNUNET_TIME_Absolute end;
36 * Number of cycles we have spent in 'run'.
38 static unsigned int cycles;
42 * Main task that is scheduled with the speed-up.
45 * @param tc scheduler context, unused
51 fprintf (stderr, "..%u", cycles);
54 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
59 end = GNUNET_TIME_absolute_get();
60 fprintf (stderr, "\n");
72 const struct GNUNET_CONFIGURATION_Handle *cfg)
74 fprintf (stderr, "0");
76 GNUNET_SCHEDULER_add_now (&run, NULL);
81 main (int argc, char *argv[])
83 static char *const argvn[] = {
85 "-c", "test_speedup_data.conf",
88 static struct GNUNET_GETOPT_CommandLineOption options[] = {
89 GNUNET_GETOPT_OPTION_END
93 struct GNUNET_TIME_Relative delta;
95 start_real = time (NULL);
96 start = GNUNET_TIME_absolute_get();
97 GNUNET_PROGRAM_run ((sizeof (argvn) / sizeof (char *)) - 1, argvn, "test-speedup",
98 "nohelp", options, &check, NULL);
100 end_real = time (NULL);
101 delta = GNUNET_TIME_absolute_get_difference (start, end);
103 if (delta.rel_value_us > ((end_real - start_real) * 1500LL * 1000LL))
105 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
106 "Execution time in GNUnet time: %s\n",
107 GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_YES));
108 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
109 "Execution time in system time: %llu ms\n",
110 (unsigned long long) ((end_real - start_real) * 1000LL));
113 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
114 "Execution time in GNUnet time: %s\n",
115 GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_YES));
116 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
117 "Execution time in system time: %llu ms\n",
118 (unsigned long long) ((end_real - start_real) * 1000LL));
122 /* end of test_speedup.c */