fizbin,
I knew I was trading speed in setup time for speed in lookup time. If you want to see me on top, change the following:
"L~R" => sub { my @foo; my $str = "17:43:33:21:23:19:27:6"; while (my $p = $str =~ /([^:]+)/g && $1 and my $add_id = $str +=~ /([^:]+)/g && $1) { push @foo, ($add_id) x $p; } \@foo; }, "L~R" => sub { my $addid = $_[0]->[ rand 100 ]; }, As mod_perl: (NOT from scratch each time): Rate fizbin ccn_fast ccn ccn_faster origCode du +ff L~R fizbin 35680/s -- -52% -53% -60% -91% -9 +1% -92% ccn_fast 74642/s 109% -- -2% -16% -80% -8 +1% -83% ccn 76321/s 114% 2% -- -14% -80% -8 +1% -82% ccn_faster 88368/s 148% 18% 16% -- -76% -7 +8% -80% origCode 375784/s 953% 403% 392% 325% -- - +6% -13% duff 398928/s 1018% 434% 423% 351% 6% +-- -8% L~R 432419/s 1112% 479% 467% 389% 15% +8% --
I did notice that not on every pass all methods were "passing". If someone wanted to make it even faster they would randomize the array as part of set up time and then just loop through the array.

Cheers - L~R


In reply to Re^5: $str to %hash to @ary by Limbic~Region
in thread $str to %hash to @ary by abaxaba

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.