Benchmark-Perl-Formance
view release on metacpan or search on metacpan
lib/Benchmark/Perl/Formance/Plugin/Shootout/binarytrees.pm view on Meta::CPAN
my $stretch_depth = $max_depth + 1;
my $stretch_tree = bottom_up_tree($stretch_depth);
# print "stretch tree of depth $stretch_depth\t check: ",
# item_check($stretch_tree), "\n";
}
my $long_lived_tree = bottom_up_tree($max_depth);
my $depth = $min_depth;
while ( $depth <= $max_depth ) {
my $iterations = 2 ** ($max_depth - $depth + $min_depth);
my $check = 0;
foreach my $i (1..$iterations) {
my $temp_tree = bottom_up_tree($depth);
$check += item_check($temp_tree);
$temp_tree = bottom_up_tree($depth);
$check += item_check($temp_tree);
}
#print $iterations * 2, "\t trees of depth $depth\t check: ", $check, "\n";
$depth += 2;
}
# print "long lived tree of depth $max_depth\t check: ",
# item_check($long_lived_tree), "\n";
}
sub main
{
my ($options) = @_;
lib/Benchmark/Perl/Formance/Plugin/Skeleton.pm view on Meta::CPAN
use Benchmark ':hireswallclock';
our $goal;
our $count;
sub main {
my ($options) = @_;
$goal = $options->{fastmode} ? 2 : 10; # benchmark parameter that influences single run duration
$count = $options->{fastmode} ? 1 : 5; # run that many iterations
my $result;
my $t = timeit $count, sub {
# REAL CODE HERE
sleep $goal;
$result = 7;
};
return {
Benchmark => $t, # "Benchmark" is the only important key
goal => $goal, # \
( run in 1.441 second using v1.01-cache-2.11-cpan-96521ef73a4 )