From: Charles Oliver Nutter Date: 2011-01-15T11:06:31+09:00 Subject: Re: Parallel Assignments and Elegance/Complexity Ratio. On Fri, Jan 14, 2011 at 2:45 PM, Colin Bartlett wrote: > Now the only thing that's puzzling me is why the MRI 1.9.1 "cheating > honestly" version of parallel assignment seems to be slightly but > clearly faster than the MRI 1.9.1 single assignment! Yes, that is a bit baffling! I have no explanation for that. As you can see in JRuby, the times for the non-expression parallel assignment and the normal assignment are roughly the same. > require "benchmark" > kt = 10_000_000 > nn = 1 > nn.times{ puts Benchmark.measure { kt.times {a,b,c=1,2,3     } } } > nn.times{ puts Benchmark.measure { kt.times {a,b,c=1,2,3; nil} } } > nn.times{ puts Benchmark.measure { kt.times {a = 1; b = 2; c = 3 } } } > > jruby 1.5.3 (ruby 1.8.7 patchlevel 249) (2010-09-28 7ca06d7) >  (Java HotSpot(TM) Client VM 1.6.0_14) [x86-java] >  3.038000   0.000000   3.038000 (  3.007000) >  1.561000   0.000000   1.561000 (  1.562000) >  1.558000   0.000000   1.558000 (  1.558000) FWIW, you'd get better results here if you ran a couple iterations, and of course if you specified --server it's significantly better... ~/projects/jruby ➔ jruby -v passign.rb jruby 1.6.0.RC1 (ruby 1.8.7 patchlevel 330) (2011-01-14 da2bb9d) (Java HotSpot(TM) Client VM 1.6.0_22) [darwin-i386-java] 1.952000 0.000000 1.952000 ( 1.839000) 1.784000 0.000000 1.784000 ( 1.784000) 1.796000 0.000000 1.796000 ( 1.796000) 0.919000 0.000000 0.919000 ( 0.919000) 0.865000 0.000000 0.865000 ( 0.865000) 0.856000 0.000000 0.856000 ( 0.856000) 0.961000 0.000000 0.961000 ( 0.961000) 0.924000 0.000000 0.924000 ( 0.924000) 0.880000 0.000000 0.880000 ( 0.880000) ~/projects/jruby ➔ jruby --server -v passign.rb jruby 1.6.0.RC1 (ruby 1.8.7 patchlevel 330) (2011-01-14 da2bb9d) (Java HotSpot(TM) Server VM 1.6.0_22) [darwin-i386-java] 1.388000 0.000000 1.388000 ( 1.324000) 1.086000 0.000000 1.086000 ( 1.086000) 1.034000 0.000000 1.034000 ( 1.034000) 0.522000 0.000000 0.522000 ( 0.522000) 0.500000 0.000000 0.500000 ( 0.500000) 0.491000 0.000000 0.491000 ( 0.491000) 0.517000 0.000000 0.517000 ( 0.517000) 0.485000 0.000000 0.485000 ( 0.485000) 0.496000 0.000000 0.496000 ( 0.496000)