Skip to content

Conversation

@l0rinc
Copy link

@l0rinc l0rinc commented Jan 3, 2026

Add Bench::setup(...).run(...) for untimed per-epoch setup.
The existing run() now delegates to runImpl() with an empty setup lambda.

Tests verify setup is excluded from timing (50ms sleep → ~0 measured) and runs once before each epoch's iterations (S-RRR-S-RRR pattern).

Fixes: #130
Alternative to: #135

Add Bench::setup(...).run(...) for untimed per-epoch setup.
The existing run() now delegates to runImpl() with an empty setup lambda.

Tests verify setup is excluded from timing (50ms sleep → ~0 measured) and runs once before each epoch's iterations (S-RRR-S-RRR pattern).
@urcheon
Copy link

urcheon commented Jan 7, 2026

For symmetry you should also have teardown, and I can think of use cases where teardown would be helpful.

The only problem I foresee is that with fluent API it becomes a little unintuitive with

Bench::setup(...).teardown(...).run(...)

@l0rinc
Copy link
Author

l0rinc commented Jan 7, 2026

We can do that in a follow-up, but a setup should already fix most cases since we usually need the benchmarking conditions to be met - and tearing it down can either be done in the next setup run or when existing the benchmark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add setup/cleanup hooks to exclude per-iteration overhead from timing

2 participants