Created
September 30, 2013 17:00
-
-
Save autarch/6766796 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 ); | |
my $flag_off = 'A string of medium length containing < 100 characters'; | |
my $flag_on = 'A string of medium length containing < 100 characters'; | |
utf8::upgrade($flag_on); | |
cmpthese( | |
5_000_000, | |
{ | |
'UTF-8 flag off' => \&off, | |
'UTF-8 flag on' => \&on, | |
} | |
); | |
sub off { | |
my $first = substr( $flag_off, 0, 10 ); | |
my $last = substr( $flag_off, -10, 10 ); | |
$flag_off =~ /medium/; | |
$flag_off =~ /(a|b|c|d|foo)/; | |
} | |
sub on { | |
my $first = substr( $flag_on, 0, 10 ); | |
my $last = substr( $flag_on, -10, 10 ); | |
$flag_on =~ /medium/; | |
$flag_on =~ /(a|b|c|d|foo)/; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment