DelphiFAQ Home Search:

Measure how long it takes to generate a web page with perl


commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.


I'm in the process of optimizing my web site's backend (database) and want to display how long it actually takes to generate each page. All pages are generated with perl.


Use the Benchmark module as shown in the example. If you view a page and hit reload a few times, you'll find that the measured time will vary quite a bit but it will give you a rough estimate if adding that new index made any difference or not.

Obviously the network transfer time doesn't get added to the measured time which is exactly the way you need it.

use Benchmark;

my $start_bench = new Benchmark;

# .. generate the page

my $end_bench = new Benchmark;

# put out the time that it took to generate this page
# (at the bottom of the page, in this case)

print '<br><font size=1>Generation of this page took ';
print timestr(timediff($end_bench, $start_bench));
print '</font></body></html>';


2012-11-09, 19:12:07
bgbgbgbgb from China  
2012-11-12, 02:18:22
anonymous from United Kingdom  



NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: