Created
July 21, 2014 12:54
-
-
Save tobyink/71eab715ac16178cbcfb 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 Types::Common::Numeric -types; | |
use Benchmark qw(timethis); | |
{ | |
my $check = ScalarRef | ArrayRef | HashRef; | |
my $sub = $check->compiled_check; | |
warn($check->inline_check(q/$ref/)); | |
$sub->([]) or die; | |
$sub->({}) or die; | |
$sub->(42) and die; | |
timethis 500_000, sub { $sub->({}) }; | |
} | |
{ | |
my $check = PositiveInt &+ Enum[-1,0,1,2]; | |
my $sub = $check->compiled_check; | |
warn($check->inline_check(q/$i/)); | |
$sub->(1) or die; | |
$sub->(2) or die; | |
$sub->(0) and die; | |
$sub->(-1) and die; | |
$sub->(42) and die; | |
timethis 500_000, sub { $sub->(1) }; | |
} | |
__END__ | |
Union... | |
initial speed: 255102.04/s | |
with xs speed: 724637.68/s | |
Intersection... | |
initial speed: 370370.37/s | |
with xs speed: 675675.68/s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment