151 lines
7.6 KiB
HTML
151 lines
7.6 KiB
HTML
<html lang="en">
|
|
<head>
|
|
<title>Flat Profile - GNU gprof</title>
|
|
<meta http-equiv="Content-Type" content="text/html">
|
|
<meta name="description" content="GNU gprof">
|
|
<meta name="generator" content="makeinfo 4.13">
|
|
<link title="Top" rel="start" href="index.html#Top">
|
|
<link rel="up" href="Output.html#Output" title="Output">
|
|
<link rel="next" href="Call-Graph.html#Call-Graph" title="Call Graph">
|
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
|
<!--
|
|
This file documents the gprof profiler of the GNU system.
|
|
|
|
Copyright (C) 1988-2019 Free Software Foundation, Inc.
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3
|
|
or any later version published by the Free Software Foundation;
|
|
with no Invariant Sections, with no Front-Cover Texts, and with no
|
|
Back-Cover Texts. A copy of the license is included in the
|
|
section entitled ``GNU Free Documentation License''.
|
|
|
|
-->
|
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
|
<style type="text/css"><!--
|
|
pre.display { font-family:inherit }
|
|
pre.format { font-family:inherit }
|
|
pre.smalldisplay { font-family:inherit; font-size:smaller }
|
|
pre.smallformat { font-family:inherit; font-size:smaller }
|
|
pre.smallexample { font-size:smaller }
|
|
pre.smalllisp { font-size:smaller }
|
|
span.sc { font-variant:small-caps }
|
|
span.roman { font-family:serif; font-weight:normal; }
|
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
|
--></style>
|
|
</head>
|
|
<body>
|
|
<div class="node">
|
|
<a name="Flat-Profile"></a>
|
|
<p>
|
|
Next: <a rel="next" accesskey="n" href="Call-Graph.html#Call-Graph">Call Graph</a>,
|
|
Up: <a rel="up" accesskey="u" href="Output.html#Output">Output</a>
|
|
<hr>
|
|
</div>
|
|
|
|
<h3 class="section">5.1 The Flat Profile</h3>
|
|
|
|
<p><a name="index-flat-profile-1"></a>
|
|
The <dfn>flat profile</dfn> shows the total amount of time your program
|
|
spent executing each function. Unless the ‘<samp><span class="samp">-z</span></samp>’ option is given,
|
|
functions with no apparent time spent in them, and no apparent calls
|
|
to them, are not mentioned. Note that if a function was not compiled
|
|
for profiling, and didn't run long enough to show up on the program
|
|
counter histogram, it will be indistinguishable from a function that
|
|
was never called.
|
|
|
|
<p>This is part of a flat profile for a small program:
|
|
|
|
<pre class="smallexample"> Flat profile:
|
|
|
|
Each sample counts as 0.01 seconds.
|
|
% cumulative self self total
|
|
time seconds seconds calls ms/call ms/call name
|
|
33.34 0.02 0.02 7208 0.00 0.00 open
|
|
16.67 0.03 0.01 244 0.04 0.12 offtime
|
|
16.67 0.04 0.01 8 1.25 1.25 memccpy
|
|
16.67 0.05 0.01 7 1.43 1.43 write
|
|
16.67 0.06 0.01 mcount
|
|
0.00 0.06 0.00 236 0.00 0.00 tzset
|
|
0.00 0.06 0.00 192 0.00 0.00 tolower
|
|
0.00 0.06 0.00 47 0.00 0.00 strlen
|
|
0.00 0.06 0.00 45 0.00 0.00 strchr
|
|
0.00 0.06 0.00 1 0.00 50.00 main
|
|
0.00 0.06 0.00 1 0.00 0.00 memcpy
|
|
0.00 0.06 0.00 1 0.00 10.11 print
|
|
0.00 0.06 0.00 1 0.00 0.00 profil
|
|
0.00 0.06 0.00 1 0.00 50.00 report
|
|
...
|
|
</pre>
|
|
<p class="noindent">The functions are sorted first by decreasing run-time spent in them,
|
|
then by decreasing number of calls, then alphabetically by name. The
|
|
functions ‘<samp><span class="samp">mcount</span></samp>’ and ‘<samp><span class="samp">profil</span></samp>’ are part of the profiling
|
|
apparatus and appear in every flat profile; their time gives a measure of
|
|
the amount of overhead due to profiling.
|
|
|
|
<p>Just before the column headers, a statement appears indicating
|
|
how much time each sample counted as.
|
|
This <dfn>sampling period</dfn> estimates the margin of error in each of the time
|
|
figures. A time figure that is not much larger than this is not
|
|
reliable. In this example, each sample counted as 0.01 seconds,
|
|
suggesting a 100 Hz sampling rate.
|
|
The program's total execution time was 0.06
|
|
seconds, as indicated by the ‘<samp><span class="samp">cumulative seconds</span></samp>’ field. Since
|
|
each sample counted for 0.01 seconds, this means only six samples
|
|
were taken during the run. Two of the samples occurred while the
|
|
program was in the ‘<samp><span class="samp">open</span></samp>’ function, as indicated by the
|
|
‘<samp><span class="samp">self seconds</span></samp>’ field. Each of the other four samples
|
|
occurred one each in ‘<samp><span class="samp">offtime</span></samp>’, ‘<samp><span class="samp">memccpy</span></samp>’, ‘<samp><span class="samp">write</span></samp>’,
|
|
and ‘<samp><span class="samp">mcount</span></samp>’.
|
|
Since only six samples were taken, none of these values can
|
|
be regarded as particularly reliable.
|
|
In another run,
|
|
the ‘<samp><span class="samp">self seconds</span></samp>’ field for
|
|
‘<samp><span class="samp">mcount</span></samp>’ might well be ‘<samp><span class="samp">0.00</span></samp>’ or ‘<samp><span class="samp">0.02</span></samp>’.
|
|
See <a href="Sampling-Error.html#Sampling-Error">Statistical Sampling Error</a>,
|
|
for a complete discussion.
|
|
|
|
<p>The remaining functions in the listing (those whose
|
|
‘<samp><span class="samp">self seconds</span></samp>’ field is ‘<samp><span class="samp">0.00</span></samp>’) didn't appear
|
|
in the histogram samples at all. However, the call graph
|
|
indicated that they were called, so therefore they are listed,
|
|
sorted in decreasing order by the ‘<samp><span class="samp">calls</span></samp>’ field.
|
|
Clearly some time was spent executing these functions,
|
|
but the paucity of histogram samples prevents any
|
|
determination of how much time each took.
|
|
|
|
<p>Here is what the fields in each line mean:
|
|
|
|
<dl>
|
|
<dt><code>% time</code><dd>This is the percentage of the total execution time your program spent
|
|
in this function. These should all add up to 100%.
|
|
|
|
<br><dt><code>cumulative seconds</code><dd>This is the cumulative total number of seconds the computer spent
|
|
executing this functions, plus the time spent in all the functions
|
|
above this one in this table.
|
|
|
|
<br><dt><code>self seconds</code><dd>This is the number of seconds accounted for by this function alone.
|
|
The flat profile listing is sorted first by this number.
|
|
|
|
<br><dt><code>calls</code><dd>This is the total number of times the function was called. If the
|
|
function was never called, or the number of times it was called cannot
|
|
be determined (probably because the function was not compiled with
|
|
profiling enabled), the <dfn>calls</dfn> field is blank.
|
|
|
|
<br><dt><code>self ms/call</code><dd>This represents the average number of milliseconds spent in this
|
|
function per call, if this function is profiled. Otherwise, this field
|
|
is blank for this function.
|
|
|
|
<br><dt><code>total ms/call</code><dd>This represents the average number of milliseconds spent in this
|
|
function and its descendants per call, if this function is profiled.
|
|
Otherwise, this field is blank for this function.
|
|
This is the only field in the flat profile that uses call graph analysis.
|
|
|
|
<br><dt><code>name</code><dd>This is the name of the function. The flat profile is sorted by this
|
|
field alphabetically after the <dfn>self seconds</dfn> and <dfn>calls</dfn>
|
|
fields are sorted.
|
|
</dl>
|
|
|
|
</body></html>
|
|
|