Time Sampling Problems with gprof

I am attempting to profile some c++ code, compiled with g++ including the option -pg, using gprof. However, in spite of the fact that the program takes 10-15 minutes to run on my computer (with the CPU maxed out), the % time, cumulative seconds and self seconds columns of the table produced by gprof are entirely 0.00s! The calls column contains correct looking data, for example over 150,000 calls to a basic function. Here is a sample of the data collected:

  %   cumulative   self              self     total           

 time   seconds   seconds    calls  Ts/call  Ts/call  name

  0.00      0.00     0.00   156012     0.00     0.00  perm::operator[](int) const

  0.00      0.00     0.00   153476     0.00     0.00  perm::perm(void)

The program doesn't use strings and the only #include is iostream (only used for outputting the final answer) so it can't be slow because of string finds and compares or other similar slow external functions as suggested in this question: unable to accumulate time using gprof - the gnu profiler

The program itself exits fine and I have no reason to believe that the profile data isn't being written correctly (as was suggested here: gprof reports no time accumulated)

As this is all being done in windows 7, trying to use Shark or Valgrind isn't an option.

Is there a reason that it is recording 0.00s being spent in each function?


gprof doesn't count any blocked time, like I/O or other stuff. Also "self time" typically is extremely small in any routine that does all its work in subfunctions, like if you're mostly using a library in a DLL where gprof can't see it. Check this answer.

链接地址: http://www.djcxy.com/p/43860.html

上一篇: 了解solaris上gprof的输出

下一篇: 时间采样问题与gprof