in reply to Re^2: qr//i versus m//i ( qr slow )
in thread qr//i versus m//i

Hah, another old benchmark i had laying around
#!/usr/bin/perl -- use strict; use warnings; use Benchmark 'cmpthese'; my @small = 1; cmpthese( 500_000, { '__' => sub { for my $line ( @small ){ next if $line !~ /\s+(-?\d+\.\d+)\s+(-?\d+\.\d+)/; } return; }, '/_'.$].'_/' => eval ' sub { for my $line ( @small ){ next if $line !~ /'. qr{\s+(-?\d+\.\d+)\s+(-?\d+\.\d+)} # 5.12.2 (?-xism: # 5.14.1 (?^: .'/; } return; } ', 'qr' => sub { my $re = qr{\s+(-?\d+\.\d+)\s+(-?\d+\.\d+)}; for my $line ( @small ){ next if $line !~ $re; } return; }, '/qr/' => sub { my $re = qr{\s+(-?\d+\.\d+)\s+(-?\d+\.\d+)}; for my $line ( @small ){ next if $line !~ /$re/; } return; }, ## 2014-02-21-11:33:11 'qr,//o' => do { our $gre = qr{\s+(-?\d+\.\d+)\s+(-?\d+\.\d+)}; sub { for my $line ( @small ){ next if $line !~ /$gre/; } return; }; }, }); __END__ Rate /qr/ qr qr,//o __ /_ +5.016001_/ /qr/ 198807/s -- -0% -48% -71% + -75% qr 198807/s 0% -- -48% -71% + -75% qr,//o 385505/s 94% 94% -- -43% + -52% __ 680272/s 242% 242% 76% -- + -15% /_5.016001_/ 800000/s 302% 302% 108% 18% + --