Skip to content

Instantly share code, notes, and snippets.

@makaroni4
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makaroni4/6e0538dd4ac40f2eb80d to your computer and use it in GitHub Desktop.
Save makaroni4/6e0538dd4ac40f2eb80d to your computer and use it in GitHub Desktop.
require 'benchmark/ips'
require 'benchmark'
Benchmark.ips do |r|
r.report("one") do
'string' + 'string'
end
r.report("two") do
"string" + "string"
end
r.report("interpolate") do
string = "string"
"#{string}" + "#{string}"
end
end
# Calculating -------------------------------------
# one 58967 i/100ms
# two 60432 i/100ms
# interpolate 53134 i/100ms
# -------------------------------------------------
# one 1738566.2 (±5.9%) i/s - 8668149 in 5.004113s
# two 1727485.3 (±5.4%) i/s - 8641776 in 5.017653s
# interpolate 1328588.0 (±5.8%) i/s - 6641750 in 5.018399s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment