(My results show that parallel assignment is slower in this test)

On Feb 15, 4:23=A0pm, Gavin <thinkersplaygro... / googlemail.com> wrote:
> Hey all
>
> I was always under the impression that parallel assignments in Ruby
> were faster than assigning variables individually.
>
> Recently I was curious to see how much faster it was and decided to
> test it:
>
> class One
>
> =A0 def initialize(first_name, last_name)
> =A0 =A0 @first_name =3D first_name
> =A0 =A0 @last_name =A0=3D last_name
> =A0 end
>
> end
>
> class Two
>
> =A0 def initialize(first_name, last_name)
> =A0 =A0 @first_name, @last_name =3D first_name, last_name
> =A0 end
>
> end
> require "rubygems"
> require "benchmark"
>
> Benchmark.bmbm do |test|
> =A0 test.report("serial") do
> =A0 =A0 10000.times { |n| var =3D =A0One.new("gavin#{n}", "morrice")}
> =A0 end
> =A0 test.report("parallel") do
> =A0 =A0 10000.times { |n| var =3D =A0Two.new("gavin#{n}", "morrice")}
> =A0 end
> end
>
> The results I get show that it's slower (in both Ruby 1.8.7 and Ruby
> 1.9.1)
>
> Can anyone elaborate?
>
> Thanks