您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

197 行
8.5KB

  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-2020 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 6.5, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  15. <title>Flat Profile (GNU gprof)</title>
  16. <meta name="description" content="Flat Profile (GNU gprof)">
  17. <meta name="keywords" content="Flat Profile (GNU gprof)">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  23. <link href="Output.html#Output" rel="up" title="Output">
  24. <link href="Call-Graph.html#Call-Graph" rel="next" title="Call Graph">
  25. <link href="Output.html#Output" rel="prev" title="Output">
  26. <style type="text/css">
  27. <!--
  28. a.summary-letter {text-decoration: none}
  29. blockquote.indentedblock {margin-right: 0em}
  30. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.lisp {margin-left: 3.2em}
  35. div.smalldisplay {margin-left: 3.2em}
  36. div.smallexample {margin-left: 3.2em}
  37. div.smalllisp {margin-left: 3.2em}
  38. kbd {font-style: oblique}
  39. pre.display {font-family: inherit}
  40. pre.format {font-family: inherit}
  41. pre.menu-comment {font-family: serif}
  42. pre.menu-preformatted {font-family: serif}
  43. pre.smalldisplay {font-family: inherit; font-size: smaller}
  44. pre.smallexample {font-size: smaller}
  45. pre.smallformat {font-family: inherit; font-size: smaller}
  46. pre.smalllisp {font-size: smaller}
  47. span.nolinebreak {white-space: nowrap}
  48. span.roman {font-family: initial; 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">
  55. <a name="Flat-Profile"></a>
  56. <div class="header">
  57. <p>
  58. 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>
  59. </div>
  60. <hr>
  61. <a name="The-Flat-Profile"></a>
  62. <h3 class="section">5.1 The Flat Profile</h3>
  63. <a name="index-flat-profile"></a>
  64. <p>The <em>flat profile</em> shows the total amount of time your program
  65. spent executing each function. Unless the &lsquo;<samp>-z</samp>&rsquo; option is given,
  66. functions with no apparent time spent in them, and no apparent calls
  67. to them, are not mentioned. Note that if a function was not compiled
  68. for profiling, and didn&rsquo;t run long enough to show up on the program
  69. counter histogram, it will be indistinguishable from a function that
  70. was never called.
  71. </p>
  72. <p>This is part of a flat profile for a small program:
  73. </p>
  74. <div class="smallexample">
  75. <pre class="smallexample">Flat profile:
  76. Each sample counts as 0.01 seconds.
  77. % cumulative self self total
  78. time seconds seconds calls ms/call ms/call name
  79. 33.34 0.02 0.02 7208 0.00 0.00 open
  80. 16.67 0.03 0.01 244 0.04 0.12 offtime
  81. 16.67 0.04 0.01 8 1.25 1.25 memccpy
  82. 16.67 0.05 0.01 7 1.43 1.43 write
  83. 16.67 0.06 0.01 mcount
  84. 0.00 0.06 0.00 236 0.00 0.00 tzset
  85. 0.00 0.06 0.00 192 0.00 0.00 tolower
  86. 0.00 0.06 0.00 47 0.00 0.00 strlen
  87. 0.00 0.06 0.00 45 0.00 0.00 strchr
  88. 0.00 0.06 0.00 1 0.00 50.00 main
  89. 0.00 0.06 0.00 1 0.00 0.00 memcpy
  90. 0.00 0.06 0.00 1 0.00 10.11 print
  91. 0.00 0.06 0.00 1 0.00 0.00 profil
  92. 0.00 0.06 0.00 1 0.00 50.00 report
  93. &hellip;
  94. </pre></div>
  95. <p>The functions are sorted first by decreasing run-time spent in them,
  96. then by decreasing number of calls, then alphabetically by name. The
  97. functions &lsquo;<samp>mcount</samp>&rsquo; and &lsquo;<samp>profil</samp>&rsquo; are part of the profiling
  98. apparatus and appear in every flat profile; their time gives a measure of
  99. the amount of overhead due to profiling.
  100. </p>
  101. <p>Just before the column headers, a statement appears indicating
  102. how much time each sample counted as.
  103. This <em>sampling period</em> estimates the margin of error in each of the time
  104. figures. A time figure that is not much larger than this is not
  105. reliable. In this example, each sample counted as 0.01 seconds,
  106. suggesting a 100 Hz sampling rate.
  107. The program&rsquo;s total execution time was 0.06
  108. seconds, as indicated by the &lsquo;<samp>cumulative seconds</samp>&rsquo; field. Since
  109. each sample counted for 0.01 seconds, this means only six samples
  110. were taken during the run. Two of the samples occurred while the
  111. program was in the &lsquo;<samp>open</samp>&rsquo; function, as indicated by the
  112. &lsquo;<samp>self seconds</samp>&rsquo; field. Each of the other four samples
  113. occurred one each in &lsquo;<samp>offtime</samp>&rsquo;, &lsquo;<samp>memccpy</samp>&rsquo;, &lsquo;<samp>write</samp>&rsquo;,
  114. and &lsquo;<samp>mcount</samp>&rsquo;.
  115. Since only six samples were taken, none of these values can
  116. be regarded as particularly reliable.
  117. In another run,
  118. the &lsquo;<samp>self seconds</samp>&rsquo; field for
  119. &lsquo;<samp>mcount</samp>&rsquo; might well be &lsquo;<samp>0.00</samp>&rsquo; or &lsquo;<samp>0.02</samp>&rsquo;.
  120. See <a href="Sampling-Error.html#Sampling-Error">Statistical Sampling Error</a>,
  121. for a complete discussion.
  122. </p>
  123. <p>The remaining functions in the listing (those whose
  124. &lsquo;<samp>self seconds</samp>&rsquo; field is &lsquo;<samp>0.00</samp>&rsquo;) didn&rsquo;t appear
  125. in the histogram samples at all. However, the call graph
  126. indicated that they were called, so therefore they are listed,
  127. sorted in decreasing order by the &lsquo;<samp>calls</samp>&rsquo; field.
  128. Clearly some time was spent executing these functions,
  129. but the paucity of histogram samples prevents any
  130. determination of how much time each took.
  131. </p>
  132. <p>Here is what the fields in each line mean:
  133. </p>
  134. <dl compact="compact">
  135. <dt><code>% time</code></dt>
  136. <dd><p>This is the percentage of the total execution time your program spent
  137. in this function. These should all add up to 100%.
  138. </p>
  139. </dd>
  140. <dt><code>cumulative seconds</code></dt>
  141. <dd><p>This is the cumulative total number of seconds the computer spent
  142. executing this functions, plus the time spent in all the functions
  143. above this one in this table.
  144. </p>
  145. </dd>
  146. <dt><code>self seconds</code></dt>
  147. <dd><p>This is the number of seconds accounted for by this function alone.
  148. The flat profile listing is sorted first by this number.
  149. </p>
  150. </dd>
  151. <dt><code>calls</code></dt>
  152. <dd><p>This is the total number of times the function was called. If the
  153. function was never called, or the number of times it was called cannot
  154. be determined (probably because the function was not compiled with
  155. profiling enabled), the <em>calls</em> field is blank.
  156. </p>
  157. </dd>
  158. <dt><code>self ms/call</code></dt>
  159. <dd><p>This represents the average number of milliseconds spent in this
  160. function per call, if this function is profiled. Otherwise, this field
  161. is blank for this function.
  162. </p>
  163. </dd>
  164. <dt><code>total ms/call</code></dt>
  165. <dd><p>This represents the average number of milliseconds spent in this
  166. function and its descendants per call, if this function is profiled.
  167. Otherwise, this field is blank for this function.
  168. This is the only field in the flat profile that uses call graph analysis.
  169. </p>
  170. </dd>
  171. <dt><code>name</code></dt>
  172. <dd><p>This is the name of the function. The flat profile is sorted by this
  173. field alphabetically after the <em>self seconds</em> and <em>calls</em>
  174. fields are sorted.
  175. </p></dd>
  176. </dl>
  177. <hr>
  178. <div class="header">
  179. <p>
  180. 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>
  181. </div>
  182. </body>
  183. </html>