From 0af65c5bc958e0372287dbcaff19fc6a00238d07 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 A warm-up step was added to the measurement function to discard the first batch of data, inspired by a privately implemented earlier version that passed tests for queue-related functions. This follows the approach described in the Dudect paper, which skips initial measurements to improve timing stability., potentially mitigating factors like cache misses or allocation delays. Unlike the author's GitHub implementation, which dynamically checks the percentiles array state for each call, a static boolean is used here to mark the first execution within a single test run, as this suits the fixed iteration structure of the testing loop. Tests using queue insertion and removal functions showed no notable difference in constant-time behavior with or without this step after memory leaks were fixed, but it is retained for potential improvements in t-test precision under different test conditions. Change-Id: Ieec138264fdd8d087142cdf3c3e9f961f521e80b --- 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);