nisah
nisah

Reputation: 2530

How to use gperftools to conditionally profile C++ code?

I am trying to CPU-profile a callback driven system and I'm only interested in profiling when the callback causes me to react a certain way ? Can I use gperftools to accomplish this ?

ProfilerEnable()/ProfilerDisable() seems promising but the header says these are deprecated. I'm not even sure if these would work.

Upvotes: 2

Views: 1204

Answers (1)

Aliaksei Kandratsenka
Aliaksei Kandratsenka

Reputation: 652

Indeed ProfilerEnable/Disable is not working anymore.

There is already request for pausing/unpausing profiling https://github.com/gperftools/gperftools/issues/597. But note that doing this pausing/unpausing frequently is likely to have performance impact.

I think you should profile all of your app and then use --focus feature of pprof to filter out uninteresting parts.

Upvotes: 1

Related Questions