4 使用流程
1. 在编译和链接时 加上-pg选项。一般我们可以加在 makefile 中。
2. 执行编译的二进制程序。执行参数和方式同以前。
3. 在程序运行目录下 生成 gmon.out 文件。如果原来有gmon.out 文件,将会被重写。
4. 结束进程。这时 gmon.out 会再次被刷新。
5. 用 gprof 工具分析 gmon.out 文件。
用户手册地址:http://sourceware.org/binutils/docs-2.17/gprof/index.html
g++ -o gperf_test gperf_test.cpp -pg -g
gprof -b ./gperf_test gmon.out
http://blog.csdn.net/stanjiang2010/article/details/5655143