问题标签 [gprof]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
707 浏览

performance - 测量选定循环的执行时间

我想测量 C 程序中选定循环的运行时间,以便查看在这些循环中花费了执行程序(在 linux 上)的总时间的百分比。我应该能够指定应该测量性能的循环。在过去的几天里,我尝试了几种工具(vtune、hpctoolkit、oprofile),但似乎都没有。他们都发现了性能瓶颈,并只是展示了那些时间。那是因为这些工具只存储高于阈值(~1ms)的时间。因此,如果一个循环花费的时间少于此时间,则不会报告其执行时间。

gprof 的基本块计数功能取决于旧编译器中现在不支持的功能。

我可以手动编写一个简单的计时器使用gettimeofday或类似的东西,但在某些情况下它不会给出准确的结果。例如:

现在在这里我想测量花费在内部循环中的总时间,我必须gettimeofday在第一个循环中调用。所以gettimeofday它自己会被调用 1000 次,这会引入自己的开销,结果会不准确。

0 投票
1 回答
12449 浏览

profiling - 在 g++ 中为 gprof 编译

我不了解 gprof 关于如何编译程序以使用 gprof 进行分析的文档。在g ++中,是否需要在-g选项之外使用选项(调试信息)进行编译-pg。在每种情况下,我都会得到不同的结果,我想看看我的应用程序中的瓶颈在哪里,而不是在调试模式下,编译器忽略了许多优化(例如内联)

0 投票
1 回答
311 浏览

c++ - 为什么 gprof 告诉我一个只从 main() 调用一次的函数被调用了 102 次?

我是一个初学者,为了好玩而编写了以下程序,以搜索目录并将每个出现的单词替换为另一个单词。我调用了一次 crt_ls_file() 函数,而且只调用了一次,但 gprof 告诉我它被调用了 102 次。我想知道是否有人知道这是为什么。我已经尝试编译程序将所有并且没有优化。

0 投票
5 回答
3380 浏览

c++ - 让 gprof 根据挂钟时间进行分析?

我的理解是,默认情况下 gprof 会考虑 CPU 时间。有没有办法让它根据挂钟时间进行配置?

我的程序做了很多磁盘 i/o,所以它使用的 CPU 时间只代表实际执行时间的一小部分。我需要知道磁盘 i/o 的哪些部分占用的时间最多。

0 投票
4 回答
3725 浏览

linux - Why does my code run slower with multiple threads than with a single thread when it is compiled for profiling (-pg)?

I'm writing a ray tracer.

Recently, I added threading to the program to exploit the additional cores on my i5 Quad Core.

In a weird turn of events the debug version of the application is now running slower, but the optimized build is running faster than before I added threading.

I'm passing the "-g -pg" flags to gcc for the debug build and the "-O3" flag for the optimized build.

Host system: Ubuntu Linux 10.4 AMD64.

I know that debug symbols add significant overhead to the program, but the relative performance has always been maintained. I.e. a faster algorithm will always run faster in both debug and optimization builds.

Any idea why I'm seeing this behavior?

Debug version is compiled with "-g3 -pg". Optimized version with "-O3".

This convinces me that "-g3" is not to blame for the odd performance delta, but that it's rather the "-pg" switch. It's likely that the "-pg" option adds some sort of locking mechanism to measure thread performance.

Since "-pg" is broken on threaded applications anyway, I'll just remove it.

0 投票
1 回答
461 浏览

gcc - 如何从 gprof 输出中排除内容?

我正在尝试分析我拥有的应用程序,但我不希望与 UI(在 wxWidgets 中制作)相关的任何内容出现在 gprof 的调用图中等。我该怎么做?

0 投票
2 回答
1389 浏览

c++ - 将 gprof 与套接字一起使用

我有一个程序我想用 gprof 分析。问题(似乎)是它使用套接字。所以我得到这样的东西:

我不久前遇到了这个问题,放弃了,然后继续前进。但我真的希望能够分析我的代码,如果可能的话使用 gprof。我能做些什么?我缺少 gprof 选项吗?插座选项?在存在这些类型的系统调用的情况下,gprof 完全没用吗?如果是这样,是否有可行的替代方案?

编辑:平台:

  • Linux 2.6 (x64)
  • GCC 4.4.1
  • gprof 2.19
0 投票
3 回答
147 浏览

c++ - 奇怪的分析器行为:相同的功能,不同的性能

我正在学习使用 gprof,然后我得到了这段代码的奇怪结果:

这是探查器输出

如果我调用一个然后两个结果是相反的,两个比一个花费更多时间
两者都是相同的功能,但是第一个调用总是比第二个花费更少的时间

这是为什么?

注意:汇编代码完全相同,并且代码正在编译,没有优化

0 投票
1 回答
411 浏览

c++ - C++ main 只使用约 20% 的时间说 gprof

我尝试使用 gprof 分析我的 C++ 程序。程序本身运行了大约 53 秒,所以我不明白为什么它说,main 只运行了大约 8.29 秒。对此有何解释?

这是一段摘录:

0 投票
1 回答
322 浏览

c++ - gprof 关于雪豹问题

问题在于 gmon.out 文件没有显示正确的数据。所有时间都是 0,没有任何东西被测量。gmon.out 文件通常会生成。我正在使用 eclipse ide for c++,并正常链接、编译和运行程序。

有什么帮助吗?