in reply to Inexplicably slow regex
A simple benchmark which shows somethng like OP's result is:
use strict; use warnings; use Benchmark qw(cmpthese); my $key = 'x'; my $str = ("\n The quick brown frog jumped over the lazy dog" x 10000 +) . "\n x"; cmpthese (-10, { sol => \&sol, nl => \&nl, lb => \&lb, } ); sub sol {$str =~ /^ \s* $key /mx;} sub nl {$str =~ /\n \s* $key /mx;} sub lb {$str =~ /(?<![^\n]) \s* $key /mx;} Rate sol lb nl sol 0.316/s -- -99% -100% lb 35.0/s 10997% -- -92% nl 441/s 139470% 1158% --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Inexplicably slow regex
by duckyd (Hermit) on Sep 12, 2006 at 23:37 UTC | |
|
Re^2: Inexplicably slow regex
by zigdon (Deacon) on Sep 13, 2006 at 15:51 UTC | |
by tye (Sage) on Sep 13, 2006 at 18:10 UTC | |
by zigdon (Deacon) on Sep 13, 2006 at 19:36 UTC |