How to profile an inner inner loop

Started by
11 comments, last by swiftcoder 15 years, 2 months ago
Quote:Original post by shavi
Quote:Original post by stonemetal
Quote:I've tried running it through tools like oprofile and callgrind, but the most I can reliably get out of them is that indeed, the function that runs this loop takes a long time.
Have you tried pulling chunks of the function you are worried about out in to separate functions so that callgrind can inspect the pieces?
I suspect that doing that would significantly change the performance characteristics of the code.
Quite possibly much less so than you might think. Aggressive inlining should put most of the chunks back in, unless there is benefit to leaving them out. It also tends to be a fairly minor code modification, and will allow you to figure out exactly which chunk is chewing up most of the cycles.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Advertisement
Quote:Original post by swiftcoder
Quote:Original post by shavi
Quote:Original post by stonemetal
Quote:I've tried running it through tools like oprofile and callgrind, but the most I can reliably get out of them is that indeed, the function that runs this loop takes a long time.
Have you tried pulling chunks of the function you are worried about out in to separate functions so that callgrind can inspect the pieces?
I suspect that doing that would significantly change the performance characteristics of the code.
Quite possibly much less so than you might think. Aggressive inlining should put most of the chunks back in, unless there is benefit to leaving them out. It also tends to be a fairly minor code modification, and will allow you to figure out exactly which chunk is chewing up most of the cycles.

Hm, interesting. Ok, I'll give that a try then.
Another option, if you have a Mac available, is to run your program through Shark. I find it the best performance tool available, especially seeing as it is free [smile]

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement