Gprof is the Berkeley application profiling tool. Gprof provides a superset of the functionality available with prof, the System V version. Therefore, it is recommended that gprof be used rather than prof. Profiling an application with gprof involves the following steps:
Special compilation and linking
14.3.1. Step 1: Special Compilation and Linking
Application profiling is available for programs written in the C, C++, Fortran, and Pascal languages. The program must be specially compiled with the -G switch to prepare the application for profiling. This special compiler option causes calls to the procedure _mcount() to be inserted at the beginning of every procedure. In addition to recording ...