Programming Tools Guide
Chapter 2, C compilation system

Preparing your program for profiling

Preparing your program for profiling

To use either of the profilers that are supplied with the C compilation system, you must do two things:

  1. Compile and link your program with a profiling option:

    for prof: cc -qp test.c
    for lprof: cc -ql test.c

  2. Run the profiled program:
    $ a.out
    
At the end of execution, data about your program's run-time behavior is written to a file in your current directory:

for prof: mon.out
for lprof: prog.cnt

where prog is the name of the profiled program. The data files are inputs to the profilers. See ``lprof'' and ``Interpreting profiling output'' in Chapter 9, ``C programmer's productivity tools'' for further information.