profiling a C++ python extension

R

rasmus

I have used gprof to profile stand alone C++ programs. I am also
aware of pure python profilers. However, is there a way to get
profile information on my C++ functions when they are compiled in a
shared library (python extension module) and called from python. From
what I can tell, gmon.out will not be generated unless the entire
executable (python interpreter) was compiled with -pg. Is my only
solution to recompile the python interpreter with -pg so that my
extension module (also compiled with -pg) produces a gmon.out?

Any suggestions or tips would be helpful.

Matt
 
B

brickenstein

Hi!
It doesn't suffice to compile the python interpreter with -pg, as the
module is loaded via dlopen.
I solved the problem for my case compiling an executable with embedded
python and the module itself.
I would wish, that there would be an easier way.
Best regards,
Michael
 
M

Matthew Woodcraft

rasmus said:
I have used gprof to profile stand alone C++ programs. I am also
aware of pure python profilers. However, is there a way to get
profile information on my C++ functions when they are compiled in a
shared library (python extension module) and called from python.
Any suggestions or tips would be helpful.

You didn't say what platform you're using. If you're using linux and
have root access, oprofile should be able to do what you need.

-M-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top