Skip to content

[FR] global setup and teardown #1873

Open

Description

@balshetzer

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.

Activity

  1. dmah42 commented on Oct 31, 2024

    @dmah42
    Member

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

  2. balshetzer commented on Oct 31, 2024

    @balshetzer
    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.

  3. reopened this on Oct 31, 2024
  4. dmah42 commented on Oct 31, 2024

    @dmah42
    Member

    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.

  5. balshetzer commented on Nov 1, 2024

    @balshetzer
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions