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 https://github.com/gperftools/gperftool