Profiling Perl
As we write this, Perl comes with a profiler called Devel::DProf. However, by the time you read this, it might be gone. Perl
v5.16, which is scheduled for release around the same time this book hits
the shelves, removes this old profiler. Most people using a profiler have
moved on to another profiler, Devel::NYTProf. We’ll tell you about Devel::DProf since it’s still in Perl, but we’ll
also tell you about the new one, which doesn’t come with Perl.
These profilers are not lightweight, and they aren’t your only
options for a profiler. CPAN also holds Devel::SmallProf, which reports the time spent in each line of your program.
That can help you figure out if you’re using some particular Perl
construct that is being surprisingly expensive. Most of the built-in
functions are pretty efficient, but it’s easy to accidentally write a
regular expression whose overhead increases exponentially with the size of
the input. See also the section Efficiency in Chapter 21 for other helpful hints.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access