我如何分析我的 Perl 程序? [英] How do I profile my Perl programs?

查看:18
本文介绍了我如何分析我的 Perl 程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要提高 Perl 应用程序的性能.如何找到慢点?

I need to improve the performance of my Perl application. How can I find the slow spots?

这是来自官方 perlfaq 的问题.我们将 perlfaq 导入 Stack Overflow..>

This is a question from the official perlfaq. We're importing the perlfaq to Stack Overflow.

推荐答案

(这是 perlfaq 官方回答, 减去任何后续编辑)

(This is the official perlfaq answer, minus any subsequent edits)

Devel 命名空间有几个模块,您可以使用它们配置您的 Perl 程序.Devel::DProf 模块与 Perl 一起提供,您可以使用 -d 开关:

The Devel namespace has several modules which you can use to profile your Perl programs. The Devel::DProf module comes with Perl and you can invoke it with the -d switch:

$ perl -d:DProf program.pl

DProf 下运行你的程序后,你会得到一个 tmon.out 文件与配置文件数据.要查看数据,您可以将其转换为带有 dprofpp 程序的人类可读报告Devel::DProf:

After running your program under DProf, you'll get a tmon.out file with the profile data. To look at the data, you can turn it into a human-readable report with the dprofpp program that comes with Devel::DProf:

$ dprofpp

您还可以使用 -p 一步完成分析和报告切换到dprofpp:

You can also do the profiling and reporting in one step with the -p switch to dprofpp:

$ dprofpp -p program.pl

Devel::NYTProf(纽约时报分析器)进行语句和子程序分析.它可以从 CPAN 获得,你也可以调用使用 -d 开关:

The Devel::NYTProf (New York Times Profiler) does both statement and subroutine profiling. It's available from CPAN and you also invoke it with the -d switch:

$ perl -d:NYTProf some_perl.pl

DProf 一样,它会创建一个数据库,其中包含您要使用的个人资料信息可以变成报告.nytprofhtml 命令将数据转换为类似于 Devel::Cover 报告的 HTML 报告:

Like DProf, it creates a database of the profile information that you can turn into reports. The nytprofhtml command turns the data into an HTML report similar to the Devel::Cover report:

$ nytprofhtml

CPAN 有几个其他的分析器,你可以在同一个时尚.您可能还对使用 C 感兴趣衡量和比较代码片段.

CPAN has several other profilers that you can invoke in the same fashion. You might also be interested in using the C to measure and compare code snippets.

您可以在 Programming Perl,第 20 章中阅读有关分析的更多信息或精通 Perl,第 5 章.

You can read more about profiling in Programming Perl, chapter 20, or Mastering Perl, chapter 5.

perldebguts 文档创建自定义调试器(如果您需要)创建一种特殊的分析器.brian d foy 描述了这个过程在 Perl Journal创建 Perl 调试器"在 Perl 中进行分析".

perldebguts documents creating a custom debugger if you need to create a special sort of profiler. brian d foy describes the process in The Perl Journal, "Creating a Perl Debugger", and "Profiling in Perl".

Perl.com 有两篇关于分析的有趣文章:"Profiling Perl",由 Simon Cozens 和 "调试和分析 mod_perl 应用程序",作者 Frank Wiles.

Perl.com has two interesting articles on profiling: "Profiling Perl", by Simon Cozens, and "Debugging and Profiling mod_perl Applications", by Frank Wiles.

Randal L. Schwartz 在加速你的 PerlPrograms" 用于 Unix Review"Profiling在 Template Toolkit via Overriding 中" for Linux Magazine.

Randal L. Schwartz writes about profiling in "Speeding up Your Perl Programs" for Unix Review and "Profiling in Template Toolkit via Overriding" for Linux Magazine.

这篇关于我如何分析我的 Perl 程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆