First, Introduction
Gprof is one of the GNU tools, it is compiled at the time of the entry and exit of each function to add the profiling code, run-time statistics program in the user state execution information, you can get the number of calls per function, execution time, call relations and other information, easy to understand. It is suitable to find the performance bottleneck of the user-level program, and the gprof is not suitable for the program that is executed in kernel state many times.
Ii. methods of Use
1) Pass PG option to GNU Tools, both compiler and connector need to add-PG option
gcc -g-pg .......
2) Execute the program (note: Statistics files are generated only when the program terminates properly.) In other words, the program must be terminated from exit or return. )
file.
3) Analysis of generated results
Gprof [Options] < executables >
When you use Gprof to parse a gmon.out file, you need to associate it with the application that generated it:
Gprof <program> gmon.out--a Get a annotated "source code list" that will annotate the source and indicate the number of executions per function. This requires adding the-G option at compile time.
Reference: http://blog.chinaunix.net/uid-23767307-id-2940412.html
Linux gprof Commands