From e45cfc5451d52bfaa92cee48c25f4ff6a71f13b6 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 17 Mar 2026 00:37:58 -1000 Subject: [PATCH] =?UTF-8?q?Revert=20scheduler=20now=20reset=20=E2=80=94=20?= =?UTF-8?q?must=20be=20monotonic=20for=20millis=5F64=5Ffrom=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit millis_64_from_() tracks 32-bit rollovers, so going backwards in time would appear as a ~49 day forward jump. Keep now monotonically increasing across all iterations. With 2000 inner iterations per outer iteration, overflow is not a practical concern. --- tests/benchmarks/core/bench_scheduler.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/benchmarks/core/bench_scheduler.cpp b/tests/benchmarks/core/bench_scheduler.cpp index f49b19a626..c0f47b0fc4 100644 --- a/tests/benchmarks/core/bench_scheduler.cpp +++ b/tests/benchmarks/core/bench_scheduler.cpp @@ -72,9 +72,13 @@ static void Scheduler_Call_5IntervalsFiring(benchmark::State &state) { } scheduler.process_to_add(); + // Start at a known time so intervals are immediately due. + // now increases monotonically across all iterations — this is required + // because millis_64_from_() tracks rollovers and going backwards would + // appear as a 32-bit wrap (~49 day jump forward). + uint32_t now = millis() + 100; + for (auto _ : state) { - // Reset each outer iteration to avoid unbounded growth toward UINT32_MAX - uint32_t now = 100; for (int i = 0; i < kInnerIterations; i++) { scheduler.call(now); // Advance time by 1ms so intervals are due again next call