gprof 的时间采样问题
我正在尝试使用 gprof 分析一些用 g++ 编译的 C++ 代码,包括选项 -pg。然而,尽管该程序在我的计算机上运行需要 10-15 分钟(CPU 已满),但 gprof 生成的表中的 % time、cumulative Seconds 和 self Second 列完全是 0.00s!调用列包含看起来正确的数据,例如对基本函数的超过 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(仅用于输出最终答案),因此它不会因为字符串查找和比较或其他类似的慢速外部而变慢按照这个问题中建议的功能: 无法使用 gprof 累积时间 - gnu profiler
程序本身退出正常,我没有理由相信配置文件数据没有正确写入(正如这里所建议的:gprof 报告没有时间累积)
由于这一切都是在 Windows 7 中完成的,因此尝试使用 Shark 或 Valgrind 不是一个选择。
是否有原因记录每个函数花费了 0.00 秒?
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)
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)
As this is all being done in windows 7, trying to use Shark or Valgrind isn't an option.
Is there a reason that it is recording 0.00s being spent in each function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.