Open
Conversation
Adds a new `benchmark::ScopedPauseTiming` class that provides a convenient RAII-style mechanism for pausing and resuming benchmark timers. This is less error-prone than manually calling `PauseTiming` and `ResumeTiming`, as it guarantees that the timer is resumed when the scope is exited. - Added `ScopedPauseTiming` to `include/benchmark/state.h`. - Added a new test `test/scoped_pause_test.cc` to verify the functionality and prevent regressions. - Updated `test/CMakeLists.txt` to include the new test. - Added documentation for the new feature in `docs/user_guide.md`.
5ba27e4 to
d5065cf
Compare
LebedevRI
reviewed
Apr 1, 2026
include/benchmark/state.h
Outdated
| } | ||
| ~ScopedPauseTiming() { state_.ResumeTiming(); } | ||
|
|
||
| private: |
Collaborator
There was a problem hiding this comment.
I think, =deleted members should be public, but it probably doesn't really matter.
You might also want to deal with move ctor/assign?
ScopedPauseTiming(ScopedPauseTiming&&) = delete;
void operator=(ScopedPauseTiming&&) = delete;
Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 7.6.0 to 8.0.0. - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](astral-sh/setup-uv@37802ad...cec2083) --- updated-dependencies: - dependency-name: astral-sh/setup-uv dependency-version: 8.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [lukka/get-cmake](https://github.com/lukka/get-cmake) from 4.3.0 to 4.3.1. - [Release notes](https://github.com/lukka/get-cmake/releases) - [Changelog](https://github.com/lukka/get-cmake/blob/main/RELEASE_PROCESS.md) - [Commits](lukka/get-cmake@b783061...ea83089) --- updated-dependencies: - dependency-name: lukka/get-cmake dependency-version: 4.3.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
Bumps [numpy](https://github.com/numpy/numpy) from 2.4.3 to 2.4.4. - [Release notes](https://github.com/numpy/numpy/releases) - [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst) - [Commits](numpy/numpy@v2.4.3...v2.4.4) --- updated-dependencies: - dependency-name: numpy dependency-version: 2.4.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
LebedevRI
reviewed
Apr 1, 2026
|
|
||
| // BM_ScopedPause sleeps for 10ms in a ScopedPauseTiming block. | ||
| // The reported time should be much less than 10ms. | ||
| void BM_ScopedPause(benchmark::State& state) { |
Collaborator
There was a problem hiding this comment.
I'd strongly suggest to use ManualTime for this, not rely on the system timers doing the right thing.
LebedevRI
approved these changes
Apr 1, 2026
Collaborator
LebedevRI
left a comment
There was a problem hiding this comment.
Seems fine to me, thank you!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new
benchmark::ScopedPauseTimingclass that provides a convenient RAII-style mechanism for pausing and resuming benchmark timers.This is less error-prone than manually calling
PauseTimingandResumeTiming, as it guarantees that the timer is resumed when the scope is exited.ScopedPauseTimingtoinclude/benchmark/state.h.test/scoped_pause_test.ccto verify the functionality and prevent regressions.test/CMakeLists.txtto include the new test.docs/user_guide.md.