Created
June 18, 2015 12:23
-
-
Save Mossuru777/87c122353d2f3d09fe69 to your computer and use it in GitHub Desktop.
Number(String) Compare
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 Benchmark qw/cmpthese/; | |
my @input = ("1", "0"); | |
cmpthese(0, { | |
'String' => sub { foreach (@data) { $_ eq "0" || $_ eq "1" } }, | |
'Number' => sub { foreach (@data) { $_ == 0 || $_ == 1 } }, | |
'Regex' => sub { foreach (@data) { $_ =~ /^[01]$/ } } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment