Context
As described in https://github.com/martinus/nanobench/issues/130, we have a few benchmarks where we have to reset the state between runs; otherwise, the repetitions will do something different than the first iteration.
Upstream
I have opened a PR to nanobench to introduce an untimed setup phase, see: https://github.com/martinus/nanobench/pull/136
Tests
Tests were only added upstream. It would be a bit awkward to wire them into nanobench.h outside the benchmarking setup:
https://github.com/martinus/nanobench/pull/136/changes/58350cfe5912d7e0533ccfcd759eea5d62eb55bb#diff-88160f647ce57661afe7d755fa70a5fa342a2b79d72d3511596878e69ed5cdc3
Fix
I have moved the changes here as well and applied them to a few simple benchmarks as a demonstration.
We can revert the ones that are controversial and add others in follow-ups. This PR is mostly meant to add the setup feature.
Benchmarks
Most benchmarks show a modest "speedup"; others a "slowdown" - but it's only the effect of the setup that's not measured anymore - and a run phase that does the same operation in each epoch iteration (wallet benchmark changes were reverted for simplicity):
<img width="1496" height="882" alt="image" src="https://github.com/user-attachments/assets/34c14565-f3df-41e5-9a86-95b2ca21703a" />