Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^2: Performance penalty of using qr//

by Athanasius (Archbishop)
on Dec 21, 2017 at 06:44 UTC ( #1205958=note: print w/replies, xml ) Need Help??

in reply to Re: Performance penalty of using qr//
in thread Performance penalty of using qr//

Hi LanX,

The inner for loops are each executed 3,789,182 times.

And yes, I originally had $s =~ /$re/ instead of $s =~ $re — it made no appreciable difference.

Update: Deparsing suggests that Perl adds the slashes anyway:

16:57 >perl -we "my $q = qr/^(\d+)$/; 123 =~ $q; print qq[$1\n];" 123 16:57 >perl -MO=Deparse -we "my $q = qr/^(\d+)$/; 123 =~ $q; print qq[ +$1\n];" BEGIN { $^W = 1; } my $q = qr/^(\d+)$/; 123 =~ /$q/; print "$1\n"; -e syntax OK 16:57 >


Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^3: Performance penalty of using qr//
by LanX (Cardinal) on Dec 21, 2017 at 08:02 UTC
    hmm .... could be a regression.

    If for some reason the scalar falls back to string interpolation instead of using the compilated code this could explain the penalty and wouldn't break the tests.

    A simplified benchmark for all platforms x versions would be nice.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Wikisyntax for the Monastery

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2021-04-10 11:36 GMT
Find Nodes?
    Voting Booth?

    No recent polls found