google / google/benchmark

[FR] Add possibility to start iteration in timing-off state.

Open
#1,811 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
10.4k
Forks
1.8k
Avg merge
2d 4h
Merged PRs (30d)
8

Description

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 */
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.