gprof的时间采样问题

时间:2010-08-30 18:45:52

标签: c++ windows profiling gprof

我试图使用gprof来描述一些用g ++编译的c ++代码,包括选项-pg。但是,尽管程序在我的计算机上运行需要10-15分钟(CPU最大化),但gprof生成的表的%time,累积秒和自秒列完全是0.00s! calls列包含正确的查看数据,例如对基本函数的超过150,000次调用。以下是收集数据的示例:

  %   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)

程序不使用字符串,唯一的#include是iostream(仅用于输出最终答案)所以它不会因为字符串查找和比较或其他类似的慢外部函数而变慢:unable to accumulate time using gprof - the gnu profiler

程序本身退出正常,我没有理由相信配置文件数据没有正确写入(如此处所示:gprof reports no time accumulated

由于这一切都是在Windows 7中完成的,因此尝试使用Shark或Valgrind不是一种选择。

是否有理由在每个功能中记录0.00s?

1 个答案:

答案 0 :(得分:3)

gprof 不计算任何阻止时间,例如I / O或其他内容。此外,“自我时间”通常在任何在子功能中完成所有工作的例程中都非常小,例如,如果您主要在DLL中使用gprof无法看到它的库。 Check this answer.