Repository navigation
Conversation
Custom profilers that open a named region need the benchmark name, but the ProfilerManager hooks receive no context at all. Adding an overload of AfterSetupStart()/BeforeTeardownStop() that takes a State is not source compatible: the new overload hides the old one in every existing subclass. Instead, add a protected ProfilerManager::GetState() accessor that returns the State of the run being profiled. Existing subclasses keep compiling untouched. The accessor returns a pointer, not a reference, because there is no meaningful answer outside the hooks. State sets the pointer immediately before invoking a hook and clears it as soon as the hook returns, so a caller outside AfterSetupStart()/BeforeTeardownStop() observes nullptr rather than a stale State. The test asserts both: the benchmark name is readable inside the hook, and the accessor is null outside it.
|
Closed without a comment, so I can't tell what to change. Was it the approach — a protected If it is the approach, the alternative that avoids both problems raised on the earlier attempts is a differently named hook rather than an overload: If the feature isn't wanted, that's a fine answer too — #2234 can be closed and I'll stop pushing on it. |
|
there's no motivation for the feature, as far as i can tell. noone is asking for it, the issue doesn't explain why someone would want to do it. |
Custom profilers that open a named region need the benchmark name, but the ProfilerManager hooks receive no context at all.
Adding an overload of AfterSetupStart()/BeforeTeardownStop() that takes a State is not source compatible: the new overload hides the old one in every existing subclass. Instead, add a protected ProfilerManager::GetState() accessor that returns the State of the run being profiled. Existing subclasses keep compiling untouched.
The accessor returns a pointer, not a reference, because there is no meaningful answer outside the hooks. State sets the pointer immediately before invoking a hook and clears it as soon as the hook returns, so a caller outside AfterSetupStart()/BeforeTeardownStop() observes nullptr rather than a stale State. The test asserts both: the benchmark name is readable inside the hook, and the accessor is null outside it.
Per AGENTS.md: AI-assisted — the patch was drafted with AI assistance
(Claude) and then reviewed, tested, and understood by me. I take full
responsibility for it.