views:

56

answers:

1

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 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: http://stackoverflow.com/questions/1287728/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: http://stackoverflow.com/questions/1030829/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?

A: 

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.

Mike Dunlavey
Blocked time doesn't cause the CPU to be maxed out either (per the OP).
Mark B
@Mark: Right, which is why I added the second sentence.
Mike Dunlavey