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

查看:51
本文介绍了如何配置我的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描述了该过程 在 The Perl Journal 创建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上有两篇有关概要分析的有趣文章:概要分析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在加速您的Perl中 用于 Unix评论分析的程序" 通过 Linux杂志通过覆盖"在Template Toolkit中使用.

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天全站免登陆