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

标签 c++ profiler gperftools

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

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

  1. 安装 gperftools tar -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/

相关文章:

c++ - 在 Mac OS X 上使用 gperftools 的问题

c++ - 使用 gperftools/Heaptrack 无需安装

javascript - 如何让 Firebug 分析器将函数显示为非匿名

c++ - 仅分析我需要使用 VS2010 的命名空间

c++ - 寻找一个免费的 C++ 时间采样分析器

c++ - _L_unlock_16的性能瓶颈

c++ - gdb 继续而不是步进

C++ - || 如何运算符(operator)工作?

c++ - 在 C++ 中销毁动态分配的内存(数组对象)

c++ - 根据平台目标修改 OriginalFilename 字符串