in reply to Profiling/Benchmarking web applications

I routinely use this little script to emulate webapps running under Apache::Registry. It evals another perl source file as a subroutine and then calls it many times. This is exactly what Apache::Registry does to all scripts for which it is configured to be a PerlHandler.

#! /usr/bin/perl -w use strict; use File::Slurp; use lib '/site/perl'; @ARGV >= 2 or die "Args: <perl program> <rep count> ...\n"; my $victim = read_file(shift @ARGV); eval " sub victim { " . $victim . " } "; open STDOUT, ">", "/dev/null"; open STDERR, ">", "/dev/null"; victim() for 1 .. shift @ARGV;

This approach works best with CGI.pm enabled scripts so I can pass query-params on the command line. I use the above script (called profile.pl) this way:

perl -d:Profile tools/profile.pl mail.cgi 500 mode=mailbox mbox=INBOX +page=4 sort=vSUBJ

So I run 500 iterations of one of my most intensive code paths under Devel::Profile (alas, Devel::DProf breaks Unicode::String in a very weird way). Try it.

Btw, I use HTML::Template and it needs lots of CPU time. I was very surprised to find my most annoying bottleneck in output page generation.