blob: 0525585d5dc01c508c434e581f4e65f8cb3cb918 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This file documents the gprof profiler of the GNU system.
Copyright (C) 1988, 1992, 1997, 1998, 1999, 2000, 2001, 2003,
2007, 2008, 2009 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".
-->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU gprof: Flat Profile</title>
<meta name="description" content="GNU gprof: Flat Profile">
<meta name="keywords" content="GNU gprof: Flat Profile">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Output.html#Output" rel="up" title="Output">
<link href="Call-Graph.html#Call-Graph" rel="next" title="Call Graph">
<link href="Output.html#Output" rel="prev" title="Output">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Flat-Profile"></a>
<div class="header">
<p>
Next: <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>
</div>
<hr>
<a name="The-Flat-Profile"></a>
<h3 class="section">5.1 The Flat Profile</h3>
<a name="index-flat-profile"></a>
<p>The <em>flat profile</em> shows the total amount of time your program
spent executing each function. Unless the &lsquo;<samp>-z</samp>&rsquo; 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&rsquo;t run long enough to show up on the program
counter histogram, it will be indistinguishable from a function that
was never called.
</p>
<p>This is part of a flat profile for a small program:
</p>
<div class="smallexample">
<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
&hellip;
</pre></div>
<p>The functions are sorted first by decreasing run-time spent in them,
then by decreasing number of calls, then alphabetically by name. The
functions &lsquo;<samp>mcount</samp>&rsquo; and &lsquo;<samp>profil</samp>&rsquo; 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>
<p>Just before the column headers, a statement appears indicating
how much time each sample counted as.
This <em>sampling period</em> 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&rsquo;s total execution time was 0.06
seconds, as indicated by the &lsquo;<samp>cumulative seconds</samp>&rsquo; 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 &lsquo;<samp>open</samp>&rsquo; function, as indicated by the
&lsquo;<samp>self seconds</samp>&rsquo; field. Each of the other four samples
occurred one each in &lsquo;<samp>offtime</samp>&rsquo;, &lsquo;<samp>memccpy</samp>&rsquo;, &lsquo;<samp>write</samp>&rsquo;,
and &lsquo;<samp>mcount</samp>&rsquo;.
Since only six samples were taken, none of these values can
be regarded as particularly reliable.
In another run,
the &lsquo;<samp>self seconds</samp>&rsquo; field for
&lsquo;<samp>mcount</samp>&rsquo; might well be &lsquo;<samp>0.00</samp>&rsquo; or &lsquo;<samp>0.02</samp>&rsquo;.
See <a href="Sampling-Error.html#Sampling-Error">Statistical Sampling Error</a>,
for a complete discussion.
</p>
<p>The remaining functions in the listing (those whose
&lsquo;<samp>self seconds</samp>&rsquo; field is &lsquo;<samp>0.00</samp>&rsquo;) didn&rsquo;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 &lsquo;<samp>calls</samp>&rsquo; 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>
<p>Here is what the fields in each line mean:
</p>
<dl compact="compact">
<dt><code>% time</code></dt>
<dd><p>This is the percentage of the total execution time your program spent
in this function. These should all add up to 100%.
</p>
</dd>
<dt><code>cumulative seconds</code></dt>
<dd><p>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.
</p>
</dd>
<dt><code>self seconds</code></dt>
<dd><p>This is the number of seconds accounted for by this function alone.
The flat profile listing is sorted first by this number.
</p>
</dd>
<dt><code>calls</code></dt>
<dd><p>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 <em>calls</em> field is blank.
</p>
</dd>
<dt><code>self ms/call</code></dt>
<dd><p>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.
</p>
</dd>
<dt><code>total ms/call</code></dt>
<dd><p>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.
</p>
</dd>
<dt><code>name</code></dt>
<dd><p>This is the name of the function. The flat profile is sorted by this
field alphabetically after the <em>self seconds</em> and <em>calls</em>
fields are sorted.
</p></dd>
</dl>
<hr>
<div class="header">
<p>
Next: <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>
</div>
</body>
</html>