1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- This file documents the gprof profiler of the GNU system.
4
5Copyright (C) 1988-2021 Free Software Foundation, Inc.
6
7Permission is granted to copy, distribute and/or modify this document
8under the terms of the GNU Free Documentation License, Version 1.3
9or any later version published by the Free Software Foundation;
10with no Invariant Sections, with no Front-Cover Texts, and with no
11Back-Cover Texts.  A copy of the license is included in the
12section entitled "GNU Free Documentation License".
13 -->
14<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
15<head>
16<title>GNU gprof: Call Graph</title>
17
18<meta name="description" content="GNU gprof: Call Graph">
19<meta name="keywords" content="GNU gprof: Call Graph">
20<meta name="resource-type" content="document">
21<meta name="distribution" content="global">
22<meta name="Generator" content="makeinfo">
23<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
24<link href="index.html#Top" rel="start" title="Top">
25<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
26<link href="Output.html#Output" rel="up" title="Output">
27<link href="Primary.html#Primary" rel="next" title="Primary">
28<link href="Flat-Profile.html#Flat-Profile" rel="previous" title="Flat Profile">
29<style type="text/css">
30<!--
31a.summary-letter {text-decoration: none}
32blockquote.smallquotation {font-size: smaller}
33div.display {margin-left: 3.2em}
34div.example {margin-left: 3.2em}
35div.indentedblock {margin-left: 3.2em}
36div.lisp {margin-left: 3.2em}
37div.smalldisplay {margin-left: 3.2em}
38div.smallexample {margin-left: 3.2em}
39div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
40div.smalllisp {margin-left: 3.2em}
41kbd {font-style:oblique}
42pre.display {font-family: inherit}
43pre.format {font-family: inherit}
44pre.menu-comment {font-family: serif}
45pre.menu-preformatted {font-family: serif}
46pre.smalldisplay {font-family: inherit; font-size: smaller}
47pre.smallexample {font-size: smaller}
48pre.smallformat {font-family: inherit; font-size: smaller}
49pre.smalllisp {font-size: smaller}
50span.nocodebreak {white-space:nowrap}
51span.nolinebreak {white-space:nowrap}
52span.roman {font-family:serif; font-weight:normal}
53span.sansserif {font-family:sans-serif; font-weight:normal}
54ul.no-bullet {list-style: none}
55-->
56</style>
57
58
59</head>
60
61<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
62<a name="Call-Graph"></a>
63<div class="header">
64<p>
65Next: <a href="Line_002dby_002dline.html#Line_002dby_002dline" accesskey="n" rel="next">Line-by-line</a>, Previous: <a href="Flat-Profile.html#Flat-Profile" accesskey="p" rel="previous">Flat Profile</a>, Up: <a href="Output.html#Output" accesskey="u" rel="up">Output</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
66</div>
67<hr>
68<a name="The-Call-Graph"></a>
69<h3 class="section">5.2 The Call Graph</h3>
70<a name="index-call-graph"></a>
71
72<p>The <em>call graph</em> shows how much time was spent in each function
73and its children.  From this information, you can find functions that,
74while they themselves may not have used much time, called other
75functions that did use unusual amounts of time.
76</p>
77<p>Here is a sample call from a small program.  This call came from the
78same <code>gprof</code> run as the flat profile example in the previous
79section.
80</p>
81<div class="smallexample">
82<pre class="smallexample">granularity: each sample hit covers 2 byte(s) for 20.00% of 0.05 seconds
83
84index % time    self  children    called     name
85                                                 &lt;spontaneous&gt;
86[1]    100.0    0.00    0.05                 start [1]
87                0.00    0.05       1/1           main [2]
88                0.00    0.00       1/2           on_exit [28]
89                0.00    0.00       1/1           exit [59]
90-----------------------------------------------
91                0.00    0.05       1/1           start [1]
92[2]    100.0    0.00    0.05       1         main [2]
93                0.00    0.05       1/1           report [3]
94-----------------------------------------------
95                0.00    0.05       1/1           main [2]
96[3]    100.0    0.00    0.05       1         report [3]
97                0.00    0.03       8/8           timelocal [6]
98                0.00    0.01       1/1           print [9]
99                0.00    0.01       9/9           fgets [12]
100                0.00    0.00      12/34          strncmp &lt;cycle 1&gt; [40]
101                0.00    0.00       8/8           lookup [20]
102                0.00    0.00       1/1           fopen [21]
103                0.00    0.00       8/8           chewtime [24]
104                0.00    0.00       8/16          skipspace [44]
105-----------------------------------------------
106[4]     59.8    0.01        0.02       8+472     &lt;cycle 2 as a whole&gt; [4]
107                0.01        0.02     244+260         offtime &lt;cycle 2&gt; [7]
108                0.00        0.00     236+1           tzset &lt;cycle 2&gt; [26]
109-----------------------------------------------
110</pre></div>
111
112<p>The lines full of dashes divide this table into <em>entries</em>, one for each
113function.  Each entry has one or more lines.
114</p>
115<p>In each entry, the primary line is the one that starts with an index number
116in square brackets.  The end of this line says which function the entry is
117for.  The preceding lines in the entry describe the callers of this
118function and the following lines describe its subroutines (also called
119<em>children</em> when we speak of the call graph).
120</p>
121<p>The entries are sorted by time spent in the function and its subroutines.
122</p>
123<p>The internal profiling function <code>mcount</code> (see <a href="Flat-Profile.html#Flat-Profile">The
124Flat Profile</a>) is never mentioned in the call graph.
125</p>
126<table class="menu" border="0" cellspacing="0">
127<tr><td align="left" valign="top">&bull; <a href="Primary.html#Primary" accesskey="1">Primary</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Details of the primary line&rsquo;s contents.
128</td></tr>
129<tr><td align="left" valign="top">&bull; <a href="Callers.html#Callers" accesskey="2">Callers</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Details of caller-lines&rsquo; contents.
130</td></tr>
131<tr><td align="left" valign="top">&bull; <a href="Subroutines.html#Subroutines" accesskey="3">Subroutines</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Details of subroutine-lines&rsquo; contents.
132</td></tr>
133<tr><td align="left" valign="top">&bull; <a href="Cycles.html#Cycles" accesskey="4">Cycles</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">When there are cycles of recursion,
134                   such as <code>a</code> calls <code>b</code> calls <code>a</code>&hellip;
135</td></tr>
136</table>
137
138<hr>
139<div class="header">
140<p>
141Next: <a href="Line_002dby_002dline.html#Line_002dby_002dline" accesskey="n" rel="next">Line-by-line</a>, Previous: <a href="Flat-Profile.html#Flat-Profile" accesskey="p" rel="previous">Flat Profile</a>, Up: <a href="Output.html#Output" accesskey="u" rel="up">Output</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
142</div>
143
144
145
146</body>
147</html>
148