gperftools安装和使用

29 篇文章 0 订阅

gperftools 下载和安装

github 上找到源码,下载并解压
64位机器需要先安装 apt-get install libunwind8-dev
./autogen.sh
./configure
make -j8
# 安装到系统文件夹
sudo make install
ldconfig 刷新动态库文件

CPU

使用方法一
gcc [...] -o myprogram -lprofiler
# 设置环境变量CPUPROFILER指定生成的性能报告文件,并执行自己的程序
CPUPROFILE=/tmp/profile ./myprogram
使用方法二
#include <gperftools/profiler.h>
....
int main(int argc, const char* argv[])
{
	ProfilerStart("test_capture.prof");
	.....
	ProfilerStop();
}
性能报告
pprof  ./test_capture test_capture.prof --web
pprof  ./test_capture test_capture.prof --pdf > prof.pdf
./test_capture test_capture.prof --text

heap

下载可视化工具
sudo apt install kcachegrind
sudo apt-get install graphviz gv

编译链接 g++ leak.cpp -ltcmalloc -g -o leak
查看结果 HEAPCHECK=normal ./leak
生成快照文件 HEAPPROFILE=profile  demo
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值