MinGW gprof inaccurate results?

1.1k Views Asked by At

I've been profiling a program with gprof on Linux (Ubuntu 11.04) and Windows (7, latest version of MinGW), same program on more or less the same dataset each time, and getting significantly different results. (Significantly as in they would lead to different conclusions about what part of the code needs optimizing.)

It's possible that the results could be legitimately different on the two systems, but I also have to consider the possibility that one result set is inaccurate and should be ignored, and a priori the more likely one would be MinGW as gprof is less extensively tested on Windows than on Linux. A stronger argument for that conclusion is that the results on Windows look distinctly weird:

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  us/call  us/call  name    
 27.43      1.13     1.13 68589813     0.02     0.02  addt
 21.48      2.02     0.89                             tok
 19.17      2.81     0.79                             hash
  9.95      3.21     0.41                             slot
  7.89      3.54     0.33                             nextx
  4.85      3.74     0.20                             next
  3.52      3.88     0.14 27809047     0.01     0.01  get
  0.85      3.92     0.04                             eol
  0.73      3.95     0.03                             __mingw_pformat
  0.73      3.98     0.03                             ch
  0.73      4.01     0.03                             tokx
  0.49      4.03     0.02                             slot
  0.49      4.05     0.02                             tok
  0.24      4.06     0.01   166896     0.06     0.06  mk2
  0.24      4.07     0.01     6693     1.49     1.49  initt
  0.24      4.08     0.01                             __pformat_putchars
  0.24      4.09     0.01                             hashs
  0.24      4.10     0.01                             pop
  0.24      4.11     0.01                             quoted
  0.12      4.12     0.01                             eat
  0.12      4.12     0.01                             expand
  0.00      4.12     0.00 145841014     0.00     0.00  initparse

There are a lot of gaps, and then initparse, which is an initialization function called only once that calls almost nothing else, is reported as having been called one hundred and forty-five million times.

Should I disregard the results from Windows and just use the ones from Linux? Or is there some issue with the reporting of number of calls on Windows that doesn't affect the percentage time results? Or am I misreading the output or otherwise misusing the tool?

0

There are 0 best solutions below