Next: Compiling Prev: Top Up: Top
Profiling allows you to learn where your program spent its time and
which functions called which other functions while it was executing.
This information can show you which pieces of your program are slower
than you expected, and might be candidates for rewriting to make your
program execute faster. It can also tell you which functions are being
called more or less often than you expected. This may help you spot
bugs that had otherwise been unnoticed.
Since the profiler uses information collected during the actual
execution of your program, it can be used on programs that are too
large or too complex to analyze by reading the source. However, how
your program is run will affect the information that shows up in the
profile data. If you don't use some feature of your program while it
is being profiled, no profile information will be generated for that
Profiling has several steps:
* You must compile and link your program with profiling enabled.
* You must execute your program to generate a profile data file.
* You must run `gprof' to analyze the profile data. *Note
The next three chapters explain these steps in greater detail.
The result of the analysis is a file containing two tables, the
"flat profile" and the "call graph" (plus blurbs which briefly explain
the contents of these tables).
The flat profile shows how much time your program spent in each
function, and how many times that function was called. If you simply
want to know which functions burn most of the cycles, it is stated
concisely here. Note: Flat Profile.
The call graph shows, for each function, which functions called it,
which other functions it called, and how many times. There is also an
estimate of how much time was spent in the subroutines of each
function. This can suggest places where you might try to eliminate
function calls that use a lot of time. Note: Call Graph.
automatically generated by info2www