It's hard to predict performance in advance.  I think it's gotten =20
harder as processors have become more complicated and there are more =20
alternatives for running code.   I'm just guessing here, but maybe =20
blocks are so critical to ruby performance that 'each' has benefited =20
from attempts to optimize the performance of blocks in general.

-Joe

On 21 sept. 08, at 11:44, Charles Oliver Nutter wrote:

> Joe W=F6lfel wrote:
>> You can try my test if you like.  I haven't checked it carefully.  =20=

>> But it does seem like 'each' is much faster under both ruby 1.86 =20
>> and ruby 1.9.  The code is below.
>
> Odd, now that I try it, each *is* faster than for. I'm going to =20
> have to investigate.
>
> JRuby:
>                      user     system      total        real
> for loop         0.334000   0.000000   0.334000 (  0.334033)
> each             0.236000   0.000000   0.236000 (  0.235695)
>
> Ruby 1.8.6:
>                      user     system      total        real
> for loop         1.050000   0.010000   1.060000 (  1.079704)
> each             0.950000   0.010000   0.960000 (  0.982576)
>
> Ruby 1.9:
>                      user     system      total        real
> for loop         0.910000   0.010000   0.920000 (  0.933510)
> each             0.420000   0.000000   0.420000 (  0.431548)
>
> - Charlie
>
>