mirror of
https://github.com/esphome/esphome.git
synced 2026-10-01 00:40:21 +00:00
Add inner iteration loops to amortize CodSpeed instrumentation overhead
Sub-microsecond benchmarks are dominated by the ~60ns per-iteration valgrind start/stop cost in CodSpeed simulation mode. Add kInnerIterations (1000) inner loops to all fast benchmarks so the actual work dominates. Move DoNotOptimize calls outside inner loops to prevent artificial overhead. Also address review feedback: - Use tokenless CodSpeed (public repo, no CODSPEED_TOKEN needed) - Fix warning message to show component-specific path - Fix stray ". :" in error message - Verify pinned SHA on re-runs to prevent stale checkouts
This commit is contained in:
@@ -171,6 +171,21 @@ def setup_codspeed_lib(output_dir: Path) -> None:
|
||||
"""
|
||||
if not (output_dir / ".git").exists():
|
||||
_clone_repo(output_dir)
|
||||
else:
|
||||
# Verify the existing checkout matches the pinned SHA
|
||||
result = subprocess.run(
|
||||
["git", "-C", str(output_dir), "rev-parse", "HEAD"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
if result.returncode != 0 or result.stdout.strip() != CODSPEED_CPP_SHA:
|
||||
print(
|
||||
f"Stale codspeed-cpp checkout, re-cloning at {CODSPEED_CPP_SHA}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
shutil.rmtree(output_dir)
|
||||
_clone_repo(output_dir)
|
||||
|
||||
benchmark_dir = output_dir / GOOGLE_BENCHMARK_SUBDIR
|
||||
lib_src = benchmark_dir / "src"
|
||||
|
||||
@@ -81,7 +81,7 @@ def filter_components_with_files(components: list[str], tests_dir: Path) -> list
|
||||
filtered_components.append(component)
|
||||
else:
|
||||
print(
|
||||
f"WARNING: No files found for component '{component}' in {tests_dir}, skipping.",
|
||||
f"WARNING: No files found for component '{component}' in {test_dir}, skipping.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return filtered_components
|
||||
@@ -284,7 +284,7 @@ def compile_and_get_binary(
|
||||
print(f"Error compiling {label} for {', '.join(components)}")
|
||||
return exit_code, None
|
||||
except Exception as e:
|
||||
print(f"Error compiling {label} for {', '.join(components)}. Check path. : {e}")
|
||||
print(f"Error compiling {label} for {', '.join(components)}: {e}")
|
||||
return EXIT_COMPILE_ERROR, None
|
||||
|
||||
# After a successful compilation, locate the executable:
|
||||
|
||||
Reference in New Issue
Block a user