mirror of
https://github.com/esphome/esphome.git
synced 2026-09-15 00:58:40 +00:00
Fix CodSpeed instrumentation with PlatformIO
- Use CodSpeed's codspeed-cpp fork with proper instrumentation for simulation mode benchmark detection - setup_codspeed_lib.py creates a flat PlatformIO-compatible library by combining google_benchmark sources, codspeed core, and instrument-hooks into a single library directory - Renames .cc to .cpp (PlatformIO doesn't compile .cc by default) - Adds all required defines: CODSPEED_ENABLED, CODSPEED_SIMULATION, CODSPEED_VERSION, CODSPEED_ROOT_DIR, CODSPEED_MODE_DISPLAY - Output JSON config consumed by cpp_benchmark.py via env var
This commit is contained in:
+16
-2
@@ -26,12 +26,26 @@ PLATFORMIO_OPTIONS = {
|
||||
"-DUSE_TIME_TIMEZONE", # enable timezone code paths
|
||||
"-g", # debug symbols for profiling
|
||||
],
|
||||
# Use deep+ LDF mode to ensure PlatformIO detects the benchmark
|
||||
# library dependency from nested includes.
|
||||
"lib_ldf_mode": "deep+",
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
# Allow CI to override the benchmark library (e.g. with CodSpeed's fork).
|
||||
# BENCHMARK_LIB_CONFIG is a JSON string from setup_codspeed_lib.py
|
||||
# containing {"lib_path": "/path/to/google_benchmark"}.
|
||||
lib_config_json = os.environ.get("BENCHMARK_LIB_CONFIG")
|
||||
|
||||
if lib_config_json:
|
||||
import json
|
||||
|
||||
lib_config = json.loads(lib_config_json)
|
||||
benchmark_lib = f"benchmark=symlink://{lib_config['lib_path']}"
|
||||
else:
|
||||
benchmark_lib = PLATFORMIO_GOOGLE_BENCHMARK_LIB
|
||||
|
||||
return build_and_run(
|
||||
selected_components=selected_components,
|
||||
tests_dir=BENCHMARKS_DIR,
|
||||
|
||||
Reference in New Issue
Block a user