Google Perf Tools安装以及使用

本文详细介绍了如何安装Google Perf Tools的libunwind和gperftools,包括源码安装和yum安装方法,并提供了遇到问题的解决策略。此外,文章还深入讲解了gperftools的使用,包括如何链接库、运行代码以及分析输出,帮助开发者进行CPU性能瓶颈定位。

Google Performance Tools安装以及使用

这边文章都记录在github:https://github.com/NIGHTFIGHTING/gperftools-tutorial
一个优化的内存管理算法—tcmalloc性能优于malloc。
一个用于CPU profile的工具,用于检测程序的性能热点,这个功能和gprof类似。
一个用于堆检查工具,用于检测程序在是够有内存泄露,这个功能和valgrind类似。
一个用于Heap profile的工具,用于监控程序在执行过程的内存使用情况。

1.使用其提供的内存管理函数---TC Malloc:
       gcc [...] -ltcmalloc  
2.使用其堆内存检查工具---Heap Checker:
       gcc [...] -o myprogram -ltcmalloc
       HEAPCHECK=normal ./myprogram   

3.使用Heap Profiler:
      gcc [...] -o myprogram -ltcmalloc
      HEAPPROFILE=/tmp/netheap ./myprogram  

4.使用Cpu Profiler:
      gcc [...] -o myprogram -lprofiler
      CPUPROFILE=/tmp/profile ./myprogram

代码:https://github.com/gperftools/gperftools
官方文档:
http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools
https://gperftools.github.io/gperftools/cpuprofile.html
http://goog-perftools.sourceforge.net/doc/cpu_profiler.html
https://github.com/gperftools/gperftools/wiki

1.安装libunwind

(1)源码安装libunwind

wget https://github.com/libunwind/libunwind/archive/v0.99.tar.gz  
tar -xvf v0.99.tar.gz  
cd libunwind-0.99  
autoreconf --force -v --install  
./configure --prefix=gperftools-tutorial/output   
make   
make install  

这里我安装产出在https://github.com/NIGHTFIGHTING/gperftools-tutorial/tree/master/output 这个目录
如果prefix不指定安装的目录,lib会产生在系统/usr/local/lib,头文件在/usr/local/include
我已经下载好的安装包在https://github.com/NIGHTFIGHTING/gperftools-tutorial/tree/master/gperftools

(2)yum安装

yum search libunwind # 查找,然后选择需要的安装  
yum install libunwind-devel.x86_64  

2.安装gperftools

源码安装google-perf-tools/gperftools

wget ht
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值