In
Benchmark.pm: Does subroutine testing order bias results? it was suggested that the first test is consistently faster, even if the tests are identical.
I added a 2nd "timethese" to your code, with the tests reversed:
Benchmark: timing 30 iterations of a, b...
a: 26 wallclock secs (26.64 usr + 0.00 sys = 26.64 CPU) @ 1
+.13/s (n=30)
b: 32 wallclock secs (31.64 usr + 0.00 sys = 31.64 CPU) @ 0
+.95/s (n=30)
Benchmark: timing 30 iterations of a2, b2...
a2: 20 wallclock secs (20.10 usr + 0.00 sys = 20.10 CPU) @ 1
+.49/s (n=30)
b2: 28 wallclock secs (27.25 usr + 0.00 sys = 27.25 CPU) @ 1
+.10/s (n=30)
It appears that at least some of the difference is due to the order of the tests.
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.