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: Top</title> 17 18<meta name="description" content="GNU gprof: Top"> 19<meta name="keywords" content="GNU gprof: Top"> 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="#Top" rel="start" title="Top"> 25<link href="#SEC_Contents" rel="contents" title="Table of Contents"> 26<link href="../dir/index.html" rel="up" title="(dir)"> 27<link href="Introduction.html#Introduction" rel="next" title="Introduction"> 28<style type="text/css"> 29<!-- 30a.summary-letter {text-decoration: none} 31blockquote.smallquotation {font-size: smaller} 32div.display {margin-left: 3.2em} 33div.example {margin-left: 3.2em} 34div.indentedblock {margin-left: 3.2em} 35div.lisp {margin-left: 3.2em} 36div.smalldisplay {margin-left: 3.2em} 37div.smallexample {margin-left: 3.2em} 38div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 39div.smalllisp {margin-left: 3.2em} 40kbd {font-style:oblique} 41pre.display {font-family: inherit} 42pre.format {font-family: inherit} 43pre.menu-comment {font-family: serif} 44pre.menu-preformatted {font-family: serif} 45pre.smalldisplay {font-family: inherit; font-size: smaller} 46pre.smallexample {font-size: smaller} 47pre.smallformat {font-family: inherit; font-size: smaller} 48pre.smalllisp {font-size: smaller} 49span.nocodebreak {white-space:nowrap} 50span.nolinebreak {white-space:nowrap} 51span.roman {font-family:serif; font-weight:normal} 52span.sansserif {font-family:sans-serif; font-weight:normal} 53ul.no-bullet {list-style: none} 54--> 55</style> 56 57 58</head> 59 60<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 61<h1 class="settitle" align="center">GNU gprof</h1> 62 63 64 65 66 67<a name="SEC_Contents"></a> 68<h2 class="contents-heading">Table of Contents</h2> 69 70<div class="contents"> 71 72<ul class="no-bullet"> 73 <li><a name="toc-Introduction-to-Profiling" href="Introduction.html#Introduction">1 Introduction to Profiling</a></li> 74 <li><a name="toc-Compiling-a-Program-for-Profiling" href="Compiling.html#Compiling">2 Compiling a Program for Profiling</a></li> 75 <li><a name="toc-Executing-the-Program" href="Executing.html#Executing">3 Executing the Program</a></li> 76 <li><a name="toc-gprof-Command-Summary" href="Invoking.html#Invoking">4 <code>gprof</code> Command Summary</a> 77 <ul class="no-bullet"> 78 <li><a name="toc-Output-Options-1" href="Output-Options.html#Output-Options">4.1 Output Options</a></li> 79 <li><a name="toc-Analysis-Options-1" href="Analysis-Options.html#Analysis-Options">4.2 Analysis Options</a></li> 80 <li><a name="toc-Miscellaneous-Options-1" href="Miscellaneous-Options.html#Miscellaneous-Options">4.3 Miscellaneous Options</a></li> 81 <li><a name="toc-Deprecated-Options-1" href="Deprecated-Options.html#Deprecated-Options">4.4 Deprecated Options</a></li> 82 <li><a name="toc-Symspecs-1" href="Symspecs.html#Symspecs">4.5 Symspecs</a></li> 83 </ul></li> 84 <li><a name="toc-Interpreting-gprof_0027s-Output" href="Output.html#Output">5 Interpreting <code>gprof</code>’s Output</a> 85 <ul class="no-bullet"> 86 <li><a name="toc-The-Flat-Profile" href="Flat-Profile.html#Flat-Profile">5.1 The Flat Profile</a></li> 87 <li><a name="toc-The-Call-Graph" href="Call-Graph.html#Call-Graph">5.2 The Call Graph</a> 88 <ul class="no-bullet"> 89 <li><a name="toc-The-Primary-Line" href="Primary.html#Primary">5.2.1 The Primary Line</a></li> 90 <li><a name="toc-Lines-for-a-Function_0027s-Callers" href="Callers.html#Callers">5.2.2 Lines for a Function’s Callers</a></li> 91 <li><a name="toc-Lines-for-a-Function_0027s-Subroutines" href="Subroutines.html#Subroutines">5.2.3 Lines for a Function’s Subroutines</a></li> 92 <li><a name="toc-How-Mutually-Recursive-Functions-Are-Described" href="Cycles.html#Cycles">5.2.4 How Mutually Recursive Functions Are Described</a></li> 93 </ul></li> 94 <li><a name="toc-Line_002dby_002dline-Profiling" href="Line_002dby_002dline.html#Line_002dby_002dline">5.3 Line-by-line Profiling</a></li> 95 <li><a name="toc-The-Annotated-Source-Listing" href="Annotated-Source.html#Annotated-Source">5.4 The Annotated Source Listing</a></li> 96 </ul></li> 97 <li><a name="toc-Inaccuracy-of-gprof-Output" href="Inaccuracy.html#Inaccuracy">6 Inaccuracy of <code>gprof</code> Output</a> 98 <ul class="no-bullet"> 99 <li><a name="toc-Statistical-Sampling-Error" href="Sampling-Error.html#Sampling-Error">6.1 Statistical Sampling Error</a></li> 100 <li><a name="toc-Estimating-children-Times" href="Assumptions.html#Assumptions">6.2 Estimating <code>children</code> Times</a></li> 101 </ul></li> 102 <li><a name="toc-Answers-to-Common-Questions" href="How-do-I_003f.html#How-do-I_003f">7 Answers to Common Questions</a></li> 103 <li><a name="toc-Incompatibilities-with-Unix-gprof" href="Incompatibilities.html#Incompatibilities">8 Incompatibilities with Unix <code>gprof</code></a></li> 104 <li><a name="toc-Details-of-Profiling" href="Details.html#Details">9 Details of Profiling</a> 105 <ul class="no-bullet"> 106 <li><a name="toc-Implementation-of-Profiling" href="Implementation.html#Implementation">9.1 Implementation of Profiling</a></li> 107 <li><a name="toc-Profiling-Data-File-Format" href="File-Format.html#File-Format">9.2 Profiling Data File Format</a> 108 <ul class="no-bullet"> 109 <li><a name="toc-Histogram-Records" href="File-Format.html#Histogram-Records">9.2.1 Histogram Records</a></li> 110 <li><a name="toc-Call_002dGraph-Records" href="File-Format.html#Call_002dGraph-Records">9.2.2 Call-Graph Records</a></li> 111 <li><a name="toc-Basic_002dBlock-Execution-Count-Records" href="File-Format.html#Basic_002dBlock-Execution-Count-Records">9.2.3 Basic-Block Execution Count Records</a></li> 112 </ul></li> 113 <li><a name="toc-gprof_0027s-Internal-Operation" href="Internals.html#Internals">9.3 <code>gprof</code>’s Internal Operation</a></li> 114 <li><a name="toc-Debugging-gprof" href="Debugging.html#Debugging">9.4 Debugging <code>gprof</code></a></li> 115 </ul></li> 116 <li><a name="toc-GNU-Free-Documentation-License-1" href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">Appendix A GNU Free Documentation License</a></li> 117</ul> 118</div> 119 120 121<a name="Top"></a> 122<div class="header"> 123<p> 124Next: <a href="Introduction.html#Introduction" accesskey="n" rel="next">Introduction</a>, Up: <a href="../dir/index.html" accesskey="u" rel="up">(dir)</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> 125</div> 126<hr> 127<a name="Profiling-a-Program_003a-Where-Does-It-Spend-Its-Time_003f"></a> 128<h1 class="top">Profiling a Program: Where Does It Spend Its Time?</h1> 129 130<p>This manual describes the <small>GNU</small> profiler, <code>gprof</code>, and how you 131can use it to determine which parts of a program are taking most of the 132execution time. We assume that you know how to write, compile, and 133execute programs. <small>GNU</small> <code>gprof</code> was written by Jay Fenlason. 134</p> 135<p>This manual is for <code>gprof</code> 136(GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)) 137version 2.36.1. 138</p> 139<p>This document is distributed under the terms of the GNU Free 140Documentation License version 1.3. A copy of the license is included 141in the section entitled “GNU Free Documentation License”. 142</p> 143<table class="menu" border="0" cellspacing="0"> 144<tr><td align="left" valign="top">• <a href="Introduction.html#Introduction" accesskey="1">Introduction</a>:</td><td> </td><td align="left" valign="top">What profiling means, and why it is useful. 145</td></tr> 146<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment"> 147</pre></th></tr><tr><td align="left" valign="top">• <a href="Compiling.html#Compiling" accesskey="2">Compiling</a>:</td><td> </td><td align="left" valign="top">How to compile your program for profiling. 148</td></tr> 149<tr><td align="left" valign="top">• <a href="Executing.html#Executing" accesskey="3">Executing</a>:</td><td> </td><td align="left" valign="top">Executing your program to generate profile data 150</td></tr> 151<tr><td align="left" valign="top">• <a href="Invoking.html#Invoking" accesskey="4">Invoking</a>:</td><td> </td><td align="left" valign="top">How to run <code>gprof</code>, and its options 152</td></tr> 153<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment"> 154</pre></th></tr><tr><td align="left" valign="top">• <a href="Output.html#Output" accesskey="5">Output</a>:</td><td> </td><td align="left" valign="top">Interpreting <code>gprof</code>’s output 155</td></tr> 156<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment"> 157</pre></th></tr><tr><td align="left" valign="top">• <a href="Inaccuracy.html#Inaccuracy" accesskey="6">Inaccuracy</a>:</td><td> </td><td align="left" valign="top">Potential problems you should be aware of 158</td></tr> 159<tr><td align="left" valign="top">• <a href="How-do-I_003f.html#How-do-I_003f" accesskey="7">How do I?</a>:</td><td> </td><td align="left" valign="top">Answers to common questions 160</td></tr> 161<tr><td align="left" valign="top">• <a href="Incompatibilities.html#Incompatibilities" accesskey="8">Incompatibilities</a>:</td><td> </td><td align="left" valign="top">(between <small>GNU</small> <code>gprof</code> and Unix <code>gprof</code>.) 162</td></tr> 163<tr><td align="left" valign="top">• <a href="Details.html#Details" accesskey="9">Details</a>:</td><td> </td><td align="left" valign="top">Details of how profiling is done 164</td></tr> 165<tr><td align="left" valign="top">• <a href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU Free Documentation License</a>:</td><td> </td><td align="left" valign="top">GNU Free Documentation License 166</td></tr> 167</table> 168 169<hr> 170<div class="header"> 171<p> 172Next: <a href="Introduction.html#Introduction" accesskey="n" rel="next">Introduction</a>, Up: <a href="../dir/index.html" accesskey="u" rel="up">(dir)</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> 173</div> 174 175 176 177</body> 178</html> 179