Good one, man. my $i does speed it up, now the ratio become perl:java:c = 27:7:5.
But use integer does not seem to affect the result, and it should not affect the result on a 32 bit machine, when integers are less than 10^6.
I also tried 0..1,000,000 as one post suggested, it slows down the whole thing.
I then became interested in the difference between your benchmark and my result. (I didn't suspect you cook the numbers and I don't, never, just as you should not suspect me.) So I ran your benchmark testing, and got:
Benchmark: timing 5 iterations of int_iterate, iterate, lex_iterate...
int_iterate: 131 wallclock secs (130.94 usr + 0.00 sys = 130.94 CPU)
iterate: 172 wallclock secs (172.63 usr + 0.00 sys = 172.63 CPU) @
+ 0.03/s (
lex_iterate: 137 wallclock secs (136.66 usr + 0.00 sys = 136.66 CPU)
s/iter iterate lex_iterate int_iterate
iterate 34.5 -- -21% -24%
lex_iterate 27.3 26% -- -4%
int_iterate 26.2 32% 4% --
I would believe this is due to my small mem config as I said in another reply.
But your data shows use integer speeds up the thing a lot, that part really confuses me. I don't think you are using 16 bit OS though. Did you compiled your perl yourself?
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||