From a51c643d1880a6afc33de6583a09ed1ec62b4426 Mon Sep 17 00:00:00 2001 From: HeatCraB Date: Fri, 4 Apr 2025 23:02:13 +0800 Subject: [PATCH] Introduce Warm-up Phase for Dudect Measurement Inspired by 'Reparaz et al.'s' 2016 paper, this change adds a warm-up phase to the function that collects and processes measurement batches, skipping the first batch to reduce timing variance in queue operations like insert and remove. Unlike the author's implementation, which uses dynamic percentile checks, this approach uses a static boolean to mark the initial run, suiting the fixed test loop. Experiments in simulation mode with qtest.c and perf show a minor 1.5% reduction in standard deviation (from 449ms to 442ms), suggesting a small improvement in execution stability. Reference: 'Reparaz et al.', "Dude, is my code constant time?", 2016, https://eprint.iacr.org/2016/1123.pdf Change-Id: I71692702401c130cd7cac1d424209308baecb87b --- dudect/fixture.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/dudect/fixture.c b/dudect/fixture.c index c2e273a7a..bf6ce8f31 100644 --- a/dudect/fixture.c +++ b/dudect/fixture.c @@ -196,8 +196,20 @@ static bool doit(int mode) bool ret = measure(before_ticks, after_ticks, input_data, mode); differentiate(exec_times, before_ticks, after_ticks); prepare_percentiles(exec_times, percentiles); - update_statistics(exec_times, classes, percentiles); - ret &= report(); + + /* This warm-up step discards the first measurement batch by skipping + * its statistical analysis. A static boolean flag controls this by + * marking the initial execution, ensuring only the first call within + * a test run is excluded from the t-test computation. + */ + static bool first_time = true; + if (first_time) { + first_time = false; + ret = true; + } else { + update_statistics(exec_times, classes, percentiles); + ret &= report(); + } free(before_ticks); free(after_ticks);