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: Flat Profile</title>
17
18<meta name="description" content="GNU gprof: Flat Profile">
19<meta name="keywords" content="GNU gprof: Flat Profile">
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="Call-Graph.html#Call-Graph" rel="next" title="Call Graph">
28<link href="Output.html#Output" rel="previous" title="Output">
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="Flat-Profile"></a>
63<div class="header">
64<p>
65Next: <a href="Call-Graph.html#Call-Graph" accesskey="n" rel="next">Call Graph</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-Flat-Profile"></a>
69<h3 class="section">5.1 The Flat Profile</h3>
70<a name="index-flat-profile"></a>
71
72<p>The <em>flat profile</em> shows the total amount of time your program
73spent executing each function.  Unless the &lsquo;<samp>-z</samp>&rsquo; option is given,
74functions with no apparent time spent in them, and no apparent calls
75to them, are not mentioned.  Note that if a function was not compiled
76for profiling, and didn&rsquo;t run long enough to show up on the program
77counter histogram, it will be indistinguishable from a function that
78was never called.
79</p>
80<p>This is part of a flat profile for a small program:
81</p>
82<div class="smallexample">
83<pre class="smallexample">Flat profile:
84
85Each sample counts as 0.01 seconds.
86  %   cumulative   self              self     total
87 time   seconds   seconds    calls  ms/call  ms/call  name
88 33.34      0.02     0.02     7208     0.00     0.00  open
89 16.67      0.03     0.01      244     0.04     0.12  offtime
90 16.67      0.04     0.01        8     1.25     1.25  memccpy
91 16.67      0.05     0.01        7     1.43     1.43  write
92 16.67      0.06     0.01                             mcount
93  0.00      0.06     0.00      236     0.00     0.00  tzset
94  0.00      0.06     0.00      192     0.00     0.00  tolower
95  0.00      0.06     0.00       47     0.00     0.00  strlen
96  0.00      0.06     0.00       45     0.00     0.00  strchr
97  0.00      0.06     0.00        1     0.00    50.00  main
98  0.00      0.06     0.00        1     0.00     0.00  memcpy
99  0.00      0.06     0.00        1     0.00    10.11  print
100  0.00      0.06     0.00        1     0.00     0.00  profil
101  0.00      0.06     0.00        1     0.00    50.00  report
102&hellip;
103</pre></div>
104
105<p>The functions are sorted first by decreasing run-time spent in them,
106then by decreasing number of calls, then alphabetically by name.  The
107functions &lsquo;<samp>mcount</samp>&rsquo; and &lsquo;<samp>profil</samp>&rsquo; are part of the profiling
108apparatus and appear in every flat profile; their time gives a measure of
109the amount of overhead due to profiling.
110</p>
111<p>Just before the column headers, a statement appears indicating
112how much time each sample counted as.
113This <em>sampling period</em> estimates the margin of error in each of the time
114figures.  A time figure that is not much larger than this is not
115reliable.  In this example, each sample counted as 0.01 seconds,
116suggesting a 100 Hz sampling rate.
117The program&rsquo;s total execution time was 0.06
118seconds, as indicated by the &lsquo;<samp>cumulative seconds</samp>&rsquo; field.  Since
119each sample counted for 0.01 seconds, this means only six samples
120were taken during the run.  Two of the samples occurred while the
121program was in the &lsquo;<samp>open</samp>&rsquo; function, as indicated by the
122&lsquo;<samp>self seconds</samp>&rsquo; field.  Each of the other four samples
123occurred one each in &lsquo;<samp>offtime</samp>&rsquo;, &lsquo;<samp>memccpy</samp>&rsquo;, &lsquo;<samp>write</samp>&rsquo;,
124and &lsquo;<samp>mcount</samp>&rsquo;.
125Since only six samples were taken, none of these values can
126be regarded as particularly reliable.
127In another run,
128the &lsquo;<samp>self seconds</samp>&rsquo; field for
129&lsquo;<samp>mcount</samp>&rsquo; might well be &lsquo;<samp>0.00</samp>&rsquo; or &lsquo;<samp>0.02</samp>&rsquo;.
130See <a href="Sampling-Error.html#Sampling-Error">Statistical Sampling Error</a>,
131for a complete discussion.
132</p>
133<p>The remaining functions in the listing (those whose
134&lsquo;<samp>self seconds</samp>&rsquo; field is &lsquo;<samp>0.00</samp>&rsquo;) didn&rsquo;t appear
135in the histogram samples at all.  However, the call graph
136indicated that they were called, so therefore they are listed,
137sorted in decreasing order by the &lsquo;<samp>calls</samp>&rsquo; field.
138Clearly some time was spent executing these functions,
139but the paucity of histogram samples prevents any
140determination of how much time each took.
141</p>
142<p>Here is what the fields in each line mean:
143</p>
144<dl compact="compact">
145<dt><code>% time</code></dt>
146<dd><p>This is the percentage of the total execution time your program spent
147in this function.  These should all add up to 100%.
148</p>
149</dd>
150<dt><code>cumulative seconds</code></dt>
151<dd><p>This is the cumulative total number of seconds the computer spent
152executing this functions, plus the time spent in all the functions
153above this one in this table.
154</p>
155</dd>
156<dt><code>self seconds</code></dt>
157<dd><p>This is the number of seconds accounted for by this function alone.
158The flat profile listing is sorted first by this number.
159</p>
160</dd>
161<dt><code>calls</code></dt>
162<dd><p>This is the total number of times the function was called.  If the
163function was never called, or the number of times it was called cannot
164be determined (probably because the function was not compiled with
165profiling enabled), the <em>calls</em> field is blank.
166</p>
167</dd>
168<dt><code>self ms/call</code></dt>
169<dd><p>This represents the average number of milliseconds spent in this
170function per call, if this function is profiled.  Otherwise, this field
171is blank for this function.
172</p>
173</dd>
174<dt><code>total ms/call</code></dt>
175<dd><p>This represents the average number of milliseconds spent in this
176function and its descendants per call, if this function is profiled.
177Otherwise, this field is blank for this function.
178This is the only field in the flat profile that uses call graph analysis.
179</p>
180</dd>
181<dt><code>name</code></dt>
182<dd><p>This is the name of the function.   The flat profile is sorted by this
183field alphabetically after the <em>self seconds</em> and <em>calls</em>
184fields are sorted.
185</p></dd>
186</dl>
187
188<hr>
189<div class="header">
190<p>
191Next: <a href="Call-Graph.html#Call-Graph" accesskey="n" rel="next">Call Graph</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>
192</div>
193
194
195
196</body>
197</html>
198