Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: No questions. Just a "thank you for named captures" !!

by sedusedan (Monk)
on Feb 07, 2013 at 16:50 UTC ( [id://1017695]=note: print w/replies, xml ) Need Help??


in reply to Re^2: No questions. Just a "thank you for named captures" !!
in thread No questions. Just a "thank you for named captures" !!

$ perl -MBench -e'$s = "a b"; /(\w+) (\w+)/; bench sub {$a=$1; $b=$2}, + -1' 3666664 calls (3339959/s), 1.098s (0.0003ms/call) $ perl -MBench -e'$s = "a b"; /(?<a>\w+) (?<a>\w+)/; bench sub {$a=$+{ +a}; $b=$+{b}}, -1' 636364 calls (560973/s), 1.134s (0.0018ms/call) $ perl -MBench -e'$s = "a b"; /(?<a>\w+) (?<a>\w+)/; %h=(a=>$+{a}, b=> +$+{b}); bench sub {$a=$h{a}; $b=$h{b}}, -1' 3333331 calls (3102372/s), 1.074s (0.0003ms/call)

Accessing %+ elements is slower due to some tie magic. In general, yeah, you don't need to worry about it. But I managed to make Org::Parser and Text::sprintfn around twice as fast by avoiding named capture or copying %+ first to a temporary hash instead of accessing invididual %+ elements repeatedly.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-29 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found