Benchmarking ruby string interpolation vs. concatenation

Ever wondered if there was a significant difference in performance between string interpolation vs. concatenation in ruby? Me too! So I put together this simple benchmark:

concatenation.rb

t = Time.now
a = []
10_000_000.times do
  a << "a" + " " + "b"
end
puts Time.now.to_f - t.to_f

interpolation.rb

t = Time.now
a = []
10_000_000.times do
  a << "#{"a"} #{"b"}"
end
puts Time.now.to_f - t.to_f

Results

➔ ruby interpolation.rb
1.5596427917480469
➔ ruby concatenation.rb
7.423596143722534

So there you have it. Interpolation is about 4.5x faster.

What do you think about my testing methodology? Is there a better way? Let me know!