gprof:function' etext'正在运行100.05%的时间

时间:2018-01-10 15:48:17

标签: c gprof

我使用gprof来获取运行速度太慢的c代码的配置文件。这是我得到的:

Flat profile:
Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  Ts/call  Ts/call  name    
100.05      0.16     0.16                             etext
  0.00      0.16     0.00    90993     0.00     0.00  Nel_wind
  0.00      0.16     0.00    27344     0.00     0.00  calc_crab_dens
  0.00      0.16     0.00    17472     0.00     0.00  Nel_radio
  0.00      0.16     0.00     1786     0.00     0.00  sync
  0.00      0.16     0.00        1     0.00     0.00  _fini
  0.00      0.16     0.00        1     0.00     0.00  calc_ele
  0.00      0.16     0.00        1     0.00     0.00  ic
  0.00      0.16     0.00        1     0.00     0.00  initialize
  0.00      0.16     0.00        1     0.00     0.00  make_table

我不知道" etext"意思是为什么它需要100.05%的时间运行。谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

我遇到了类似的问题,这是由于我使用其他可执行文件调用gprof造成的。

发生事故是因为我正在使用不同的选项重新编译,并且在由不同的可执行文件生成的两个不同的gprof文件上天真地调用了具有相同可执行文件名的gmon.out

gprof exec1 exec1.gmon.out # Good, expected output
gprof exec1 exec2.gmon.out # Weird etext function with 0 calls, but lots of time consumed

确保您没有做类似的事情。