Next | Making Programs Faster | 25 |
Wallclock time is measured by Perl's built-in time() function:
use LWP::Simple 'get'; my $url= shift; my $start = time(); my $doc = get($url); my $elapsed = time() - $start; print "$elapsed second(s) elapsed.\n";
2 second(s) elapsed.
It returns the amount of time that has elapsed since the beginning of 1970
By default, the resolution of time is only one second
Related: $^T variable contains the time at which the program started
print "Program has been running for ", time() - $^T, " second(s).\n";
Next | Copyright © 2003 M. J. Dominus |