Problems with time sampling using gprof

I am trying to profile some C ++ code compiled with g ++, including the -pg option, with gprof. However, despite the fact that the program takes 10-15 minutes to work on my computer (with a maximum maximum of CPU), the% time, cumulative seconds and own seconds columns of the table created by gprof are only 0.00 s! The call column contains the correct data, for example, more than 150,000 calls to the base function. Here is an example 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 does not use strings, and the only #include is iostream (used only to output the final answer), so it cannot be slow due to string finds and comparisons or other similar slow external functions, as suggested in this question: could not be accumulated time using gprof - gnu profiler

The program itself crashes, and I have no reason to believe that the profile data is not written correctly (as suggested here: gprof reports that time does not accumulate )

As all of this is done in Windows 7, trying to use Shark or Valgrind is not an option.

Is there a reason why each function records 0.00s?

+4
source share
1 answer

gprof does not take into account blocking times, such as I / O or something else. In addition, "self time" is usually extremely small in any routine that does all its work in subfunctions, for example, if you mostly use a library in a DLL where gprof does not see it. Check out this answer.

+3
source

All Articles