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?