index.html 11 KB

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