Benchmark
The Benchmark module encapsulates a number of routines to help you figure out how long it takes to execute some code.
|
|
[ home ]
-
[ search ]
-
[ sitemap ]
timethis - run a chunk of code several times
timethese - run several chunks of code several times
cmpthese - print results of timethese as a comparison chart
timeit - run a chunk of code and see how long it goes
countit - see how many times a chunk of code runs in a given time
#!/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)
|