***** infoCopter.com/perl *****
BenchmarkThe Benchmark module encapsulates a number of routines to help you figure out how long it takes to execute some code.
timethis - run a chunk of code several times
#!/usr/bin/perl -w
use strict;
use Benchmark;
my $count = 3;
my $t = timeit($count, \&mysub);
print "$count loops of code took:", timestr($t), "\n";
sub mysub () {
my $j = 0;
for (my $i = 0; $i < 1000000; $i++) {
$j++;
}
}
Output...3 loops of code took: 2 wallclock secs ( 2.87 usr + 0.00 sys = 2.87 CPU) @ 1.05/s (n=3) |