mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 08:55:36 +00:00
Suppress blocking warnings in scheduler benchmarks
Under valgrind, 2000 inner iterations take long enough in wall clock to trigger WarnIfComponentBlockingGuard. Use a BenchComponent subclass that sets warn_if_blocking_over_ to UINT16_MAX to prevent log noise.
This commit is contained in:
@@ -10,6 +10,15 @@ namespace esphome::benchmarks {
|
||||
// sub-microsecond benchmarks.
|
||||
static constexpr int kInnerIterations = 2000;
|
||||
|
||||
// Component subclass that suppresses blocking warnings.
|
||||
// Under valgrind, 2000 inner iterations take long enough in wall clock
|
||||
// to trigger WarnIfComponentBlockingGuard. Setting the threshold to max
|
||||
// prevents log noise without affecting the benchmarked code path.
|
||||
class BenchComponent : public Component {
|
||||
public:
|
||||
BenchComponent() { this->warn_if_blocking_over_ = UINT16_MAX; }
|
||||
};
|
||||
|
||||
// --- Scheduler fast path: no work to do ---
|
||||
|
||||
static void Scheduler_Call_NoWork(benchmark::State &state) {
|
||||
@@ -30,7 +39,7 @@ BENCHMARK(Scheduler_Call_NoWork);
|
||||
|
||||
static void Scheduler_Call_TimersNotDue(benchmark::State &state) {
|
||||
Scheduler scheduler;
|
||||
Component dummy_component;
|
||||
BenchComponent dummy_component;
|
||||
|
||||
// Add some timeouts far in the future
|
||||
for (int i = 0; i < 10; i++) {
|
||||
@@ -54,7 +63,7 @@ BENCHMARK(Scheduler_Call_TimersNotDue);
|
||||
|
||||
static void Scheduler_Call_5IntervalsFiring(benchmark::State &state) {
|
||||
Scheduler scheduler;
|
||||
Component dummy_component;
|
||||
BenchComponent dummy_component;
|
||||
int fire_count = 0;
|
||||
|
||||
// Add 5 intervals with 1ms period — they fire every call when time advances
|
||||
@@ -82,7 +91,7 @@ BENCHMARK(Scheduler_Call_5IntervalsFiring);
|
||||
|
||||
static void Scheduler_NextScheduleIn(benchmark::State &state) {
|
||||
Scheduler scheduler;
|
||||
Component dummy_component;
|
||||
BenchComponent dummy_component;
|
||||
|
||||
// Add some timeouts
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
Reference in New Issue
Block a user