Is there a way to profile underlying C++ code?

B

Bo Peng

Dear list,

I have a C++-SWIG-wrapped python module. The running time for one of the
functions is pretty unpredictable so I would like to profile it.
However, the python profiler does not seem to enter the compiled module
(.so file). Is there a way to profile the C++ functions?

Many thanks in advance.
Bo
 
T

Travis E. Oliphant

Bo said:
Dear list,

I have a C++-SWIG-wrapped python module. The running time for one of the
functions is pretty unpredictable so I would like to profile it.
However, the python profiler does not seem to enter the compiled module
(.so file). Is there a way to profile the C++ functions?

On Linux you can use oprofile (which is pretty nice and easy to use ---
no recompiling. Just start the profiler, run your code, and stop the
profiler).

http://oprofile.sourceforge.net/about/

-Travis
 
B

Bo Peng

Travis said:
On Linux you can use oprofile (which is pretty nice and easy to use ---
no recompiling. Just start the profiler, run your code, and stop the
profiler).

Thank you very much for the tip. This is a great tool.

The source of the problem has been found: cache misses. Briefly, I have
a long array and I need to choose numbers from it randomly. When the
array is short, the performance is good. When the array is big, picking
a number will cause a cache miss almost all the time. This results in
almost doubled execution time.

Problem found, but I am out of idea how to fix it since the nature of my
algorithm is working randomly on large arrays.

Cheers,
Bo
 
C

Christophe

Bo Peng a écrit :
Thank you very much for the tip. This is a great tool.

The source of the problem has been found: cache misses. Briefly, I have
a long array and I need to choose numbers from it randomly. When the
array is short, the performance is good. When the array is big, picking
a number will cause a cache miss almost all the time. This results in
almost doubled execution time.

Problem found, but I am out of idea how to fix it since the nature of my
algorithm is working randomly on large arrays.

Cheers,
Bo

There might be one possibility for you. If the order of the random
positions you get has no meaning for the final result, you could start
by generating all those numbers, sort the list and then do the lookups.
 

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

Forum statistics

Threads
474,282
Messages
2,571,404
Members
48,096
Latest member
Kenkian2628

Latest Threads

Top