All you need is for scanning that string to be in an inner loop and you are screwed even on modern hardware. The questioner is asking about making split faster and has presumably already found that to be the limiting step in his program. There are already benchmarks in this discussion showing that the split builtin is about 4–5 times faster than any of the Perl equivalents the monks have suggested so far.

If this is in an inner loop, yes, even a small difference could be the difference between "good enough" and user complaints that "it takes too long". The solution is probably to reorganize the program to ensure that the string is only scanned once, but if that is already the case, we may have a situation where data is arriving too fast for a single node to handle and we need to scale out into a cluster. The first step in that direction is always the hardest because adding the coordination overhead means you may need two or three nodes just to match what one node could previously handle. Of course you can then add more nodes once you have paid that cost, but this is getting way into "XY Problem" territory for this discussion.


In reply to Re^2: Fastest split possible by jcb
in thread Fastest split possible by pedrete

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.