问题描述
我正在尝试获取流程中各个功能的性能.我该如何使用perf工具呢?还有其他工具吗?
I am trying to get performance of individual functions within a process. How can I do it using perf tool? Is there any other tool for this?
例如,假设主函数调用函数A,B,C.我想分别获得主要功能以及功能A,B,C的性能.
For example, let's say, main function calls functions A , B , C . I want to get performance of main function as well as functions A,B,C individually .
是否有一个很好的文档来低估perf源代码?
Is there a good document for understating perf source code?
谢谢.
推荐答案
您要执行的是用户土地探测.Perf只能做一部分.尝试 sudo perf top -p [pid]
,然后查看记分板.它将显示按CPU使用率排序的功能列表.这是基准测试期间的redis的简短说明:
What you want to do is user-land probing. Perf can only do part of it.Try sudo perf top -p [pid]
and then watch the scoreboard. It will show the list of functions sorted by CPU usage. Here is an snapshort of redis during benchmark:
如果您想获取有关用户界面功能的更多信息,例如IO使用率,延迟,内存使用率,我强烈建议您使用Systemtap.它既是脚本语言,也是在基于Linux内核的操作系统上进行程序分析的工具.这是关于它的教程:
If you want to get more infos of your user-land functions, such as IO usage, latency, memory usage, I strongly suggest you to use Systemtap. It is both scripting language and tool for profiling program on Linux kernel-based operation system. Here is a tutorial about it:
http://qqibrow.github.io/performance-profiling-with-systemtap/
您无需成为systemtap脚本编写专家,就可以在线找到许多不错的脚本.例如,有一个有关使用它来查找特定功能的延迟的示例.
And you don't need to be a expert of systemtap scripting, there are many good script online for you.For example, there is an example about using it to find out the latency of specific function.
https://github.com/openresty/stapxx#func-latency-distr
这篇关于有没有一种方法可以使用perf工具查找流程中各个功能的性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!