aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_scheduler_delay.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/test_scheduler_delay.c')
-rw-r--r--src/util/test_scheduler_delay.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/util/test_scheduler_delay.c b/src/util/test_scheduler_delay.c
index 1ec86c647..c72ee7b19 100644
--- a/src/util/test_scheduler_delay.c
+++ b/src/util/test_scheduler_delay.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_scheduler_delay.c 21 * @file util/test_scheduler_delay.c
22 * @brief testcase for delay of scheduler, measures how 22 * @brief testcase for delay of scheduler, measures how
@@ -43,51 +43,51 @@ static unsigned long long cumDelta;
43 * @param cls closure 43 * @param cls closure
44 */ 44 */
45static void 45static void
46test_task (void *cls) 46test_task(void *cls)
47{ 47{
48 struct GNUNET_TIME_Absolute now; 48 struct GNUNET_TIME_Absolute now;
49 49
50 now = GNUNET_TIME_absolute_get (); 50 now = GNUNET_TIME_absolute_get();
51 if (now.abs_value_us > target.abs_value_us) 51 if (now.abs_value_us > target.abs_value_us)
52 cumDelta += (now.abs_value_us - target.abs_value_us); 52 cumDelta += (now.abs_value_us - target.abs_value_us);
53 else 53 else
54 cumDelta += (target.abs_value_us - now.abs_value_us); 54 cumDelta += (target.abs_value_us - now.abs_value_us);
55 target = 55 target =
56 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply 56 GNUNET_TIME_relative_to_absolute(GNUNET_TIME_relative_multiply
57 (GNUNET_TIME_UNIT_MICROSECONDS, i)); 57 (GNUNET_TIME_UNIT_MICROSECONDS, i));
58 fprintf (stderr, "%s", "."); 58 fprintf(stderr, "%s", ".");
59 if (i > MAXV) 59 if (i > MAXV)
60 { 60 {
61 fprintf (stderr, "%s", "\n"); 61 fprintf(stderr, "%s", "\n");
62 return; 62 return;
63 } 63 }
64 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 64 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply
65 (GNUNET_TIME_UNIT_MICROSECONDS, i), 65 (GNUNET_TIME_UNIT_MICROSECONDS, i),
66 &test_task, 66 &test_task,
67 NULL); 67 NULL);
68 i += INCR; 68 i += INCR;
69} 69}
70 70
71 71
72int 72int
73main (int argc, char *argv[]) 73main(int argc, char *argv[])
74{ 74{
75 GNUNET_log_setup ("test-scheduler-delay", 75 GNUNET_log_setup("test-scheduler-delay",
76 "WARNING", 76 "WARNING",
77 NULL); 77 NULL);
78 target = GNUNET_TIME_absolute_get (); 78 target = GNUNET_TIME_absolute_get();
79 GNUNET_SCHEDULER_run (&test_task, NULL); 79 GNUNET_SCHEDULER_run(&test_task, NULL);
80 fprintf (stdout, 80 fprintf(stdout,
81 "Sleep precision: %llu microseconds (average delta). ", 81 "Sleep precision: %llu microseconds (average delta). ",
82 cumDelta / (MAXV / INCR)); 82 cumDelta / (MAXV / INCR));
83 if (cumDelta <= 500 * MAXV / INCR) 83 if (cumDelta <= 500 * MAXV / INCR)
84 fprintf (stdout, "%s", "Timer precision is excellent.\n"); 84 fprintf(stdout, "%s", "Timer precision is excellent.\n");
85 else if (cumDelta <= 5000 * MAXV / INCR) /* 5 ms average deviation */ 85 else if (cumDelta <= 5000 * MAXV / INCR) /* 5 ms average deviation */
86 fprintf (stdout, "%s", "Timer precision is good.\n"); 86 fprintf(stdout, "%s", "Timer precision is good.\n");
87 else if (cumDelta > 25000 * MAXV / INCR) 87 else if (cumDelta > 25000 * MAXV / INCR)
88 fprintf (stdout, "%s", "Timer precision is awful.\n"); 88 fprintf(stdout, "%s", "Timer precision is awful.\n");
89 else 89 else
90 fprintf (stdout, "%s", "Timer precision is acceptable.\n"); 90 fprintf(stdout, "%s", "Timer precision is acceptable.\n");
91 return 0; 91 return 0;
92} 92}
93 93