我需要测试Perl应用程序(文件操作,数据库操作等)。 我正在寻找一些针对Perl代码的性能分析工具。
是否有类似于Linux中的gprof的Perl代码性能分析工具?
有些人可能会建议使用Devel::DProf作为最标准的方法,但如果你仔细看一下,它实际上是一个相当糟糕的解决方案。
现在Perl的最佳分析器是Devel::NYTProf。
如果你在谷歌上搜索它,你会看到一些演示,展示它的能力。而且它的功能非常强大。
Krish: 在你发问题之前,你应该至少查看基本文档。一个寻找东西的方法是使用perldoc -q <something>
。 -q
标志将通过FAQ进行关键字搜索。
因此,例如,perldoc -q profile
:
Found in /usr/local/lib/perl5/5.10.0/pod/perlfaq3.pod
How do I profile my Perl programs?
You should get the Devel::DProf module from the standard distribution
(or separately on CPAN) and also use Benchmark.pm from the standard
distribution. The Benchmark module lets you time specific portions of
your code, while Devel::DProf gives detailed breakdowns of where your
code spends its time.
与调试类似,性能分析最好由perl解释器本身完成。
这个网站将为您提供使用-d:DProf
参数进行解释器性能分析以及如何使用它的概述。