]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
fix compiler errors
authorAlan T. DeKok <aland@freeradius.org>
Fri, 23 Sep 2022 14:15:05 +0000 (10:15 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 23 Sep 2022 14:15:05 +0000 (10:15 -0400)
src/lib/util/time_tests.c

index 158535e0a453d7c944180b6856efc3bc5cd085fd..8e667d8c2c364f7308f05297bb9f5de6955156b7 100644 (file)
@@ -24,6 +24,9 @@
 #include <freeradius-devel/util/acutest_helpers.h>
 #include <freeradius-devel/util/time.h>
 
+#define ROUNDS (100000)
+
+DIAG_OFF(unused-but-set-variable)
 static void time_benchmark(void)
 {
        int             i;
@@ -31,20 +34,20 @@ static void time_benchmark(void)
        uint64_t        rate;
 
        start = fr_time();
-       for (i = 0; i < 100000; i++) {
-               fr_time_t now;
+       for (i = 0; i < ROUNDS; i++) {
+               volatile fr_time_t now;
 
-               (fr_time_t volatile)now = fr_time();
+               now = fr_time();
        }
        stop = fr_time();
 
-       rate = (uint64_t)((float)NSEC / (fr_time_delta_unwrap(fr_time_sub(stop, start)) / 100000));
+       rate = (uint64_t)((float)NSEC / (fr_time_delta_unwrap(fr_time_sub(stop, start)) / ROUNDS));
        printf("fr_time rate %" PRIu64 "\n", rate);
 
        /* shared runners are terrible for performance tests */
-       if (!getenv("NO_PERFORMANCE_TESTS")) TEST_CHECK(rate > 1000000);
+       if (!getenv("NO_PERFORMANCE_TESTS")) TEST_CHECK(rate > (ROUNDS * 10));
 }
-
+DIAG_ON(unused-but-set-variable)
 
 TEST_LIST = {
        { "time_const_benchmark",               time_benchmark },