mirror of
https://github.com/esphome/esphome.git
synced 2026-09-16 09:38:42 +00:00
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
This commit is contained in:
@@ -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=<path> 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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<uint32_t>(i % 5), []() {});
|
||||
scheduler.set_timeout(&dummy_component, static_cast<uint32_t>(i % 5), 0, []() {});
|
||||
}
|
||||
benchmark::DoNotOptimize(dummy_component);
|
||||
scheduler.process_to_add();
|
||||
benchmark::DoNotOptimize(scheduler);
|
||||
}
|
||||
state.SetItemsProcessed(state.iterations() * kInnerIterations);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user