Skip to content

Commit 27bd3d0

Browse files
committed
fix(skills): misleading DCE advice in setup-harness
`benchmark.pedantic` is not a dead-code-elimination tool; it controls the measurement loop. CPython doesn't perform the kind of DCE that `black_box` guards against in compiled languages, so pure-Python benchmarks don't need an equivalent. List the actual primitives for the languages that do (C++: DoNotOptimize, JMH: Blackhole.consume).
1 parent c47530a commit 27bd3d0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

skills/codspeed-setup-harness/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ Good benchmarks are representative, isolated, and stable. Here are guidelines:
287287

288288
- **Avoid benchmarking setup**: Use the framework's setup/teardown mechanisms to exclude initialization from measurements.
289289

290-
- **Prevent dead code elimination**: Use `black_box()` (Rust), `benchmark.pedantic()` (Python), or equivalent to ensure the compiler/runtime doesn't optimize away the work you're measuring.
290+
- **Prevent dead code elimination**: Use `black_box()` (Rust), `benchmark::DoNotOptimize` (C++), or `Blackhole.consume` (JMH) so the compiler doesn't optimize away unused results.
291291

292292
- **Cover the critical path**: Benchmark the functions that matter most to your users — the ones called frequently or on the hot path.
293293

0 commit comments

Comments
 (0)