As per update, fixed the bug in solution_1, with little modification to performance improvement. Regarding the contention that baseline and solution_1 are doing fewer prints, of course they are. If IO is a bottle neck, then a method that can reduce calls to IO is a better method. But, if you want to eliminate those benefits of the algorithms, benchmarking with subroutines including lines like

print OUT "$_\n" foreach @list;

result in the following comparisons, where _pr specifies a version with more print statements:

Benchmark: timing 100000 iterations of Baseline, Baseline_pr, Queue, Q +ueue_pr... Baseline: 1.62739 wallclock secs ( 1.62 usr + 0.01 sys = 1.63 CPU) + @ 61349.69/s (n=100000) Baseline_pr: 2.13879 wallclock secs ( 2.14 usr + 0.00 sys = 2.14 CPU +) @ 46728.97/s (n=100000) Queue: 3.61375 wallclock secs ( 3.61 usr + 0.00 sys = 3.61 CPU) + @ 27700.83/s (n=100000) Queue_pr: 3.70646 wallclock secs ( 3.71 usr + 0.00 sys = 3.71 CPU) + @ 26954.18/s (n=100000) Rate Queue_pr Queue Baseline_pr Baseline Queue_pr 26954/s -- -3% -42% -56% Queue 27701/s 3% -- -41% -55% Baseline_pr 46729/s 73% 69% -- -24% Baseline 61350/s 128% 121% 31% -- Benchmark: timing 1000 iterations of Baseline, Baseline_pr, Queue, Que +ue_pr... Baseline: 5.63275 wallclock secs ( 5.60 usr + 0.03 sys = 5.63 CPU) + @ 177.62/s (n=1000) Baseline_pr: 8.3455 wallclock secs ( 8.32 usr + 0.02 sys = 8.34 CPU) + @ 119.90/s (n=1000) Queue: 25.3093 wallclock secs (25.29 usr + 0.01 sys = 25.30 CPU) + @ 39.53/s (n=1000) Queue_pr: 25.1902 wallclock secs (25.17 usr + 0.02 sys = 25.19 CPU) + @ 39.70/s (n=1000) Rate Queue Queue_pr Baseline_pr Baseline Queue 39.5/s -- -0% -67% -78% Queue_pr 39.7/s 0% -- -67% -78% Baseline_pr 120/s 203% 202% -- -32% Baseline 178/s 349% 347% 48% --

In reply to Re^3: Challenge: Sorting Sums Of Sorted Series by kennethk
in thread Challenge: Sorting Sums Of Sorted Series by Limbic~Region

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.