Testing old code in MRI 2.1.0 I noticed that using WHILE loops in place
of other looping structures reduced times in some algorithms from
14%-20% or greater, as the iterations increased.

However, running the same code in Rubinius 2.2.2 and JRuby 1.7.9 showed
no appreciable difference between the WHILE loop heavy code versus using
TIMES and EACH, etc.

I had noticed this performance difference in 2.0.0 too, but it seems in
2.1.0 it's increased.

Since it seems WHILE loops are so much faster, why doesn't Ruby parse
the other loop structures into WHILE loop semantics to get the same
increased performance?

Examples:

n.times do |i| .... end  becomes   i=0; while i < n; .....; i +=1 end

x.step(lmt,i) do |j| ..end  becomes  j=x; while j < lmt; ...; j += i end

and so on for EACH, et al.

-- 
Posted via http://www.ruby-forum.com/.