From: Josef Weidendorfer <Josef.W<eidendorfer@gm...> - 2013-03-13 19:13:35
Am 13.03.2013 16:58, schrieb Farah Saab Gmail:
> How do I get the number of loops in a function shown in Kcachegrind?
> Is it enough to press the button "Cycle Detection"?
No, that is something totally different (it's about correct
calculation of inclusive costs, and that needs detection of recursive
function calls = cycles in the call graph).
What do you mean by "number of loops in a function" ?
How often the loop body was executed for a given loop construct on
the source level?
It's a little tricky because Valgrind does not see loops. It just sees
jumps in the machine code. KCachegrind can show how often a jump
was executed, but you have to understand that the compiler can do
optimizations such as loop unrolling, such that the loop trip count
does not relate to any jump counts.
This said, you should run your code with Callgrind options
"--dump-instr=yes --collect-jumps=yes". Then, machine code
annotation in KCachegrind does show jump arcs, and how often
(conditional) jumps were executed.