Section 18.8. Profiling


18.8. Profiling

The -p option adds special functions to your program to output profiling information when you run it. Profiling is useful in resolving performance problems, because it lets you see which functions your program is spending its execution time on. The profiling output is saved in a file called mon.out. You can then use the prof utility to analyze the profiling information in a number of ways; see the prof manual for details.

For the GNU profiler, gprof, compile your program with the -pg option. The default output filename for the profiling information is then gmon.out. gprof with the -pg option can generate a call graph showing which functions in your program call which others. If you combine the -pg option with -g, the GCC option that provides source-line information for a debugger, then gprof can also provide line-by-line profiling.



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net