gpt4 book ai didi

c++ - 我已经安装了 gperftools-2.0,但是我无法获取 cpu profile 统计信息

转载 作者:行者123 更新时间:2023-11-28 08:05:51 24 4
gpt4 key购买 nike

我已经安装了 gperftools-2.0,但是我无法获取 cpu profile 统计信息

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

  1. 安装 gperftoolstar -xzvfj gperftools-2.0.tar.gz

2.编辑cpp文件test.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 测试 -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”值可以更改此间隔时间。

关于c++ - 我已经安装了 gperftools-2.0,但是我无法获取 cpu profile 统计信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10313357/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com