在 gprof 中分析单个函数

发布于 2024-07-30 09:51:12 字数 127 浏览 9 评论 0原文

是否可以使用 gprof 对 C++ 中的单个函数进行行分析?

类似:

gprof -l -F function_name ...

,这似乎不起作用。

Is it possible to use gprof to line-profile a single function in C++?

Something like:

gprof -l -F function_name ...

, which does not seem to work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我早已燃尽 2024-08-06 09:51:12

这可以通过 valgrind 轻松完成。 如果您有机会在您的开发环境中使用它,那么它是一个很棒的工具。 它甚至还有图形界面kcachegrind

That can be done easily with valgrind. It is a wonderful tool if you have the chance to use it in your development environment. It even have and graphical interface kcachegrind.

廻憶裏菂餘溫 2024-08-06 09:51:12

尝试使用 [symspec] 选项来过滤结果。 gprof 2.18.0 表示不推荐使用 -F-f 并使用 symspec 代替。

此外,-l 可能不适用于使用较新版本的 gcc 编译的二进制文件。 尝试使用 gcov 代替。

Try using options with [symspec] to filter the results. gprof 2.18.0 says that -F and -f are deprecated and to use symspec instead.

Also, -l may not work with binaries compiled with newer versions of gcc. Try gcov instead.

情仇皆在手 2024-08-06 09:51:12

您是否正在寻找可疑的性能问题? 如果你对它在哪里有先入之见,那么它很可能不在那里。 如果您确实想找到性能问题,首先您可能需要超越一些gprof延续的神话

Are you looking for a suspected performance problem? If you have a preconception of where it is, chances are it's not there. If you really want to find performance problems, first you may need to look beyond some myths perpetuated by gprof.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文