Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Setup and teardown that only runs once for a benchmark with the same parameters #1874

Open
balshetzer opened this issue Oct 31, 2024 · 0 comments

Comments

@balshetzer
Copy link

balshetzer commented Oct 31, 2024

Is your feature request related to a problem? Please describe.
Setup and Teardown run for every repetition of the benchmark. As the runner gathers timings it keeps running setup and teardown unnecessarily.

Describe the solution you'd like
For a given benchmark with a specific set of parameters, there should be a way to specify a setup and teardown that runs exactly once.
e.g. RegisterBenchmark(name, func, params...)->SetupOnce(functor)->TeardownOnce(functor).

Describe alternatives you've considered
I haven't found an alternative other than allowing setup and teardown to run unnecessarily and consume resources.

Additional context
If I were trying to benchmark reading the same data from alternative file formats. I might make a general function that can be parameterized on the different formats. The setup would create the file, teardown would delete the file, and the benchmark would extract the data.

It's unnecessary for the setup and teardown to do that again and again for each repetition of the same benchmark with the same parameters. Especially if, say, you had to make the file very large to get accurate benchmark data.

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

No branches or pull requests

1 participant