Skip to content

Instantly share code, notes, and snippets.

@jstorimer
Created August 16, 2012 18:34
Show Gist options
  • Select an option

  • Save jstorimer/3372468 to your computer and use it in GitHub Desktop.

Select an option

Save jstorimer/3372468 to your computer and use it in GitHub Desktop.
Rehearsal -------------------------------------------------
string interp 0.200000 0.000000 0.200000 ( 0.202780)
array join 0.520000 0.020000 0.540000 ( 0.540294)
---------------------------------------- total: 0.740000sec
user system total real
string interp 0.210000 0.000000 0.210000 ( 0.216187)
array join 0.520000 0.000000 0.520000 ( 0.518884)
require 'benchmark'
Benchmark.bmbm do |x|
n = 1_000_000
subdomain = 'snowdevil'
x.report('string interp') do
n.times do
"#{subdomain}.myshopify.com"
end
end
x.report('array join') do
n.times do
[subdomain, '.myshopify.com'].join
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment