Created
July 20, 2014 14:24
-
-
Save tobyink/e733f839cecc0dd193a6 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 strictures; | |
use Types::Standard -types; | |
use Benchmark qw(timethis); | |
{ | |
my $check = Tuple[Int, Str, HashRef]; | |
my $data = [1, "Hello", {}]; | |
my $sub = $check->compiled_check; | |
warn($check->inline_check(q/$tuple/)); | |
$sub->($data) or die; | |
timethis 500_000, sub { $sub->($data) }; | |
} | |
{ | |
my $check = Map[Int, ArrayRef]; | |
my $data = { 1 => [], 2 => [], 3 => [] }; | |
my $sub = $check->compiled_check; | |
warn($check->inline_check(q/$map/)); | |
$sub->($data) or die; | |
timethis 500_000, sub { $sub->($data) }; | |
} | |
__END__ | |
Tuple... | |
initial speed: 109649.12/s | |
with xs speed: 1063829.79/s | |
Map... | |
initial speed: 40064.10/s | |
with xs speed: 375939.85/s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment