Skip to content

[FR] Pass State into the ProfilerManager #2234

Description

@Goddan-wq

Hello

Some custom profilers for regional profiling require registering a region with a string name. It's convenient to use the name of the benchmark itself as this name. Therefore, I suggest adding a mechanism to the ProfilerManager that would get the benchmark name

One way to implement this is to pass State as an argument to the AfterSetupStart and BeforeTeardownStop methods. Then, the ProfilerManager will have access to the benchmark name via the name() method

To maintain backward compatibility with the current interface, I propose adding a new function overload and leaving the old one (you can mark it as deprecated if you prefer)

virtual void AfterSetupStart() {};
virtual void AfterSetupStart(const State&) { AfterSetupStart() };

And in benchmark.cc we pass *this into this methods

Currently, this is the only context for using this feature. However, I think CustomProfiler's ability to look into State could be useful for other tasks as well. This would allow more context to be passed to profilers. But if you think that passing the State is too much, we could add a lightweight method to pass only the name of the bench

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions