* 1、下载及安装libunwind
下载地址: http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz
<http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz>
安装: ./configure --prefix=/home/your_name/tools/libunwind/
CFLAGS=-U_FORTRIFY_SOURCEmake make install
* 2、下载及安装gperftools
git地址:https://github.com/gperftools/gperftools
<https://github.com/gperftools/gperftools>
安装: ./configure --prefix=/home/your_name/tools/gperftools LDFLAGS=-L
/home/your_name/tools/libunwind/libCPPFLAGS=-I/home/your_name/tools/libunwind/
include make make install
* 3、安装kcachegrind
系统ubuntu16.04 sudo apt-get install kcachegrind
* 4、使用方法
参考:https://dirtysalt.github.io/gperftools.html#orgheadline4
<https://dirtysalt.github.io/gperftools.html#orgheadline4>
举例: env LD_PRELOAD="/home/your-name/tools/gperftools/lib/libprofiler.so"
CPUPROFILE_FREQUENCY=100 CPUPROFILE=cpu_perf.prof ./Test
运行完成后会在当前目录下生成cpu_perf.prof文件,结合pprof工具(gperftools/bin)可生成txt或pdf等:
~/tools/gperftools/bin/pprof --pdf ./test cpu_perf.prof > cpu_perf.pdf ~
/tools/gperftools/bin/pprof --txt ./test cpu_perf.prof > cpu_perf.txt
或者在代码中加入google/profiler.h头文件并结合相应函数使用。

友情链接
ioDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信