Programming Tools Guide
Chapter 9, C programmer's productivity tools

Creating a profiled version of a program

Creating a profiled version of a program

If a program is to be profiled with lprof, it must be compiled with the -ql option to the cc command so that line count data will be saved. For example:

   $ cc -ql travel.c
If you wish to create relocatable object files and link them later, you must specify -ql when you link as well as when you compile:
   $ cc -ql -c travel.c
   $ cc -ql -c misc.c
   $ cc -ql -o travel travel.o misc.o
To profile an individual source file, rather than the source for the whole program, create a profiled version by using the -ql option when you compile the source file in question, and again when you link.