You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
197 lines
8.5 KiB
HTML
197 lines
8.5 KiB
HTML
<!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-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".
|
|
-->
|
|
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<title>Flat Profile (GNU gprof)</title>
|
|
|
|
<meta name="description" content="Flat Profile (GNU gprof)">
|
|
<meta name="keywords" content="Flat Profile (GNU gprof)">
|
|
<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.indentedblock {margin-right: 0em}
|
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
|
blockquote.smallquotation {font-size: smaller}
|
|
div.display {margin-left: 3.2em}
|
|
div.example {margin-left: 3.2em}
|
|
div.lisp {margin-left: 3.2em}
|
|
div.smalldisplay {margin-left: 3.2em}
|
|
div.smallexample {margin-left: 3.2em}
|
|
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.nolinebreak {white-space: nowrap}
|
|
span.roman {font-family: initial; font-weight: normal}
|
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
|
ul.no-bullet {list-style: none}
|
|
-->
|
|
</style>
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<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> [<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 ‘<samp>-z</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>
|
|
<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
|
|
…
|
|
</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 ‘<samp>mcount</samp>’ and ‘<samp>profil</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>
|
|
<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’s total execution time was 0.06
|
|
seconds, as indicated by the ‘<samp>cumulative seconds</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>open</samp>’ function, as indicated by the
|
|
‘<samp>self seconds</samp>’ field. Each of the other four samples
|
|
occurred one each in ‘<samp>offtime</samp>’, ‘<samp>memccpy</samp>’, ‘<samp>write</samp>’,
|
|
and ‘<samp>mcount</samp>’.
|
|
Since only six samples were taken, none of these values can
|
|
be regarded as particularly reliable.
|
|
In another run,
|
|
the ‘<samp>self seconds</samp>’ field for
|
|
‘<samp>mcount</samp>’ might well be ‘<samp>0.00</samp>’ or ‘<samp>0.02</samp>’.
|
|
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
|
|
‘<samp>self seconds</samp>’ field is ‘<samp>0.00</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>calls</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>
|
|
<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> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|