Created
April 16, 2019 04:14
-
-
Save gugod/33c0a2ac356021fec768e562be783d46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use Dumbbench; | |
my $bench = Dumbbench->new( inital_runs => 1000 ); | |
my $nums = [ map { int rand(100000000) } 1...1000 ]; | |
$bench->add_instances( | |
Dumbbench::Instance::PerlSub->new( | |
name => "listassign", | |
code => sub { | |
my $num2 = [ @$nums ]; | |
@$num2 = sort { $b <=> $a } @$num2; | |
return; | |
} | |
), | |
Dumbbench::Instance::PerlSub->new( | |
name => "scalarassign + ArrayRef", | |
code => sub { | |
my $num2 = [ @$nums ]; | |
$num2 = [sort { $b <=> $a } @$num2]; | |
return; | |
} | |
), | |
); | |
$bench->run; | |
$bench->report; | |
__END__ | |
> perl bench.pl | |
listassign: Ran 25 iterations (3 outliers). | |
listassign: Rounded run time per iteration: 1.39103514e-04 +/- 4.6e-11 (0.0%) | |
scalarassign + ArrayRef: Ran 23 iterations (1 outliers). | |
scalarassign + ArrayRef: Rounded run time per iteration: 1.16248e-04 +/- 5.1e-08 (0.0%) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment