in reply to Re^4: question about reg exp engine
in thread question about reg exp engine
use strict; use warnings; use Benchmark qw( cmpthese ); my $results = cmpthese( -10, { 'r3' => sub { my $string = " stuff "; $string =~ s/^\s//g; $string =~ s/\s$//g; $string =~ s/\s+$//g; }, 'r1' => sub { my $string = " stuff "; $string =~ s/^\s|\s$|\s+$//g; }, } );
Rate r1 r3 r1 295926/s -- -1% r3 299980/s 1% --
matching GrandFather's, I get the following:my $string = (' ' x 1000) . 'x' . (' ' x 1000);
So Lies, damn lies, and benchmarks (with the wrong data), indeed.Rate r3 r1 r3 61890/s -- -79% r1 297607/s 381% --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: question about reg exp engine
by GrandFather (Saint) on Aug 04, 2008 at 00:24 UTC | |
by broomduster (Priest) on Aug 04, 2008 at 00:43 UTC |