0

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

following is my steps to get the statistics:

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

2.edit cpp file 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

  2. run ./test

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

whose output is: Using local file ./test. Using local file test.prof.

what's wrong in my steps?

Jean Davy
  • 2,062
  • 1
  • 19
  • 24

1 Answers1

1

You just need your program run a little longer time, As the Google profiler just update the CPU statistics info every interval time. Reset the "CPUPROFILE_FREQUENCY" or "CPUPROFILE_REALTIME" value can change this interval time.

plus_wu
  • 11
  • 4