我已经安装了gperftools-2.0,但我无法获得CPU配置文件统计信息
以下是我获取统计信息的步骤:
- 安装 gperftoolstar -xzvfj gperftools-2.0.tar.gz
2.编辑CPP文件测试.cpp
#include <stdio.h>
#include <gperftools/profiler.h>
int main()
{
ProfilerStart("test.prof");
for (int i = 0; i<100; i++)
{
printf("hello world!");
}
ProfilerStop();
return 0;
}
编译g++ test.cpp -o test -O0 -I/usr/local/include/-L/usr/local/lib/-lprofiler
跑。/测试
报告pprof ./test --text test.prof
其输出为:使用本地文件 ./test。使用本地文件 test.prof.
我的脚步出了什么问题?
你只需要你的程序运行更长的时间,因为谷歌分析器只是每隔一段时间更新一次CPU统计信息。 重置"CPUPROFILE_FREQUENCY"或"CPUPROFILE_REALTIME"值可以更改此间隔时间。