Fix scheduler benchmark triggering warn_blocking

WarnIfComponentBlockingGuard compares the `now` passed to
scheduler.call() against real millis() in finish(). Using fake time
ahead of real millis() caused uint32_t underflow in the guard, triggering
blocking warnings. Fix by reading real millis() at the start of each
outer iteration so fake time stays close to wall clock.
This commit is contained in:
J. Nick Koston
2026-03-17 00:53:10 -10:00
parent 662780bcc6
commit 4565167bec
+4 -4
View File
@@ -72,13 +72,13 @@ static void Scheduler_Call_5IntervalsFiring(benchmark::State &state) {
}
scheduler.process_to_add();
// Must be monotonic — millis_64_from_() tracks rollovers.
uint32_t now = millis() + 100;
for (auto _ : state) {
// Use real millis() each outer iteration so our fake time stays close
// to wall clock — WarnIfComponentBlockingGuard compares the `now` we
// pass to scheduler.call() against real millis() in finish().
uint32_t now = millis();
for (int i = 0; i < kInnerIterations; i++) {
scheduler.call(now);
// Advance time by 1ms so intervals are due again next call
now++;
}
benchmark::DoNotOptimize(fire_count);