I ran your benchmark code above, changing the points from 1000 to 10 000. I got the following results:
Rate davidrw_2 davidrw_1 op_cmp2 op_orig ternary
davidrw_2 48968/s -- -21% -87% -91% -91%
davidrw_1 62049/s 27% -- -83% -89% -89%
op_cmp2 363917/s 643% 487% -- -35% -36%
op_orig 559112/s 1042% 801% 54% -- -2%
ternary 570934/s 1066% 820% 57% 2% --
Note that I changed the
map code to:
my @comparisons = map { [($_ - 15) * 2000, $_] } 16 .. 24;
That is, 16 .. 24 instead of 24 .. 16.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.