From b87b4102e048da8007c429c73e3da83438a02c5d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 17 Mar 2026 01:42:37 -1000 Subject: [PATCH] Fix binary path extraction and defer benchmark compile error - Use BENCHMARK_BINARY= marker for reliable binary path extraction instead of fragile tail -1 (PlatformIO can print warnings after path) - Fix Scheduler_Defer: defer() is protected on Component, use set_timeout(delay=0) directly on Scheduler instead --- .github/workflows/ci.yml | 4 ++-- script/test_helpers.py | 2 +- tests/benchmarks/core/bench_scheduler.cpp | 10 +++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a5ac0e29ee..0a4a6302bf2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -332,8 +332,8 @@ jobs: run: | . venv/bin/activate export BENCHMARK_LIB_CONFIG=$(python script/setup_codspeed_lib.py) - # --build-only prints the binary path as the last line of stdout - BINARY=$(script/cpp_benchmark.py --all --build-only | tail -1) + # --build-only prints BENCHMARK_BINARY= to stdout + BINARY=$(script/cpp_benchmark.py --all --build-only | grep '^BENCHMARK_BINARY=' | tail -1 | cut -d= -f2-) echo "binary=$BINARY" >> $GITHUB_OUTPUT - name: Run CodSpeed benchmarks diff --git a/script/test_helpers.py b/script/test_helpers.py index 24d99acaeb0..ad290b7ceba 100644 --- a/script/test_helpers.py +++ b/script/test_helpers.py @@ -389,7 +389,7 @@ def build_and_run( return exit_code if build_only: - print(program_path) + print(f"BENCHMARK_BINARY={program_path}") return EXIT_OK # Run the binary diff --git a/tests/benchmarks/core/bench_scheduler.cpp b/tests/benchmarks/core/bench_scheduler.cpp index 1b61223f755..f481bfc9e97 100644 --- a/tests/benchmarks/core/bench_scheduler.cpp +++ b/tests/benchmarks/core/bench_scheduler.cpp @@ -111,16 +111,20 @@ static void Scheduler_SetInterval(benchmark::State &state) { } BENCHMARK(Scheduler_SetInterval); -// --- Scheduler: defer registration --- +// --- Scheduler: defer registration (set_timeout with delay=0) --- static void Scheduler_Defer(benchmark::State &state) { + Scheduler scheduler; Component dummy_component; + // defer() is Component::defer which calls set_timeout(delay=0). + // Call set_timeout directly since defer() is protected. for (auto _ : state) { for (int i = 0; i < kInnerIterations; i++) { - dummy_component.defer(static_cast(i % 5), []() {}); + scheduler.set_timeout(&dummy_component, static_cast(i % 5), 0, []() {}); } - benchmark::DoNotOptimize(dummy_component); + scheduler.process_to_add(); + benchmark::DoNotOptimize(scheduler); } state.SetItemsProcessed(state.iterations() * kInnerIterations); }