diff options
Diffstat (limited to 'src/util/test_speedup.c')
-rw-r--r-- | src/util/test_speedup.c | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/src/util/test_speedup.c b/src/util/test_speedup.c deleted file mode 100644 index bca6886aa..000000000 --- a/src/util/test_speedup.c +++ /dev/null | |||
@@ -1,126 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2011-2013 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 | * @file util/test_speedup.c | ||
22 | * @brief testcase for speedup.c | ||
23 | */ | ||
24 | #include "platform.h" | ||
25 | #include "gnunet_util_lib.h" | ||
26 | |||
27 | /** | ||
28 | * Start time of the testcase | ||
29 | */ | ||
30 | static struct GNUNET_TIME_Absolute start; | ||
31 | |||
32 | /** | ||
33 | * End-time of the testcase (affected by speed-up) | ||
34 | */ | ||
35 | static struct GNUNET_TIME_Absolute end; | ||
36 | |||
37 | /** | ||
38 | * Number of cycles we have spent in 'run'. | ||
39 | */ | ||
40 | static unsigned int cycles; | ||
41 | |||
42 | |||
43 | /** | ||
44 | * Main task that is scheduled with the speed-up. | ||
45 | * | ||
46 | * @param cls NULL | ||
47 | * @param tc scheduler context, unused | ||
48 | */ | ||
49 | static void | ||
50 | run (void *cls) | ||
51 | { | ||
52 | cycles++; | ||
53 | fprintf (stderr, "..%u", cycles); | ||
54 | if (cycles <= 5) | ||
55 | { | ||
56 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
57 | &run, | ||
58 | NULL); | ||
59 | return; | ||
60 | } | ||
61 | end = GNUNET_TIME_absolute_get (); | ||
62 | fprintf (stderr, "\n"); | ||
63 | fflush (stdout); | ||
64 | } | ||
65 | |||
66 | |||
67 | /** | ||
68 | * | ||
69 | */ | ||
70 | static void | ||
71 | check (void *cls, | ||
72 | char *const *args, | ||
73 | const char *cfgfile, | ||
74 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
75 | { | ||
76 | fprintf (stderr, "0"); | ||
77 | fflush (stdout); | ||
78 | GNUNET_SCHEDULER_add_now (&run, NULL); | ||
79 | } | ||
80 | |||
81 | |||
82 | int | ||
83 | main (int argc, char *argv[]) | ||
84 | { | ||
85 | static char *const argvn[] = { | ||
86 | "test-speedup", | ||
87 | "-c", "test_speedup_data.conf", | ||
88 | NULL | ||
89 | }; | ||
90 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
91 | GNUNET_GETOPT_OPTION_END | ||
92 | }; | ||
93 | time_t start_real; | ||
94 | time_t end_real; | ||
95 | struct GNUNET_TIME_Relative delta; | ||
96 | |||
97 | start_real = time (NULL); | ||
98 | start = GNUNET_TIME_absolute_get (); | ||
99 | GNUNET_PROGRAM_run ((sizeof(argvn) / sizeof(char *)) - 1, argvn, | ||
100 | "test-speedup", | ||
101 | "nohelp", options, &check, NULL); | ||
102 | |||
103 | end_real = time (NULL); | ||
104 | delta = GNUNET_TIME_absolute_get_difference (start, end); | ||
105 | |||
106 | if (delta.rel_value_us > ((end_real - start_real) * 1500LL * 1000LL)) | ||
107 | { | ||
108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
109 | "Execution time in GNUnet time: %s\n", | ||
110 | GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_YES)); | ||
111 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
112 | "Execution time in system time: %llu ms\n", | ||
113 | (unsigned long long) ((end_real - start_real) * 1000LL)); | ||
114 | return 0; | ||
115 | } | ||
116 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
117 | "Execution time in GNUnet time: %s\n", | ||
118 | GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_YES)); | ||
119 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
120 | "Execution time in system time: %llu ms\n", | ||
121 | (unsigned long long) ((end_real - start_real) * 1000LL)); | ||
122 | return 1; | ||
123 | } | ||
124 | |||
125 | |||
126 | /* end of test_speedup.c */ | ||