Ah, much better. Now I can test it! Here are the results from my benchmark against /usr/dict/words, 100,000 iterations (my final code above is "new" and your code is "mjd"):
Benchmark: timing 100000 iterations of mjd, new, original... mjd: 17 wallclock secs (16.86 usr + 0.00 sys = 16.86 CPU) @ 59 +31.20/s (n=100000) new: 3 wallclock secs ( 2.70 usr + 0.01 sys = 2.71 CPU) @ 36 +900.37/s (n=100000) original: 17 wallclock secs (12.87 usr + 0.01 sys = 12.88 CPU) @ 77 +63.98/s (n=100000) Rate mjd original new mjd 5931/s -- -24% -84% original 7764/s 31% -- -79% new 36900/s 522% 375% --
It looks like this solution is actually slower than the original...

-sam


In reply to Re: Re: Finding all substrings by samtregar
in thread Finding all substrings by TheHobbit

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.