Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: The Deceiver

by itub (Priest)
on Aug 13, 2004 at 15:12 UTC ( [id://382705]=note: print w/replies, xml ) Need Help??


in reply to Re^4: The Deceiver
in thread Why does a Perl 5.6 regex run a lot slower on Perl 5.8?

If I remove the backreference by changing the regex in my example to $n++ while ($s =~ /(.*?)RRRR/sg);, I get the following:
time ~/bin/perl5.8.0 reg.pl
500 matches

real    0m0.018s
user    0m0.010s
sys     0m0.010s

time ~/bin/perl5.6.1 reg.pl
1 matches

real    0m0.015s
user    0m0.010s
sys     0m0.000s

So at least in this case Perl 5.8.0 doesn't have a speed problem. I don't know exactly what's going on in your code though.

Replies are listed 'Best First'.
Re^6: The Deceiver
by itub (Priest) on Aug 13, 2004 at 15:27 UTC
    Sorry to reply to myself, but I think I found something. The problem seems to manifest itself more clearly when using the /i modifier and the regex fails. It seems the engine is wasting a lot of time normalizing case.

    $s = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyRRRyyyy\n" x 300; $n = 0; $n++ while ($s =~ /(.*?)RRRR/isg); print "$n matches\n";

    To summarize: 5.6.1: 0 matches, 0.32 s; 5.8.0: 0 matches, 2.2 s.

    But note that if I change the regex to /x(.*?)RRRR/isg the results are reversed: 5.6.1: 9.2 s; 5.8.0: 1.4 s. That's because now 5.6.1 can't get away with the fake anchor. Interesting...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://382705]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-24 20:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found