Created
October 16, 2008 12:53
-
-
Save tokuhirom/17122 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 warnings; | |
use Benchmark qw/cmpthese/; | |
sub c1 { $_->[0] } | |
my @a = map {[rand]} (qw/1/x1000); | |
cmpthese( | |
1000 => { | |
simple => sub { | |
map { $_->[1] } | |
sort { $a->[0] <=> $b->[0] } | |
map { [$_->[0], $_] } | |
@a | |
}, | |
"call code" => sub { | |
map { $_->[1] } | |
sort { $a->[0] <=> $b->[0] } | |
map { [c1($_), $_] } | |
@a | |
}, | |
}, | |
); | |
Rate call code simple | |
call code 207/s -- -13% | |
simple 238/s 15% -- |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment