Last active
August 29, 2015 14:03
-
-
Save makaroni4/6e0538dd4ac40f2eb80d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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