Re:Yet Another Language Speed Test – Counting Primes
by caf on Saturday July 04, 2015 @12:16AM
(#9829168)
The note about the idiomatic Ruby version of this (each on a range) being slower than the tested version (while loop) is very interesting.
This looks like an opportunity for the Ruby interpreter to optimise: if the range is excessively large, it could decide itself to loop over the bounds rather than instantiating the entire range.
This looks like an opportunity for the Ruby interpreter to optimise: if the range is excessively large, it could decide itself to loop over the bounds rather than instantiating the entire range.