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.


In reply to Re: Profiling/Benchmarking web applications by kappa
in thread Profiling/Benchmarking web applications by jryan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.