Use CodSpeed's codspeed-cpp fork for simulation mode

- Clone CodSpeed's codspeed-cpp repo (pinned to SHA) in CI
- Create PlatformIO-compatible library.json combining google_benchmark
  and codspeed core sources for proper instrumentation
- Pass library path via BENCHMARK_LIB env var to cpp_benchmark.py
- Use simulation mode for reproducible CPU instruction counting
- Locally, vanilla google/benchmark is used (no CodSpeed instrumentation)
This commit is contained in:
J. Nick Koston
2026-03-16 21:01:31 -10:00
parent a6219434b9
commit 5cd2f58582
2 changed files with 33 additions and 2 deletions
+4 -1
View File
@@ -2,6 +2,7 @@
"""Build and run C++ benchmarks for ESPHome components using Google Benchmark."""
import argparse
import os
from pathlib import Path
import sys
@@ -29,13 +30,15 @@ PLATFORMIO_OPTIONS = {
def run_benchmarks(selected_components: list[str], build_only: bool = False) -> int:
# Allow CI to override the benchmark library (e.g. with CodSpeed's fork)
benchmark_lib = os.environ.get("BENCHMARK_LIB", PLATFORMIO_GOOGLE_BENCHMARK_LIB)
return build_and_run(
selected_components=selected_components,
tests_dir=BENCHMARKS_DIR,
codegen_components=BENCHMARK_CODEGEN_COMPONENTS,
config_prefix="cppbench",
friendly_name="CPP Benchmarks",
libraries=PLATFORMIO_GOOGLE_BENCHMARK_LIB,
libraries=benchmark_lib,
platformio_options=PLATFORMIO_OPTIONS,
main_entry="main.cpp",
label="benchmarks",