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] Add possibility to start iteration in timing-off state. #1811

Open
benjamin-branchware opened this issue Jul 10, 2024 · 1 comment
Open

Comments

@benjamin-branchware
Copy link

benjamin-branchware commented Jul 10, 2024

A common pattern I am using in my benchmarking code is:

for (auto _ : state) {
    state.PauseTiming();
    /* Generate some data for this iteration, or cleanup from the previous */
    state.ResumeTiming();
    
    /* Do some work */
}

This seems a little unpleasant because timing is starting when entering the loop body and immediately being paused.
What I would like instead is something like:

for (auto _ : state.with_paused_timing()) {
    /* Generate some data for this iteration, or cleanup from the previous */
    state.ResumeTiming();
    
    /* Do some work */
}
@dmah42
Copy link
Member

dmah42 commented Jul 11, 2024

would this do exactly the same under the hood, just not as explicitly?

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