Firstly, you omitted the other contender:

... sub lookbehind { my $x = shift; split '(?:(?<=[^#]####)|(?<=[^#]##)|(?<!#))[@]', $x; } C:\test>junk8 Subroutine Benchmark::mytime redefined at c:/Perl/lib/Benchmark.pm lin +e 459. Benchmark: timing 10000 iterations of lookbehind, rollahead, unroll ... lookbehind: 2.34183 wallclock secs ( 2.19 usr + 0.00 sys = 2.19 CPU) + @ 4570.38/s (n=10000) rollahead: 3.46343 wallclock secs ( 3.23 usr + 0.00 sys = 3.23 CPU) + @ 3092.15/s (n=10000) unroll: 3.51775 wallclock secs ( 3.33 usr + 0.02 sys = 3.34 CPU) + @ 2990.43/s (n=10000) Rate unroll rollahead lookbehind unroll 2990/s -- -3% -35% rollahead 3092/s 3% -- -32% lookbehind 4570/s 53% 48% --

Secondly, you didn't check your results. unroll and rollahead produce different results:

rollahead => @# #@## ##@ ##@## #@# # @# #@## ##@@# #@## ##@ +@# #@ ... unroll => @# #@## ##@ ##@## #@# @# #@## ##@@# #@## ##@@ +# #@# ...

And both sets are wrong! Any output that has an even number of #s preceding a @ (as with the 3rd, 4th etc. outputs above) is wrong. If you look back at the op, you'll see that any @s that persist into the results set are preceded by an odd number of ##s.

The results set from the fastest algorithm:

lookbehind => #@## ###@#### #####@ #####@#### ###@## # #@## + ###@#### ...

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: Seeking Audience with the Perl Regex Droids... by BrowserUk
in thread Seeking Audience with the Perl Regex Droids... by mobiusinversion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.