diff options
Diffstat (limited to 'devdocs/gcc~13/gcov-intro.html')
| -rw-r--r-- | devdocs/gcc~13/gcov-intro.html | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/devdocs/gcc~13/gcov-intro.html b/devdocs/gcc~13/gcov-intro.html new file mode 100644 index 00000000..d6d682d7 --- /dev/null +++ b/devdocs/gcc~13/gcov-intro.html @@ -0,0 +1,9 @@ +<div class="section-level-extent" id="Gcov-Intro"> <div class="nav-panel"> <p> Next: <a href="invoking-gcov" accesskey="n" rel="next">Invoking <code class="command">gcov</code></a>, Up: <a href="gcov" accesskey="u" rel="up"><code class="command">gcov</code>—a Test Coverage Program</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div> <h1 class="section" id="Introduction-to-gcov"><span>10.1 Introduction to gcov<a class="copiable-link" href="#Introduction-to-gcov"> ¶</a></span></h1> <p><code class="command">gcov</code> is a test coverage program. Use it in concert with GCC to analyze your programs to help create more efficient, faster running code and to discover untested parts of your program. You can use <code class="command">gcov</code> as a profiling tool to help discover where your optimization efforts will best affect your code. You can also use <code class="command">gcov</code> along with the other profiling tool, <code class="command">gprof</code>, to assess which parts of your code use the greatest amount of computing time. </p> <p>Profiling tools help you analyze your code’s performance. Using a profiler such as <code class="command">gcov</code> or <code class="command">gprof</code>, you can find out some basic performance statistics, such as: </p> <ul class="itemize mark-bullet"> <li>how often each line of code executes </li> +<li>what lines of code are actually executed </li> +<li>how much computing time each section of code uses </li> +</ul> <p>Once you know these things about how your code works when compiled, you can look at each module to see which modules should be optimized. <code class="command">gcov</code> helps you determine where to work on optimization. </p> <p>Software developers also use coverage testing in concert with testsuites, to make sure software is actually good enough for a release. Testsuites can verify that a program works as expected; a coverage program tests to see how much of the program is exercised by the testsuite. Developers can then determine what kinds of test cases need to be added to the testsuites to create both better testing and a better final product. </p> <p>You should compile your code without optimization if you plan to use <code class="command">gcov</code> because the optimization, by combining some lines of code into one function, may not give you as much information as you need to look for ‘hot spots’ where the code is using a great deal of computer time. Likewise, because <code class="command">gcov</code> accumulates statistics by line (at the lowest resolution), it works best with a programming style that places only one statement on each line. If you use complicated macros that expand to loops or to other control structures, the statistics are less helpful—they only report on the line where the macro call appears. If your complex macros behave like functions, you can replace them with inline functions to solve this problem. </p> <p><code class="command">gcov</code> creates a logfile called <samp class="file"><var class="var">sourcefile</var>.gcov</samp> which indicates how many times each line of a source file <samp class="file"><var class="var">sourcefile</var>.c</samp> has executed. You can use these logfiles along with <code class="command">gprof</code> to aid in fine-tuning the performance of your programs. <code class="command">gprof</code> gives timing information you can use along with the information you get from <code class="command">gcov</code>. </p> <p><code class="command">gcov</code> works only on code compiled with GCC. It is not compatible with any other profiling or test coverage mechanism. </p> </div> <div class="nav-panel"> <p> Next: <a href="invoking-gcov">Invoking <code class="command">gcov</code></a>, Up: <a href="gcov"><code class="command">gcov</code>—a Test Coverage Program</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div><div class="_attribution"> + <p class="_attribution-p"> + © Free Software Foundation<br>Licensed under the GNU Free Documentation License, Version 1.3.<br> + <a href="https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Gcov-Intro.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Gcov-Intro.html</a> + </p> +</div> |
