This will not tell you what you want to know. The answer to which is about 20-40 times faster when you use mod_perl. You will get even more benefit if your scripts are connecting/disconnecting from a DB every call.

When you call a CGI the first thing that happens is that the system has to start a new process ie it forks a perl binary. Once that is started your script is passed to it for compilation/execution. AFAIK perl sets $^T (not apache) so any number you get will be in a word - crap. The big overhead is forking the new perl - see Apache::PerlRun link below which essentially just gives you a persistent perl with the code recompiled on every call. This alone will give you 10x speed improvement on average.

What you want is ab (apache benchmark, part of the apache distro). Set up a modperl environment. It is well documented and works smoothly. Put the same script into /cgi-bin and /modperl. Run ab. Read it and weep.

You can run some pretty crap code using mod_perl with Apache::PerlRun which gives you a good chunk of mod_perl speed (ie persistent perl with no fork a new perl per call) but does not cache the code. In English this will turn dirty CGIs into dirty mod_perl widgets and get you 10x on speed with remarkably few, if any issues.

cheers

tachyon


In reply to Re: measuring startup time: how early does $^T (start time of program) get set? by tachyon
in thread measuring startup time: how early does $^T (start time of program) get set? by blahblahblah

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.