Home

Callgrind

Callgrind is a profiling tool from the Valgrind instrumentation framework designed to profile program execution by producing a call graph and per-function cost information. It records how many times each function is called and how many machine instructions are executed within each function, providing both a self cost and a cumulated cost across callers. The data are generated during a Valgrind run and stored in a file named callgrind.out.pid, which can be analyzed with visualization tools.

Callgrind works by instrumenting the program at runtime through Valgrind’s IR, intercepting function entries and exits

Usage typically involves running the program under Valgrind with the tool specified, for example valgrind --tool=callgrind

Limitations include substantial runtime overhead and the need for debug information for precise source-level reporting. Callgrind

and
counting
executed
instructions.
When
debugging
information
is
available,
the
results
can
be
annotated
to
source
lines
for
easier
interpretation.
Callgrind
does
not
measure
hardware
caches
directly;
for
cache
analysis,
the
separate
Cachegrind
tool
in
the
Valgrind
suite
is
used,
and
the
two
tools
can
provide
complementary
data.
./program
[args].
After
the
run,
the
generated
callgrind.out.*
file
can
be
analyzed
with
callgrind_annotate
for
a
text
report,
or
loaded
into
KCachegrind
or
QCachegrind
for
an
interactive
graphical
call
graph
with
cost
annotations.
The
tool
also
supports
on-the-fly
toggling
of
data
collection
and
can
be
combined
with
other
Valgrind
tools
in
a
single
execution.
is
best
suited
for
deterministic
workloads
and
targeted
optimization
of
hot
paths.