利用 gprof2dot 和graphviz 图形化定位linux c/c++系统性能瓶颈

1 下载

 

http://code.google.com/p/jrfonseca/wiki/Gprof2Dot

http://jrfonseca.googlecode.com/svn/trunk/gprof2dot/gprof2dot.py  下载gprof2dot.py

 http://www.graphviz.org/Download_source.php下载源代码graphviz-2.18.tar.gz

 

2  环境

[admin@b2bsearch80 bin]$ python -V

Python2.3.4

[admin@b2bsearch80 bin]$ gcc -v

Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs

Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux

Thread model: posix

gcc version 3.4.6 20060404 (Red Hat3.4.6-3)

[admin@b2bsearch80 bin]$ uname -a

Linux b2bsearch802.6.9-42.ELsmp #1 SMP Wed Jul 12 23:27:17 EDT 2006 i686 i686 i386 GNU/Linux

 

3  安装

 

Chmod 744 gprof2dot.py

Tar -zxvf graphviz-2.18.tar.gz

  ./configure

 make

  su  -

 make install

 

4   编译代码

gcc -pg -g -o uniqueCoreDump uniqueCoreDump.c

 

5  执行代码生成gmon.out

 

  执行命令产生gmon.out文件

  ./uniqueCoreDump

ll gmon.out

 

如果gprof ./uniqueCoreDump有:

gmon.out file is missing call-graph data

 

则表示没有正确的编译选项或者只有一个main函数

 

 

 

6  生成图片

 gprof ./uniqueCoreDump  | ./gprof2dot.py -n0 -e0 | dot -Tpng -o output.png

 

  sz  output.png 

 

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值