You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
4.4KB

  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>How do I? (GNU gprof)</title>
  16. <meta name="description" content="How do I? (GNU gprof)">
  17. <meta name="keywords" content="How do I? (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="index.html#Top" rel="up" title="Top">
  24. <link href="Incompatibilities.html#Incompatibilities" rel="next" title="Incompatibilities">
  25. <link href="Assumptions.html#Assumptions" rel="prev" title="Assumptions">
  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="How-do-I_003f"></a>
  56. <div class="header">
  57. <p>
  58. Next: <a href="Incompatibilities.html#Incompatibilities" accesskey="n" rel="next">Incompatibilities</a>, Previous: <a href="Inaccuracy.html#Inaccuracy" accesskey="p" rel="prev">Inaccuracy</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
  59. </div>
  60. <hr>
  61. <a name="Answers-to-Common-Questions"></a>
  62. <h2 class="chapter">7 Answers to Common Questions</h2>
  63. <dl compact="compact">
  64. <dt>How can I get more exact information about hot spots in my program?</dt>
  65. <dd>
  66. <p>Looking at the per-line call counts only tells part of the story.
  67. Because <code>gprof</code> can only report call times and counts by function,
  68. the best way to get finer-grained information on where the program
  69. is spending its time is to re-factor large functions into sequences
  70. of calls to smaller ones. Beware however that this can introduce
  71. artificial hot spots since compiling with &lsquo;<samp>-pg</samp>&rsquo; adds a significant
  72. overhead to function calls. An alternative solution is to use a
  73. non-intrusive profiler, e.g. oprofile.
  74. </p>
  75. </dd>
  76. <dt>How do I find which lines in my program were executed the most times?</dt>
  77. <dd>
  78. <p>Use the <code>gcov</code> program.
  79. </p>
  80. </dd>
  81. <dt>How do I find which lines in my program called a particular function?</dt>
  82. <dd>
  83. <p>Use &lsquo;<samp>gprof -l</samp>&rsquo; and lookup the function in the call graph.
  84. The callers will be broken down by function and line number.
  85. </p>
  86. </dd>
  87. <dt>How do I analyze a program that runs for less than a second?</dt>
  88. <dd>
  89. <p>Try using a shell script like this one:
  90. </p>
  91. <div class="example">
  92. <pre class="example">for i in `seq 1 100`; do
  93. fastprog
  94. mv gmon.out gmon.out.$i
  95. done
  96. gprof -s fastprog gmon.out.*
  97. gprof fastprog gmon.sum
  98. </pre></div>
  99. <p>If your program is completely deterministic, all the call counts
  100. will be simple multiples of 100 (i.e., a function called once in
  101. each run will appear with a call count of 100).
  102. </p>
  103. </dd>
  104. </dl>
  105. </body>
  106. </html>