哪个分析器更准确:OProfile 还是 Google Performance Tools?
I found two great profilers:
Have anyone tried them both? Which is better?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
I found two great profilers:
Have anyone tried them both? Which is better?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
oprofile更准确;它使用CPU性能监控(内置硬件监控,具有100个性能事件);
并且 google-perftools libprofiler.so 使用
setitimer
- 操作系统内核的 intreval 计时器:间隔计时器由操作系统模拟,并且不能超过
HZ
,据我所知(每秒 100 次或每秒 1000 次或 300 或 250)。我刚刚尝试了 10000 和 100000,但有效率为 1000(程序运行时间为 2 秒,并且 cpu profiler 从 google 收集到的样本只有约 2000 个)。这是我的 HZ:不知道这在无滴答内核上如何工作。
反过来,oprofile 使用 CPU 中的特殊硬件,该硬件的精确度可达几个刻度。它可以在 CPU 每 100000 次或 1000000 次滴答时测量程序的位置,并且该值与操作系统 HZ 设置无关。此外,它不仅可以分析 CPU 的每个 N 个周期,还可以分析每个 N 个 L2 缓存未命中或每个 N 个
jmp
错误预测等等......有数百个硬件Pentium Pro 之后的任何 CPU 中的性能事件。oprofile 的另一个更好的方面是它可以分析任何内容,任何用户应用程序或所有用户应用程序或内核和每个应用程序。
但是 oprofile 需要 root 才能使用它(AFAIK),如果使用错误,它可能会冻结您的系统;它需要在内核中启用(当内核构建时)。
google-perftools 更好的一面是:易于使用;良好的绘图和分析能力;无需 root 即可工作。另外,google-perftools 中有一个很好的堆分析器。
oprofile 和 google-perftools/cpuprofiler:
callgrind
命令进行绘制)oprofile is more accurate; it uses CPU performance monitoring (built in hardware monitoring with 100s of performance events);
and google-perftools libprofiler.so uses
setitimer
- intreval timer of OS kernel:Interval timer is emulated by OS and it can't be more than
HZ
, as I know (100 times per second or 1000 times per second or 300 or 250). I just tried both 10000 and 100000, but the effective rate was 1000 (run time of program is 2 seconds and there is only ~2000 samples collected by cpu profiler from google). This is my HZ:Don't know how this will work on tickless kernel.
In turn, oprofile uses special hardware in CPU and this hardware is accurate up to several ticks. It can measure, where your program is, at every 100000th or 1000000th ticks of CPU and this value is not tied to OS HZ setting. Also it can profile not only on every N-th tick of CPU, but also on every N-th L2 cache miss or every N-th
jmp
misprediction and so on... there are hundreds of hardware performance events in any CPU after Pentium Pro.The other better side of oprofile is that it can profile anything, any user application or all user application or kernel and every application.
But oprofile requires root to use it (AFAIK), it can freeze you system with wrong usage; it needs to be enabled in kernel (when kernel was built).
Better side of google-perftools is: easy to use; good graphing and analysing capabilities; need no root to work. Also, there is a good heap profiler in google-perftools.
Both oprofile and google-perftools/cpuprofiler:
callgrind
command )