[cgiapp] Debugging Performance with CGI::Application Using Firebug and Time::HiRes
daykinandy at gmail.com
Thu Dec 30 09:49:41 EST 2010
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.
When I request a page I use the firebug plugin for firefox to tell me the
number of seconds I wait for the page to respond after submitting the page
request. I can see the time by viewing the purple bar in the net panel. I am
getting back ~6 seconds every time I load the page, but according to my time
profiler I have below the code is only taking ~1 second. I know the network
is not accounting for the other 5 seconds, since when I load the same page
no CGI::Application the page only takes ~1 second to load. (Also, the site
is hosted on an IP on a LAN I am on).
To measure the performance below I am loading my home page and using the
Time::HiRes module. and getting the time when the page is called by
http://hostname/page.cgi and checking the time again when the MyPage module
(which inherits from a module called Base.pm) is done running. I am using a
lot of the same code for the Base.pm CGI module from this tutorial
I have tried placing the time markers within my module MyPage.pm and Base.pm
but I am getting results that confirm the tests I mentioned above.
Does anyone have any ideas on how else to find the performance bottleneck? I
have a feeling that my benchmark below is not accurate for some reason.
Here is the code I am using to do the benchmarking:
use Time::HiRes qw/gettimeofday/;
my $s1 = gettimeofday();
my $m1 = int($s1*1000);
my $PRIVATE_HOME_DIR = '/app_path';
use lib qw ( /app_path/modules );
use CGI::Carp qw(fatalsToBrowser);
TMPL_PATH => $PRIVATE_HOME_DIR.'/templates'
my $s2 = gettimeofday();
my $m2 = int($s2*1000);
my $diff = $m2 - $m1;
die("main the code took: $diff");
More information about the cgiapp