##
Rate brackets slash i
brackets 3508/s -- -66%
slash i 10434/s 197% --
####
#!/usr/bin/perl -w
use strict;
use Benchmark 'cmpthese';
our $s = "HELLOWORLD" x 1024;
cmpthese(1_000_000, {
'slash_i' => sub { $s =~ m/hello/i; $s =~ m/jello/i },
'brackets' => sub { $s =~ m/[Hh][Ee][Ll][Ll][Oo]/;
$s =~ m/[Jj][Ee][Ll][Ll][Oo]/; },
});
####
Rate brackets slash_i
brackets 5633/s -- -66%
slash_i 16683/s 196% --