Call Graph - GNU gprof
Description: GNU gprof

Next: Line-by-line, Previous: Flat Profile, Up: Output

### 5.2 The Call Graph

The call graph shows how much time was spent in each function and its children. From this information, you can find functions that, while they themselves may not have used much time, called other functions that did use unusual amounts of time.

Here is a sample call from a small program. This call came from the same `gprof` run as the flat profile example in the previous section.

         granularity: each sample hit covers 2 byte(s) for 20.00% of 0.05 seconds

         index % time    self  children    called     name
                                                          <spontaneous>
         [1]    100.0    0.00    0.05                 start [1]
                         0.00    0.05       1/1           main [2]
                         0.00    0.00       1/2           on_exit [28]
                         0.00    0.00       1/1           exit [59]
         -----------------------------------------------
                         0.00    0.05       1/1           start [1]
         [2]    100.0    0.00    0.05       1         main [2]
                         0.00    0.05       1/1           report [3]
         -----------------------------------------------
                         0.00    0.05       1/1           main [2]
         [3]    100.0    0.00    0.05       1         report [3]
                         0.00    0.03       8/8           timelocal [6]
                         0.00    0.01       1/1           print [9]
                         0.00    0.01       9/9           fgets [12]
                         0.00    0.00      12/34          strncmp <cycle 1> [40]
                         0.00    0.00       8/8           lookup [20]
                         0.00    0.00       1/1           fopen [21]
                         0.00    0.00       8/8           chewtime [24]
                         0.00    0.00       8/16          skipspace [44]
         -----------------------------------------------
         [4]     59.8    0.01        0.02       8+472     <cycle 2 as a whole> [4]
                         0.01        0.02     244+260         offtime <cycle 2> [7]
                         0.00        0.00     236+1           tzset <cycle 2> [26]
         -----------------------------------------------

The lines full of dashes divide this table into entries, one for each function. Each entry has one or more lines.

In each entry, the primary line is the one that starts with an index number in square brackets. The end of this line says which function the entry is for. The preceding lines in the entry describe the callers of this function and the following lines describe its subroutines (also called children when we speak of the call graph).

The entries are sorted by time spent in the function and its subroutines.

The internal profiling function `mcount` (see The Flat Profile) is never mentioned in the call graph.