[cgiapp] Debugging Performance with CGI::Application Using Firebug and Time::HiRes

Rhesa Rozendaal perl at rhesa.com
Thu Dec 30 14:21:45 EST 2010


On 12/30/2010 03:49 PM, Andy Daykin wrote:
> I have been trying to find where the performance issues in my code are
> coming from, but there is time that is unaccounted for when I have been
> trying to debug a sites performance written with CGI::Application.

These are the main steps that take time:

1. establish connection with web server
2. send request
3. web server runs your app
4. your app generates the response
5. receive response

Your code below only measures step 4, so if you find that that does not 
account for the bulk of the time, then it must be in one of the other steps.

As a start, I would run

   time page.cgi

This will show you the combined time of steps 3 and 4 (I'm assuming 
you're not using mod_perl or fcgi or some other persistence framework). 
This will include the time it takes to load all of the modules your 
MyPage module uses, and all the modules they depend on in turn. If you 
have a lot of dependencies, or expensive things to set up (database 
connections, connections to other types of servers, etc), this may be 
the most time-consuming part.

If that doesn't account for the bulk of the time, then it looks like the 
network i/o is the bottleneck. I believe firebug tells you the times for 
connect, send, and receive, so you should already have seen this (and 
since you say you're on a LAN, this is unlikely to be the bottleneck).

If the bottleneck is in fact in the execution of your cgi script, then 
I'd profile it with Devel::NYTProf to find out what the hot spots are. 
The next thing I'd grab for would be mod_perl. The third step would be 
making sure that as much of the expensive setup is done only once per 
mod_perl process.

HTH,
Rhesa


More information about the cgiapp mailing list