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] global setup and teardown #1873

Open
balshetzer opened this issue Oct 29, 2024 · 4 comments
Open

[FR] global setup and teardown #1873

balshetzer opened this issue Oct 29, 2024 · 4 comments

Comments

@balshetzer
Copy link

Is your feature request related to a problem? Please describe.
I have benchmarks that need to create files. The benchmark is run multiple times to establish timing. But it's expensive and pointless to create and delete the files for each repetition.

Describe the solution you'd like
I expected setup to run once at the beginning and teardown to run once at the end. If that's not feasible then it would be good to have a real "global" setup/teardown that doesn't get run for each repetition.

@dmah42
Copy link
Member

dmah42 commented Oct 31, 2024

you can override main and do the global setup teardown in there.

@dmah42 dmah42 closed this as completed Oct 31, 2024
@balshetzer
Copy link
Author

There are lots of globals. I was referring to the setup and teardown for a specific benchmark. Right now the setup and teardown runs each time the benchmark is run even if it is a repetition or if it is during gathering timings for the "real" run.

@dmah42 dmah42 reopened this Oct 31, 2024
@dmah42
Copy link
Member

dmah42 commented Oct 31, 2024

ah i see, i misunderstood "global".

so it sounds like there are three possible places to put setup/teardown:

  1. main (global setup teardown)
  2. per registered benchmark (not supported)
  3. per benchmark run (fixture)

and you're looking for #2. i'm not sure implementing #2 would be generally a good idea, only because it would potentially cause users to make mistakes where they think what they're doing in #2 is actually #3 and they introduce cross-run dependencies.

@balshetzer
Copy link
Author

What about a final teardown then? I could make my startup check if the files already exist and create them if they don't. But then not delete them until a final teardown.

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

2 participants