From: Charles Oliver Nutter Date: 2008-10-11T01:14:47+09:00 Subject: [ruby-core:19285] Re: performance of C function calls in 1.8 vs 1.9 Charles Oliver Nutter wrote: > Unexpectedly, 'times' and 'each' are faster for 1.8.6 than 'for'. The "fasterness" of 1.8.6 appears to be because the original bench did not have a variable assignment in the times/each blocks (where the 'for' does). Adding that: ~/projects/jruby ��� ruby test.rb user system total real times 1.760000 0.010000 1.770000 ( 1.773225) for 1.220000 0.010000 1.230000 ( 1.239431) each 1.790000 0.010000 1.800000 ( 1.805276) ~/projects/jruby ��� ../ruby1.9/ruby -I ../ruby1.9/lib test.rb user system total real times 1.090000 0.020000 1.110000 ( 1.110330) for 5.320000 0.030000 5.350000 ( 5.372634) each 1.040000 0.010000 1.050000 ( 1.041633) ~/projects/jruby ��� jruby --server test.rb user system total real times 1.511000 0.000000 1.511000 ( 1.510814) for 1.113000 0.000000 1.113000 ( 1.112858) each 1.347000 0.000000 1.347000 ( 1.346819) So at least that's one mystery solved; 1.8.6 must have some peephole optimization for empty blocks with no var assignment (i.e. completely empty). - Charlie