C programmer's productivity tools

Improving performance with prof and lprof

The prof and lprof profilers can help a programmer locate the time-consuming parts of a C program.

prof provides a time profile, that is, a list of the most time consuming functions and the amount of time taken by each. The lprof tool provides a list of the lines that are being executed most frequently. Once these potential problem areas have been identified, it is the programmer's job to rewrite those parts of the code so that the program runs more efficiently.

Although either of these profilers can be used singly, they are most efficient if you use them together. First, profile your program with prof to identify the most time-consuming functions. Then, profile only those functions (rather than the entire program) with lprof to determine which lines are being executed most frequently. This two-step approach takes the guesswork out of determining which lines of code are the most time-consuming.

It is important to profile programs with data that are typical of what the program will encounter in normal use. Most test cases fail to provide profiling data representative of typical usage.

Next topic: Improving test coverage with lprof
Previous topic: Using lprof with shared libraries

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003