Created
October 3, 2012 00:32
-
-
Save tancnle/3824209 to your computer and use it in GitHub Desktop.
Benchmark single and double quotes
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" | |
n = 1000000 | |
Benchmark.bm do |x| | |
x.report("assign single") { n.times do; c = 'a string'; end} | |
x.report("assign double") { n.times do; c = "a string"; end} | |
x.report("assign interp") { n.times do; c = "a #{n} string"; end} | |
x.report("concat single") { n.times do; 'a string ' + 'b string'; end} | |
x.report("concat double") { n.times do; "a string " + "b string"; end} | |
x.report("concat interp") { n.times do; "a #{n} string " + "b #{n} string"; end} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment