summaryrefslogtreecommitdiff
path: root/src/util/test_speedup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/test_speedup.c')
-rw-r--r--src/util/test_speedup.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/src/util/test_speedup.c b/src/util/test_speedup.c
index a46d83dc3..eacc879df 100644
--- a/src/util/test_speedup.c
+++ b/src/util/test_speedup.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20/** 20/**
21 * @file util/test_speedup.c 21 * @file util/test_speedup.c
22 * @brief testcase for speedup.c 22 * @brief testcase for speedup.c
@@ -47,19 +47,19 @@ static unsigned int cycles;
47 * @param tc scheduler context, unused 47 * @param tc scheduler context, unused
48 */ 48 */
49static void 49static void
50run (void *cls) 50run(void *cls)
51{ 51{
52 cycles++; 52 cycles++;
53 fprintf (stderr, "..%u", cycles); 53 fprintf(stderr, "..%u", cycles);
54 if (cycles <= 5) 54 if (cycles <= 5)
55 { 55 {
56 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 56 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS,
57 &run, 57 &run,
58 NULL); 58 NULL);
59 return; 59 return;
60 } 60 }
61 end = GNUNET_TIME_absolute_get(); 61 end = GNUNET_TIME_absolute_get();
62 fprintf (stderr, "\n"); 62 fprintf(stderr, "\n");
63 fflush(stdout); 63 fflush(stdout);
64} 64}
65 65
@@ -68,23 +68,23 @@ run (void *cls)
68 * 68 *
69 */ 69 */
70static void 70static void
71check (void *cls, 71check(void *cls,
72 char *const *args, 72 char *const *args,
73 const char *cfgfile, 73 const char *cfgfile,
74 const struct GNUNET_CONFIGURATION_Handle *cfg) 74 const struct GNUNET_CONFIGURATION_Handle *cfg)
75{ 75{
76 fprintf (stderr, "0"); 76 fprintf(stderr, "0");
77 fflush (stdout); 77 fflush(stdout);
78 GNUNET_SCHEDULER_add_now (&run, NULL); 78 GNUNET_SCHEDULER_add_now(&run, NULL);
79} 79}
80 80
81 81
82int 82int
83main (int argc, char *argv[]) 83main(int argc, char *argv[])
84{ 84{
85 static char *const argvn[] = { 85 static char *const argvn[] = {
86 "test-speedup", 86 "test-speedup",
87 "-c", "test_speedup_data.conf", 87 "-c", "test_speedup_data.conf",
88 NULL 88 NULL
89 }; 89 };
90 static struct GNUNET_GETOPT_CommandLineOption options[] = { 90 static struct GNUNET_GETOPT_CommandLineOption options[] = {
@@ -94,30 +94,30 @@ main (int argc, char *argv[])
94 time_t end_real; 94 time_t end_real;
95 struct GNUNET_TIME_Relative delta; 95 struct GNUNET_TIME_Relative delta;
96 96
97 start_real = time (NULL); 97 start_real = time(NULL);
98 start = GNUNET_TIME_absolute_get(); 98 start = GNUNET_TIME_absolute_get();
99 GNUNET_PROGRAM_run ((sizeof (argvn) / sizeof (char *)) - 1, argvn, "test-speedup", 99 GNUNET_PROGRAM_run((sizeof(argvn) / sizeof(char *)) - 1, argvn, "test-speedup",
100 "nohelp", options, &check, NULL); 100 "nohelp", options, &check, NULL);
101 101
102 end_real = time (NULL); 102 end_real = time(NULL);
103 delta = GNUNET_TIME_absolute_get_difference (start, end); 103 delta = GNUNET_TIME_absolute_get_difference(start, end);
104 104
105 if (delta.rel_value_us > ((end_real - start_real) * 1500LL * 1000LL)) 105 if (delta.rel_value_us > ((end_real - start_real) * 1500LL * 1000LL))
106 { 106 {
107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 107 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
108 "Execution time in GNUnet time: %s\n", 108 "Execution time in GNUnet time: %s\n",
109 GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_YES)); 109 GNUNET_STRINGS_relative_time_to_string(delta, GNUNET_YES));
110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 110 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
111 "Execution time in system time: %llu ms\n", 111 "Execution time in system time: %llu ms\n",
112 (unsigned long long) ((end_real - start_real) * 1000LL)); 112 (unsigned long long)((end_real - start_real) * 1000LL));
113 return 0; 113 return 0;
114 } 114 }
115 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 115 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
116 "Execution time in GNUnet time: %s\n", 116 "Execution time in GNUnet time: %s\n",
117 GNUNET_STRINGS_relative_time_to_string (delta, GNUNET_YES)); 117 GNUNET_STRINGS_relative_time_to_string(delta, GNUNET_YES));
118 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 118 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
119 "Execution time in system time: %llu ms\n", 119 "Execution time in system time: %llu ms\n",
120 (unsigned long long) ((end_real - start_real) * 1000LL)); 120 (unsigned long long)((end_real - start_real) * 1000LL));
121 return 1; 121 return 1;
122} 122}
123 123