Time Sampling Problems with gprof

会有一股神秘感。 提交于 2019-12-19 22:26:07

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3603249/time-sampling-problems-with-gprof

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!