在 gprof 中分析单个函数
是否可以使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可以通过 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.
尝试使用 [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.
您是否正在寻找可疑的性能问题? 如果你对它在哪里有先入之见,那么它很可能不在那里。 如果您确实想找到性能问题,首先您可能需要超越一些由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.