mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 17:05:36 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user