红联Linux门户
Linux帮助

一些linux命令

发布时间:2007-10-10 01:22:01来源:红联作者:Mqqlecyro
备忘
gprof a.out -b gmon.out

gprof是gnu binutils工具之一,默认情况下linux系统当中都带有这个工具。

使用 -pg 选项来编译hello.c,如果要得到带注释的源码清单,则需要增加 -g 选项。运行: gcc -pg -g -o hello hello.c

运行应用程序: ./hello 会在当前目录下产生gmon.out文件

使用gprof来分析gmon.out文件,需要把它和产生它的应用程序关联起来:

gprof hello gmon.out -p 得到每个函数占用的执行时间

gprof hello gmon.out -q 得到call graph,包含了每个函数的调用关系,调用次数,执行时间等信息。

gprof hello gmon.out -A 得到一个带注释的“源代码清单”,它会注释源码,指出每个函数的执行次数。这需要在编译的时候增加 -g选项。
文章评论

共有 0 条评论