http://www.perlmonks.org?node_id=810439


in reply to Re^9: Speeding up named capture buffer access
in thread Speeding up named capture buffer access

I created a very simple example that matched some simple times with a few different formats, and benchmarked it using named capture buffers, alternative capture group numbering, and your method with embedded code. The alternative capture method is about 40% faster than the named buffers (so I'm going to be implementing it for at least some of the regular expression matching where the order of the matches stays the same). The embedded code was significantly slower (7x) than the named buffers. It's possible I wasn't doing it as efficiently as possible, but given that:

    it appears to be significantly slower
    it's listed as an experimental feature
    the regular expressions are more complicated
I think that I'll pass on it for the time being. But it was fun to experiment with something new!

Replies are listed 'Best First'.
Re^11: Speeding up named capture buffer access
by ikegami (Patriarch) on Dec 01, 2009 at 19:49 UTC

    yeah, I figured the sub calls would significantly slow things down.

    The use of (?{}) doesn't complicate things. It's use is minimal, and it's use is the same for every subpattern. Using it just shifts code from outside the pattern into the pattern. Specifically, it removes the need to parse the returned values a second time in order to get numbers. However, the use of rc does complicate things.