Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Performance penalty of using qr//

by Athanasius (Archbishop)
on Dec 21, 2017 at 06:44 UTC ( [id://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 >

Cheers,

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

Replies are listed 'Best First'.
Re^3: Performance penalty of using qr//
by LanX (Saint) 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-25 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found