简体   繁体   English

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

[英]i have installed gperftools-2.0, but i can't get cpu profile statistics

i have installed gperftools-2.0, but i can't get cpu profile statistics 我已经安装了gperftools-2.0,但是我无法获取CPU配置文件统计信息

following is my steps to get the statistics: 以下是我获取统计信息的步骤:

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

2.edit cpp file test.cpp 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. compile g++ test.cpp -o test -O0 -I/usr/local/include/ -L/usr/local/lib/ -lprofiler 编译g ++ test.cpp -o test -O0 -I / usr / local / include / -L / usr / local / lib / -lprofiler

  2. run ./test 运行./test

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

whose output is: Using local file ./test. 其输出是:使用本地文件./test。 Using local file test.prof. 使用本地文件test.prof。

what's wrong in my steps? 我的步骤有什么问题?

You just need your program run a little longer time, As the Google profiler just update the CPU statistics info every interval time. 您只需要让程序运行更长的时间即可,因为Google探查器只会每隔一段时间更新一次CPU统计信息。 Reset the "CPUPROFILE_FREQUENCY" or "CPUPROFILE_REALTIME" value can change this interval time. 重置“ CPUPROFILE_FREQUENCY”或“ CPUPROFILE_REALTIME”值可以更改此间隔时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM