use Benchmark 'cmpthese'; my $y = "HELLO world" x 100; cmpthese(-5, { cc_simple => sub { $y =~ /[hH][eE][lL][lL][oO]/; }, cc_complex => sub { $y =~ /\w+ [hH][eE][lL][lL][oO] \w+/; }, i_simple => sub { $y =~ /hello/i; }, i_complex => sub { $y =~ /\w+ hello \w+/i; }, simple => sub { $y =~ /HELLO/; }, complex => sub { $y =~ /\w+ HELLO \w+/; }, simple_fail => sub { $y =~ /hELLO/; }, complex_fail => sub { $y =~ /\w+ hELLO \w+/; }, }); __END__ Rate cc_complex i_complex complex complex_fail simple_fail cc_simple i_simple simple cc_complex 13973/s -- -2% -82% -83% -87% -99% -99% -99% i_complex 14271/s 2% -- -81% -83% -87% -99% -99% -99% complex 77103/s 452% 440% -- -7% -31% -93% -93% -94% complex_fail 82560/s 491% 479% 7% -- -26% -92% -93% -94% simple_fail 111335/s 697% 680% 44% 35% -- -90% -90% -92% cc_simple 1065985/s 7529% 7370% 1283% 1191% 857% -- -5% -23% i_simple 1120558/s 7919% 7752% 1353% 1257% 906% 5% -- -19% simple 1377591/s 9759% 9553% 1687% 1569% 1137% 29% 23% --