Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to understand the output of callgrind using Kcachegrind

When profiling the log Kcachegrind shows %of inclusive as 13.92%. Should it not be close to 100% as mentioned in the FAQ Q:1??

Here is the screenshot of the profile log

enter image description here

like image 771
Ashwin Avatar asked Nov 16 '11 06:11

Ashwin


People also ask

What does Callgrind measure?

Callgrind records the count of instructions, not the actual time spent in a function. If you have a program where the bottleneck is file I/O, the costs associated with reading and writing files won't show up in the profile, as those are not CPU-intensive tasks.

How does callgrind work?

Overview. Callgrind is a Valgrind tool for profiling programs. The collected data consists of the number of instructions executed on a run, their relationship to source lines, and call relationship among functions together with call counts.

What is incl in KCacheGrind?

1.1 What is the difference between 'Incl. These are cost attributes for functions regarding some event type. As functions can call each other, it makes sense to distinguish the cost of the function itself ('Self Cost') and the cost including all called functions ('Inclusive Cost').


1 Answers

Not necessarily.

main is not the "real" entry point of your program, there is lot of stuff going on before and after, for example loading/unloading DLLs and the construction/destruction of globals (those which are dynamically initialized).

Those things take time, although normally negligible.

Note that there are flags for callgrind that allow to start the collection of statistics at the start of a function (for example main) depending on what you are really interested in.

like image 92
Matthieu M. Avatar answered Oct 07 '22 22:10

Matthieu M.