GPROF
Monitoring Program Performance


GPROF is a directory of C programs which illustrate how the GPROF peformance monitoring program can be used to monitor the performance of a C program and produce a variety of reports.

In order to use GPROF with a C program, the user program must be compiled and linked with the -pg switch. For example, either


        gcc -pg myprog.c
      
or, in a two step process,

        gcc -c -pg myprog.c
        gcc -pg myprog.o
      
When the resulting executable program is run, GPROF will silently monitor the program, and produce a report file called gmon.out. This report file is not user-readable. To see the information contained in the report, you have to run gprof and tell it the name of the executable program you just ran. A typical procedure, then, would be to issue the commands
        myprog            (to run your program called "myprog")
        gprof myprog      (to have GPROF make the report)
      

GPROF can only report on code which has been compiled with the appropriate options. If your program calls routines from a precompiled library (which probably was NOT compiled with the -pg option!) then your report information will not include information about the time spent in those routines. GPROF's report will charge all such time to the higher level routine that called the library routine. If most of your execution time occurs in various library routines, then this fact may greatly reduce the value of GPROF's information.

For more information on how to use GPROF, type


        man gprof
      

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

GPROF examples are available in a C version and a C++ version and a FORTRAN90 version.

Examples and Tests:

LINPACK_BENCH is the LINPACK benchmark code, which solves a linear system. This program was compiled, run, and analyzed with GPROF. Files you may copy include:

You can go up one level to the C source codes.


Last revised on 14 September 2010.