develooper Front page | perl.perl5.porters | Postings from February 2015

Re: [perl #123918] regex end of line match very slow

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
February 27, 2015 09:32
Subject:
Re: [perl #123918] regex end of line match very slow
Message ID:
20150227093201.GM28599@iabyn.com
On Wed, Feb 25, 2015 at 10:32:21AM -0600, Paul Salazar wrote:
> >So pre-COW:
> >
> >     the regex engine *always* copied after a successful match in the presence
> >     of $& etc, going quadratic always, regardless of whether the string is
> >     subsequently modified or not; (it actually didn't copy in the just
> >     presence of captures, and just returned garbage in $1 etc if the
> >     string was modified; this was a tradeoff of performance over
> >     correctness).
> >
> >
> All makes sense except I'm not seeing the pre-COW going quadratic. Same
> example ran on 5.8
> 
>  ~$ perl -v
> 
> This is perl, v5.8.8 built for msys-64int
> 
> Running match \s$ on 100000 iterations on concatenated string...
> Time: 0.0459511280059814
> 
> Running match \S$ on 100000 iterations on concatenated string...
> Time: 0.0440521240234375

Try adding $& to the code or changing the regex to "(\\s)\$"; you'll then
see the slowdown in 5.8.x too.


-- 
All wight. I will give you one more chance. This time, I want to hear
no Wubens. No Weginalds. No Wudolf the wed-nosed weindeers.
    -- Life of Brian

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About