简体   繁体   English

如何在没有重建的情况下在Linux平台上分析程序?

[英]How to profile program on Linux platform without rebuilding?

I've used two profiling tools (VTune on windows and dbx (within sunstudio) on Solaris) which can profile program without rebuild them, and during profiling, the program just run at the same speed as normal. 我已经使用了两个分析工具(Solaris上的VTune和Solaris上的dbx(在sunstudio中)),它可以在不重建它们的情况下对程序进行分析,在分析过程中,程序只能以与正常相同的速度运行。 Both of these 2 features saved me a lot of time. 这两个功能都为我节省了很多时间。

Now I want to know if there is some free tools available on Linux platform can do the same thing. 现在我想知道Linux平台上是否有一些免费工具可以做同样的事情。 I think I need profiling tools based on sampling. 我想我需要基于抽样的分析工具。 VTune is good but expensive ... I've heard of gprof and valgrind. VTune很好但价格昂贵......我听说过gprof和valgrind。 But seems gprof need instrument the program (so we have to rebuild the program) and valgrind will slow down the program execution quite a lot. 但似乎gprof需要对程序进行检测(因此我们必须重建程序)并且valgrind将会大大减慢程序执行速度。 (from valgrind's introduction, Cachegrind runs programs about 20--100x slower than normal, and Callgrind which I need to profiling is based on Cachegrind) (来自valgrind的介绍,Cachegrind运行程序比正常情况慢20到100倍,而我需要分析的Callgrind基于Cachegrind)

For profiling, I just need to figure out the execution time of function calls so I can find out where the performance degradation happens. 对于分析,我只需要弄清楚函数调用的执行时间,这样我就可以找出性能下降的位置。 Actually I don't need many low level profiling information as Cachegrind provided... 实际上我不需要很多低级分析信息,因为Cachegrind提供了......

oprofile is pretty good, but it can be difficult to set up. oprofile非常好,但设置起来可能很困难。 It also doesn't require you to rebuild your program. 它也不需要您重建您的程序。

Agreeing with Paul, I think Zoom is probably the best Linux profiler you can pay for. 与Paul保持一致,我认为Zoom可能是您可以支付的最佳Linux分析器。

However, for real results , I rely on this simple method , that I've been using since before profilers were invented. 然而,对于真实的结果 ,我依赖于这种简单的方法 ,这是我在分析器发明之前就已经使用过的。

Performance Counters for Linux is a new tool usable on kernels 2.6.31 and later; Linux的性能计数器是一个可用于内核2.6.31及更高版本的新工具; it's less intrusive (to both the program and the system as a whole) than valgrind or OProfile. 与valgrind或OProfile相比,它对程序和整个系统的侵扰性较小。

A nicer option than oprofile is Zoom . Zoom是一个比oprofile更好的选择。 It's similar to Shark on Mac OS X, if you have ever used that. 它与Mac OS X上的Shark类似,如果您曾经使用过它。 It's commercial ($199) but you can get a free trial from www.rotateright.com . 这是商业(199美元),但您可以从www.rotateright.com获得免费试用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM