[C++-sig] Re: profiling code
Neal D. Becker
ndbecker2 at verizon.net
Thu Sep 16 18:53:48 CEST 2004
Vladimir Prus wrote:
> Hi Neal,
>
>> I realize this isn't exactly specific to boost-python. I want to profile
>> my
>> boost-python code. I'm using Linux.
>>
>> AFAICT, I would need to use a version of python build with -pg.
>> Hopefully
>> this would allow profiling dynamically loaded modules? (I haven't tried
>> it recently).
>>
>> Is there any way to profile my modules without building a special python?
>
> Sure, you can you the valgrind "skin" called "calltree". It produces a
> profile file which can be then visualied using the "kcachegrind" tool.
> Advantages: no need to recompile anything. You also get better precision
> because the binary is not alterted by the profiling code.
> Disadvantages: since valgrind essentially emulates processor, the program
> will run 10 times slower.
>
2 points:
1) Thanks! callgrind + kcachegrind are fantastic tools.
2) I was able to speed up my code by 4X. Turns out, problem was my use of
index operator [] on iterators instead of ++, etc.
David Abrahams told me this more than once. Moral:
Listen to Master Abrahams!
More information about the Cplusplus-sig
mailing list