Most compilers have the ability to generate call graph data that can be utilized by the "gprof" profiler to display detailed behavior information for a program at the function level. This information includes the number of calls for each function and the functions that called them. It also includes an estimate of the amount of time spent in each function based on sampling. Several different types of reports are available, including source code output annotated with the number of times each statement was executed. This is a form of instrumented profiling (supplemented by sampling), as the compiler is adding profiling instructions to the resulting executable.

To use gprof, first compile your program with options to enable profiling support. For the Intel compilers, include the -p and-g options. For the GNU compilers, include the -pg option. Next, conduct a standard execution of the program, which will generate a call graph for the run. The raw call graph output will be stored in a file in the same directory named "gmon.out" by default. The profile data may be read and interpreted by running gprof. For the default profile, type:

This will display the profiling data for the previous run, followed by a call graph analysis for all functions.

 
©   Cornell University  |  Center for Advanced Computing  |  Copyright Statement  |  Inclusivity Statement