3

我一直在 Linux(Ubuntu 11.04)和 Windows(7,MinGW 的最新版本)上使用 gprof 分析程序,每次在或多或少相同的数据集上使用相同的程序,并获得明显不同的结果。(很明显,它们会导致关于代码的哪些部分需要优化的不同结论。)

两个系统上的结果可能会合法地不同,但我还必须考虑一个结果集不准确并且应该被忽略的可能性,并且先验结果集更有可能是 MinGW,因为 gprof 的测试较少Windows 比在 Linux 上。该结论的一个更有力的论据是 Windows 上的结果看起来非常奇怪:

  %   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

有很多空白,然后initparse,这是一个初始化函数,只调用一次,几乎什么都不调用,据报道已被调用了 1.45 亿次。

我是否应该忽略 Windows 的结果而只使用 Linux 的结果?或者在 Windows 上报告不影响时间百分比结果的呼叫次数是否存在问题?还是我误读了输出或以其他方式滥用了该工具?

4

0 回答 0