Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interpreting callgrind data

I need a dynamic call graph for my app. I run it with callgrind tool (valgrind suite) and got callgrind.out.xxxxx file. Now, I want to make a graphical representation of this data. KCacheGrind doesn't help me much because it draws a limited part of the graph (draws ~50 functions instead of ~1500 profiled and I don't know how to fix that). How can I get a graph image where all of the functions will be drawn?

like image 782
maverik Avatar asked Feb 14 '12 15:02

maverik


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 to use callgrind?

To use Callgrind, you must specify --tool=callgrind on the Valgrind command line or use the supplied script callgrind . Callgrind's cache simulation is based on the Cachegrind tool of the Valgrind package.

How callgrind works?

Overview. Callgrind is a profiling tool that records the call history among functions in a program's run as a call-graph. By default, the collected data consists of the number of instructions executed, their relationship to source lines, the caller/callee relationship between functions, and the numbers of such calls.

What is IR in Callgrind?

Ir: The number of instructions executed in total by the selected function after being called by this caller.


2 Answers

Using the following command to generate graph.png using gprof2dot

$ ./gprof2dot.py --format=callgrind --output=out.dot /path/to/callgrind.out
$ dot -Tpng out.dot -o graph.png
like image 152
samaitra Avatar answered Oct 13 '22 06:10

samaitra


Ok, I've found the way. The generated callgrind.out file you can convert to dot file using gprof2dot (yes, this tool can parse callgrind files as well). And then you can get the graph image using dot -T<type> dotfile.dot -o graphfile.<type>

like image 33
maverik Avatar answered Oct 13 '22 07:10

maverik