Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

My memory of this issue was that the unmodified sort was optimized in older versions of perl, but that recent editions had optimized all four of the common sorts (numeric and standard, forward and backwards). Fortunately (in some sense) I'm equipped to test this hypothesis, having some older installs to work with. I used bart's benchmarking code, for completeness.

This is perl, version 5.004_04 built for IP27-irix

Benchmark: timing 1000 iterations of f_alpha, f_cmp, f_owtdi, f_sship, + i_alpha, i_cmp, i_owtdi, i_sship... f_alpha: 88 secs (86.12 usr 0.04 sys = 86.16 cpu) f_cmp: 306 secs (298.55 usr 0.44 sys = 298.99 cpu) f_owtdi: 274 secs (266.25 usr 0.40 sys = 266.65 cpu) f_sship: 242 secs (238.57 usr 0.20 sys = 238.77 cpu) i_alpha: 84 secs (81.57 usr 0.09 sys = 81.66 cpu) i_cmp: 301 secs (293.79 usr 0.38 sys = 294.17 cpu) i_owtdi: 270 secs (264.43 usr 0.27 sys = 264.70 cpu) i_sship: 241 secs (238.31 usr 0.18 sys = 238.49 cpu) Rate f_cmp i_cmp f_owtdi i_owtdi f_sship i_sship f_alp +ha i_alpha f_cmp 3.34/s -- -2% -11% -11% -20% -20% -7 +1% -73% i_cmp 3.40/s 2% -- -9% -10% -19% -19% -7 +1% -72% f_owtdi 3.75/s 12% 10% -- -1% -10% -11% -6 +8% -69% i_owtdi 3.78/s 13% 11% 1% -- -10% -10% -6 +7% -69% f_sship 4.19/s 25% 23% 12% 11% -- -0% -6 +4% -66% i_sship 4.19/s 25% 23% 12% 11% 0% -- -6 +4% -66% f_alpha 11.61/s 247% 241% 209% 207% 177% 177% +-- -5% i_alpha 12.25/s 266% 260% 227% 224% 192% 192% +6% --

This is perl, version 5.005_03 built for i686-linux-thread

Benchmark: timing 1000 iterations of f_alpha, f_cmp, f_owtdi, f_sship, + i_alpha, i_cmp, i_owtdi, i_sship... f_alpha: 141 wallclock secs (140.97 usr + 0.02 sys = 140.99 CPU) f_cmp: 228 wallclock secs (227.89 usr + 0.16 sys = 228.05 CPU) f_owtdi: 192 wallclock secs (190.93 usr + 1.75 sys = 192.68 CPU) f_sship: 164 wallclock secs (163.18 usr + 0.09 sys = 163.27 CPU) i_alpha: 118 wallclock secs (118.25 usr + 0.11 sys = 118.36 CPU) i_cmp: 203 wallclock secs (203.10 usr + 0.23 sys = 203.33 CPU) i_owtdi: 191 wallclock secs (190.90 usr + 1.96 sys = 192.86 CPU) i_sship: 163 wallclock secs (162.19 usr + 0.15 sys = 162.34 CPU) Rate f_cmp i_cmp i_owtdi f_owtdi f_sship i_sship f_alp +ha i_alpha f_cmp 4.39/s -- -11% -15% -16% -28% -29% -3 +8% -48% i_cmp 4.92/s 12% -- -5% -5% -20% -20% -3 +1% -42% i_owtdi 5.19/s 18% 5% -- -0% -15% -16% -2 +7% -39% f_owtdi 5.19/s 18% 6% 0% -- -15% -16% -2 +7% -39% f_sship 6.12/s 40% 25% 18% 18% -- -1% -1 +4% -28% i_sship 6.16/s 40% 25% 19% 19% 1% -- -1 +3% -27% f_alpha 7.09/s 62% 44% 37% 37% 16% 15% +-- -16% i_alpha 8.45/s 93% 72% 63% 63% 38% 37% 1 +9% --

This is perl, v5.6.1 built for IP27-irix

Benchmark: timing 1000 iterations of f_alpha, f_cmp, f_owtdi, f_sship, + i_alpha, i_cmp, i_owtdi, i_sship... f_alpha: 76 wallclock secs (74.17 usr + 0.10 sys = 74.27 CPU) @ 13 +.46/s (n=1000) f_cmp: 75 wallclock secs (74.12 usr + 0.09 sys = 74.21 CPU) @ 13 +.48/s (n=1000) f_owtdi: 178 wallclock secs (175.29 usr + 0.15 sys = 175.44 CPU) @ + 5.70/s (n=1000) f_sship: 46 wallclock secs (45.62 usr + 0.01 sys = 45.63 CPU) @ 21 +.92/s (n=1000) i_alpha: 67 wallclock secs (66.26 usr + 0.02 sys = 66.28 CPU) @ 15 +.09/s (n=1000) i_cmp: 67 wallclock secs (66.49 usr + 0.08 sys = 66.57 CPU) @ 15 +.02/s (n=1000) i_owtdi: 179 wallclock secs (175.72 usr + 0.17 sys = 175.89 CPU) @ + 5.69/s (n=1000) i_sship: 47 wallclock secs (46.10 usr + 0.02 sys = 46.12 CPU) @ 21 +.68/s (n=1000) Rate i_owtdi f_owtdi f_alpha f_cmp i_cmp i_alpha i_sship + f_sship i_owtdi 5.69/s -- 0% -58% -58% -62% -62% -74% + -74% f_owtdi 5.70/s 0% -- -58% -58% -62% -62% -74% + -74% f_alpha 13.5/s 137% 136% -- 0% -10% -11% -38% + -39% f_cmp 13.5/s 137% 136% 0% -- -10% -11% -38% + -39% i_cmp 15.0/s 164% 164% 12% 11% -- 0% -31% + -31% i_alpha 15.1/s 165% 165% 12% 12% 0% -- -30% + -31% i_sship 21.7/s 281% 280% 61% 61% 44% 44% -- + -1% f_sship 21.9/s 285% 284% 63% 63% 46% 45% 1% + --

And for completeness, this is perl, v5.6.1 built for i686-linux

Benchmark: timing 1000 iterations of f_alpha, f_cmp, f_owtdi, f_sship, + i_alpha, i_cmp, i_owtdi, i_sship... f_alpha: 48 wallclock secs (48.24 usr + 0.00 sys = 48.24 CPU) @ 20 +.73/s (n=1000) f_cmp: 48 wallclock secs (48.23 usr + 0.01 sys = 48.24 CPU) @ 20 +.73/s (n=1000) f_owtdi: 67 wallclock secs (66.64 usr + 0.00 sys = 66.64 CPU) @ 15 +.01/s (n=1000) f_sship: 30 wallclock secs (29.58 usr + 0.29 sys = 29.87 CPU) @ 33 +.48/s (n=1000) i_alpha: 38 wallclock secs (38.22 usr + 0.01 sys = 38.23 CPU) @ 26 +.16/s (n=1000) i_cmp: 38 wallclock secs (38.11 usr + 0.05 sys = 38.16 CPU) @ 26 +.21/s (n=1000) i_owtdi: 66 wallclock secs (65.85 usr + 0.03 sys = 65.88 CPU) @ 15 +.18/s (n=1000) i_sship: 29 wallclock secs (28.70 usr + 0.31 sys = 29.01 CPU) @ 34 +.47/s (n=1000) Rate f_owtdi i_owtdi f_alpha f_cmp i_alpha i_cmp f_sship + i_sship f_owtdi 15.0/s -- -1% -28% -28% -43% -43% -55% + -56% i_owtdi 15.2/s 1% -- -27% -27% -42% -42% -55% + -56% f_alpha 20.7/s 38% 37% -- 0% -21% -21% -38% + -40% f_cmp 20.7/s 38% 37% 0% -- -21% -21% -38% + -40% i_alpha 26.2/s 74% 72% 26% 26% -- -0% -22% + -24% i_cmp 26.2/s 75% 73% 26% 26% 0% -- -22% + -24% f_sship 33.5/s 123% 121% 61% 61% 28% 28% -- + -3% i_sship 34.5/s 130% 127% 66% 66% 32% 32% 3% + --

Note that the two Irix perls are running on the same box, but the two Linux perls are not (the 5.6.1 box is about 3 times as fast).

It would seem, if I'm reading this right, that the optimization of the basic sort in older versions is just barely enough to make it faster than numeric sort: now that the numeric sort is optimized as well, its inherent speed advantage shows. In 5.6.1, all of the sorts are faster, but the spaceship and cmp sorts improve by much more than the others, because the callback overhead referred to elswhere in this thread is removed.



If God had meant us to fly, he would *never* have given us the railroads.
    --Michael Flanders


In reply to Re: The High Price of Golf, and A Surprise by ChemBoy
in thread The High Price of Golf, and A Surprise by Zaxo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-24 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found