gprof的时间采样问题 [英] Time Sampling Problems with gprof

查看:113
本文介绍了gprof的时间采样问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用gprof分析一些用g ++编译的c ++代码,包括-pg选项.但是,尽管该程序在我的计算机上运行需要10-15分钟(而CPU已用尽),但gprof生成的表的%时间,累积秒数和自秒数列完全是0.00s!调用列包含正确的外观数据,例如,对基本功能的150,000次调用.以下是收集的数据示例:

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[](int) const

  0.00      0.00     0.00   153476     0.00     0.00  perm::perm(void)

程序不使用字符串,唯一的#include是iostream(仅用于输出最终答案),因此它不会因为字符串查找和比较或其他类似的慢速外部函数而变慢,如本问题所示:无法使用gprof-gnu分析器来累积时间

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: 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: gprof reports no time accumulated)

由于这些都是在Windows 7中完成的,因此无法选择使用Shark或Valgrind.

As this is all being done in windows 7, trying to use Shark or Valgrind isn't an option.

是否有记录它在每个功能中花费0.00的原因?

Is there a reason that it is recording 0.00s being spent in each function?

推荐答案

gprof 不计算任何阻塞时间,例如I/O或其他内容.同样,在任何子功能中完成所有工作的例程中,自用时间"通常都非常小,例如,如果您主要使用的是DLL中的库,而gprof则看不到它. 选中此答案.

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.

这篇关于gprof的时间采样问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆