correct cycle test
authorLaurent MAZET <laurent.mazet@thalesgroup.com>
Thu, 23 Oct 2025 17:51:24 +0000 (19:51 +0200)
committerLaurent MAZET <laurent.mazet@thalesgroup.com>
Thu, 23 Oct 2025 17:51:24 +0000 (19:51 +0200)
cycle.c

diff --git a/cycle.c b/cycle.c
index 69852a7a59829616dafa24ce22f6f58341644493..1b0204b5ac46940b1f091c27b067eecfd09990eb 100644 (file)
--- a/cycle.c
+++ b/cycle.c
@@ -41,13 +41,13 @@ void *ping (__attribute__((unused)) void *arg)
 
     for (int i = -1; i < nb_measurements; i++) {
 
-        int duration = MINDUR * ((MAXDUR / MINDUR) * rand () / RAND_MAX);
+        int duration = MINDUR * (1 + (rand () % (MAXDUR / MINDUR)));
 
         ts_t ts1, ts2;
         sys_timestamp (&ts1);
         usleep (duration);
         sys_timestamp (&ts2);
-        if (i != -1) deltas[i] = diff_timestamp (&ts2, &ts1) - duration;
+        if (i != -1) deltas[i] = diff_timestamp (&ts2, &ts1) - duration * 1000;
     }
 
     pthread_exit (NULL);