[C++-sig] profiling C++ python extension

Mark Williams mark at image-engine.com
Fri Nov 21 21:21:06 CET 2008


stephan nies wrote:
> Hi Mark,
>
> just had a quick glance at the google-perftools documentation.
>
> Could you provide a little more Detail in how you use it
> with a python extension? Do you link against libprofiler.so
> or do you use LD_PRELOAD ?
>
> Do you do anything special other than that? Or do you
> just start your python application?
>   
What I ended up doing was writing a small module (linked against 
libprofiler.so) containing bindings for the ProfilerStart/ProfilerStop 
functions. Then I could just import that module in Python and call 
start/stop around the sections I wanted to profile. After that I just 
ran "pprof" over the resulting file to create a PDF showing the call 
graph and timings.

Cheers,
Mark


More information about the Cplusplus-sig mailing list