gperftools-2.5.93



https://github.com/gperftools/gperftools


https://gperftools.github.io/gperftools/cpuprofile.html



yum install libunwind

yum install libunwind-devel

yum install graphviz


编译时 -lprofiler 运行找不到 profiler 时,export LD_LIBRARY_PATH=/usr/local/lib/ 默认装这下面


Running the Code

There are several alternatives to actually turn on CPU profiling for a given run of an executable:

  1. Define the environment variable CPUPROFILE to the filename to dump the profile to. For instance, if you had a version of /bin/ls that had been linked against libprofiler, you could run:

    % env CPUPROFILE=ls.prof /bin/ls
  2. In addition to defining the environment variable CPUPROFILE you can also define CPUPROFILESIGNAL. This allows profiling to be controlled via the signal number that you specify. The signal number must be unused by the program under normal operation. Internally it acts as a switch, triggered by the signal, which is off by default. For instance, if you had a copy of /bin/chrome that had been been linked against libprofiler, you could run:

    % env CPUPROFILE=chrome.prof CPUPROFILESIGNAL=12 /bin/chrome &

    You can then trigger profiling to start:

    % killall -12 chrome

    Then after a period of time you can tell it to stop which will generate the profile:

    % killall -12 chrome
  3. In your code, bracket the code you want profiled in calls to ProfilerStart() and ProfilerStop(). (These functions are declared in <gperftools/profiler.h>.) ProfilerStart() will take the profile-filename as an argument.



分析:

pprof  ./demo my.prof > profile.txt

pprof --text ./demo my.prof > profile.txt

pprof --pdf ./demo my.prof > profile.pdf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值