Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by sedusedan (Monk)
on Feb 07, 2013 at 16:50 UTC ( #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.


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2014-11-27 21:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (188 votes), past polls