]> git.codecow.com Git - Monocypher.git/commitdiff
Corrected timing computation for the speed benchmark
authorLoup Vaillant <loup@loup-vaillant.fr>
Wed, 20 Sep 2017 22:32:59 +0000 (00:32 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Wed, 20 Sep 2017 22:32:59 +0000 (00:32 +0200)
I intended to take the best timing out of several tries.  Turned out I
only took the *last* timing, which defeats the purpose.

Now we take the fastest try as intended.  The results are now a bit
more stable.

tests/speed.c

index 3ce663b890a841332290bb4cbca96ff42fe49911..64fac0fe1dca873e2efcf14665dcab01ec101261 100644 (file)
@@ -53,6 +53,8 @@ static void print(const char *name, u64 speed, const char *unit)
 
 #define TIMING_START                            \
     timespec duration;                          \
+    duration.tv_sec = -1;                       \
+    duration.tv_nsec = -1;                      \
     duration.tv_sec  = 3600 * 24;               \
     duration.tv_nsec = 0;                       \
     FOR (i, 0, 50) {                            \
@@ -60,7 +62,7 @@ static void print(const char *name, u64 speed, const char *unit)
 
 #define TIMING_END                              \
     TIMESTAMP(end);                             \
-    duration = diff(start, end);                \
+    duration = min(duration, diff(start, end)); \
     } /* end FOR*/                              \
     return speed(duration)