Skip to content

Instantly share code, notes, and snippets.

@jherdman
Created January 6, 2009 21:44
Show Gist options
  • Save jherdman/44016 to your computer and use it in GitHub Desktop.
Save jherdman/44016 to your computer and use it in GitHub Desktop.
## Note to self...
include Benchmark
number = 2
year = 2008
bmbm(6) do |x|
x.report 'joining' do
10_000.times do
['Q', number, ' ', year].join
end
end
x.report 'interpolation' do
10_000.times do
"Q#{number} #{year}"
end
end
end
# Rehearsal -------------------------------------------------
# joining 0.251000 0.000000 0.251000 ( 0.280000)
# interpolation 0.200000 0.000000 0.200000 ( 0.271000)
# ---------------------------------------- total: 0.451000sec
# user system total real
# joining 0.090000 0.000000 0.090000 ( 0.090000)
# interpolation 0.040000 0.000000 0.040000 ( 0.040000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment