Repository navigation
Add State::in_timed_section() helper - #2319
Merged
Merged
Conversation
Member
|
why would users need this? i understand that you caught a bug with it, but if that bug is resolved (and that suggests we're missing a test) then is this more generally useful? |
Contributor
Author
|
In the end, this is only relevant for the Python bindings, where I'm using that assert condition to detect wrong usage by Python developers directly in the bindings. I'm compiling in release mode, so I wouldn't hit that in the library code. But I agree, the value for users is limited. I figured it fits in with the rest of the State lifecycle methods. |
dmah42
previously approved these changes
Oct 5, 2026
LebedevRI
reviewed
Oct 5, 2026
In some scenarios, it can be useful to know if we are currently in a benchmark loop. The "are we currently in a timed section" check was already used internally, but only in asserts around timings. This change just packages that check into a public API on `State`, which makes user queries on the benchmark status a bit nicer.
nicholasjng
force-pushed
the
push-sqnnlxmpmstu
branch
from
October 7, 2026 05:51
5451de3 to
dfd07b2
Compare
State::in_timing_loop() helperState::in_timed_section() helper
LebedevRI
approved these changes
Oct 8, 2026
Collaborator
|
@nicholasjng 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.
In some scenarios, it can be useful to know if we are currently in a benchmark loop. The "are we currently in a loop" check was already used internally, but only in asserts around timings.
This change just packages that check into a public API on
State, which makes user queries on the benchmark status a bit nicer.Same case, implementing Pythonic bindings around
State::{Pause,Resume}Timing(). In particular, this allows me to catch a pause outside of a benchmark loop withif(!state->in_timing_loop())and emit astd::runtime_error, which is translated to a PythonRuntimeErrorby nanobind.