Callgrind Format Specification
One can see that in
main
only code from line 16 is executed where also the other functions are called. Inclusive cost
of
main
is 820, which is the sum of self cost 20 and costs spent in the calls: 400 for the single call to
func1
and 400
as sum for the three calls to
func2
.
Function
func1
is located in
file1.c
, the same as
main
. Therefore, a "cfl=" specification for the call to
func1
is not needed. The function
func1
only consists of code at line 51 of
file1.c
, where
func2
is called.
3.1.5. Name Compression
With the introduction of association specifications like calls it is needed to specify the same function or same file name
multiple times. As absolute filenames or symbol names in C++ can be quite long, it is advantageous to be able to
specify integer IDs for position specifications. Here, the term "position" corresponds to a file name (source or object
file) or function name.
To support name compression, a position specification can be not only of the format "spec=name", but also "spec=(ID)
name" to specify a mapping of an integer ID to a name, and "spec=(ID)" to reference a previously defined ID mapping.
There is a separate ID mapping for each position specification, i.e. you can use ID 1 for both a file name and a symbol
name.
With string compression, the example from 1.4 looks like this:
events: Instructions
fl=(1) file1.c
fn=(1) main
16 20
cfn=(2) func1
calls=1 50
16 400
cfl=(2) file2.c
cfn=(3) func2
calls=3 20
16 400
fn=(2)
51 100
cfl=(2)
cfn=(3)
calls=2 20
51 300
fl=(2)
fn=(3)
20 700
As position specifications carry no information themselves, but only change the meaning of subsequent cost lines or
associations, they can appear everywhere in the file without any negative consequence. Especially, you can define
name compression mappings directly after the header, and before any cost lines. Thus, the above example can also be
written as
11