require 'benchmark' N = 10_000 Benchmark.bm(20) do |x| x.report('<<') do N.times do |i| one = 'one' * i two = 'two' * i three = 'three' * i y = one << two << three end end x.report('+') do N.times do |i| one = 'one' * i two = 'two' * i three = 'three' * i y = one + two + three end end x.report('#{one}#{two}#{three}') do N.times do |i| one = 'one' * i two = 'two' * i three = 'three' * i y = "#{one}#{two}#{three}" end end x.report('one#{two}#{three}') do N.times do |i| two = 'two' * i three = 'three' * i y = "one#{two}#{three}" end end x.report('onetwo#{three}') do N.times do |i| three = 'three' * i y = "onetwo#{three}" end end end