我已经安装了 GPERFtools-2.0,但我无法获取 CPU 配置文件统计信息



我已经安装了gperftools-2.0,但我无法获得CPU配置文件统计信息

以下是我获取统计信息的步骤:

  1. 安装 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;
}
  1. 编译g++ test.cpp -o test -O0 -I/usr/local/include/-L/usr/local/lib/-lprofiler

  2. 跑。/测试

  3. 报告pprof ./test --text test.prof

其输出为:使用本地文件 ./test。使用本地文件 test.prof.

我的脚步出了什么问题?

你只需要你的程序运行更长的时间,因为谷歌分析器只是每隔一段时间更新一次CPU统计信息。 重置"CPUPROFILE_FREQUENCY"或"CPUPROFILE_REALTIME"值可以更改此间隔时间。

最新更新