test: Use the range-based loop in all benchmarks - #1655
Closed
chfast wants to merge 1 commit into
Closed
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1655 +/- ##
=======================================
Coverage 97.72% 97.72%
=======================================
Files 171 171
Lines 15631 15631
Branches 3617 3617
=======================================
Hits 15275 15275
Misses 269 269
Partials 87 87
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Standardizes batched benchmarks on range-based loops while preserving per-item throughput reporting.
Changes:
- Replaces eight
KeepRunningBatch()loops. - Adds processed-item counters.
- Preserves gas metrics in precompile benchmarks.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
test/precompiles_bench/precompiles_bench.cpp |
Updates precompile loop and item reporting. |
test/internal_benchmarks/lru_cache_bench.cpp |
Updates batched cache insertion benchmark. |
test/internal_benchmarks/find_jumpdest_bench.cpp |
Updates random lookup benchmarks. |
test/internal_benchmarks/evmmax_bench.cpp |
Updates modular arithmetic benchmarks. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Replace the 8 KeepRunningBatch() loops with the range-based one. The batch size never drove the loop body, it only told google/benchmark to divide the reported time by it, so the executed work is unchanged and only the Time column changes from per item to per loop iteration. The per-item time is now reported explicitly by the avg_time_per_item counter, and the precompiles report avg_gas_used per input to match it: avg_gas_used / avg_time_per_input is exactly gas_rate. Uniform loops also keep every benchmark measurable by the tools instrumenting the range-based loop only.
chfast
force-pushed
the
test/bench-batch-loop
branch
from
August 14, 2026 08:01
8282d9e to
d8033c1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the 8
state.KeepRunningBatch(N)loops with the range-basedfor (auto _ : state)one.KeepRunningBatch()never drove the loop body — the body already iterated over all the items itself. The batch size only told google/benchmark to divide the measured time by it, so this changes the reporting, not the executed work:avg_time_per_inputinprecompiles_bench) is added and reports what the Time column reported before.avg_gas_used / avg_time_per_inputis exactlygas_rate.Before and after with the same compiler,
precompile<PrecompileId::ecrecover, evmone>:The per-item counter matters most for
find_jumpdestandlru_cache, where the batch size is derived from the benchmark argument (indexes.size(),capacity): without it a larger argument would simply look slower per iteration.Uniform loops also keep every benchmark measurable by tools instrumenting the range-based loop only, which is the case for the CodSpeed compatibility layer: #1653 currently needs a dedicated macro to swap the loop in its builds, and that macro can be dropped once this lands.