DelphiFAQ Home Search:
General :: Programming :: perl
General questions about perl.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

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


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>';

Generated 12:01:44 on Oct 26, 2020