The gprof utility is the GNU profiler, a tool that identifies how much time is spent in a function of an operating program. The GNU profiler also identifies which functions were called by a given function. Similar to the gcov utility (the topic of Chapter 7, Coverage Testing with GNU gcov ), the compiler introduces profiling code into the target image, which generates a statistics file upon execution. This file ( gmon.out ) contains histogram records, call-graph arc records, and basic-block execution records that illustrate the execution profile of an application. When read by the gprof utility, the performance behavior of the application can be readily understood .
We ll discuss use of the gprof utility bundled with version 3.2.2 of the GNU compiler tool chain.