This one loops over the list of items once (at most).

Intriguing. Both your original version and the updated one do much better than mine at small widths (25), but then get progressively worse, where mine gets better.

I haven't read through your algorithm properly yet, but we do get the same results (except I used 2 spaces not 1 between the columns).

[22:49:46.54] P:\test>405274 >nul 100 trials of Buk:25 ( 190.051ms total), 1.901ms/trial 100 trials of Buk:50 ( 113.853ms total), 1.139ms/trial 100 trials of Buk:75 ( 88.451ms total), 884us/trial 100 trials of Buk:100 ( 70.376ms total), 703us/trial 100 trials of Buk:125 ( 38.077ms total), 380us/trial 100 trials of Buk:150 ( 46.875ms total), 468us/trial 100 trials of Buk:175 ( 46.875ms total), 468us/trial 100 trials of Buk:200 ( 46.875ms total), 468us/trial [22:50:02.71] P:\test>405274-tye1 >nul 100 trials of Tye1:25 ( 93.742ms total), 937us/trial 100 trials of Tye1:50 ( 190.402ms total), 1.904ms/trial 100 trials of Tye1:75 ( 265.551ms total), 2.656ms/trial 100 trials of Tye1:100 ( 343.750ms total), 3.438ms/tria +l 100 trials of Tye1:125 ( 421.875ms total), 4.219ms/tria +l 100 trials of Tye1:150 ( 453.125ms total), 4.531ms/tria +l 100 trials of Tye1:175 ( 468.750ms total), 4.688ms/tria +l 100 trials of Tye1:200 ( 484.375ms total), 4.844ms/tria +l [22:50:08.43] P:\test>405274-tye2 >nul 100 trials of Tye2:25 ( 107.743ms total), 1.077ms/trial 100 trials of Tye2:50 ( 154.991ms total), 1.550ms/trial 100 trials of Tye2:75 ( 200.225ms total), 2.002ms/trial 100 trials of Tye2:100 ( 227.510ms total), 2.275ms/tria +l 100 trials of Tye2:125 ( 250ms total), 2.500ms/tria +l 100 trials of Tye2:150 ( 234.375ms total), 2.344ms/tria +l 100 trials of Tye2:175 ( 234.375ms total), 2.344ms/tria +l 100 trials of Tye2:200 ( 250ms total), 2.500ms/tria +l

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

In reply to Re^2: 'ls -C' column style (sideways) by BrowserUk
in thread 'ls -C' column style by hv

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.