Showing a page process time in the page footer is a common thing in many sites, some sites even take it forward by showing DB query time and processing time separately.

In this tip, we'll see how to show page process time in perl. For this purpose we'll require the perl module Time::HiRes (CPAN).

Installing Time::HiRes

You can either download the source from CPAN and then install it manually or you can use the cpan shell module to install Time::HiRes.

Code:

$cpan
$cpan> install Time::HiRes

The Code

In array context gettimeofday() returns a two-element array with the seconds and microseconds since the epoch. Returns the floating seconds between the two times, which should have been returned by gettimeofday() . If the second argument is omitted, then the current time is used.