Apache::Registry PerlHandler Versus Custom PerlHandler
Apache::args Versus Apache::Request::param Versus CGI::param
Buffered Printing and Better print( ) Techniques
Interpolation, Concatenation, or List
Keeping a Small Memory Footprint
Object Methods Calls Versus Function Calls
Using the Perl stat( ) Call's Cached Results
time( ) System Call Versus $r->request_time
Printing Unmodified Files
Caching and Pre-Caching
Caching with Memoize
Comparing Runtime Performance of Perl and C

TMTOWTDI (sometimes pronounced "tim toady"), an acronym for "There's More Than One Way To Do It," is the main motto of Perl. In other words, you can reach the same goal (usually a working product) by coding in many different styles, using different modules and deploying the same modules in different ways.

However, when you come to the point where performance is the goal, you might have to learn what's efficient and what's not. This may mean that you will have to use an approach that you don't really like, that's less convenient, or that requires changing your coding habits.

This section is about performance trade-offs. For almost every comparison, we will provide the theoretical difference and then run benchmarks to support the theory. No matter how good the theory is, it's the numbers we get in practice that matter.

We also would like to mention that the code snippets used in the benchmarks are meant to demonstrate the points we are making and are intended to be as short and easy to understand as possible, rather than being real-world examples.

In the following benchmarks, unless stated differently, mod_perl is tested directly, and the following Apache configuration has been used:

MinSpareServers 10
MaxSpareServers 20
StartServers 10
MaxClients 20
MaxRequestsPerChild 10000