Created
June 22, 2012 21:27
-
-
Save larzconwell/2975301 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
Desktop% ruby -v (~/Desktop) | |
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] | |
Desktop% cat benchmark_quotes.rb (~/Desktop) | |
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 string #{'b 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 } | |
end | |
Desktop% ruby -w benchmark_quotes.rb (~/Desktop) | |
user system total real | |
assign single 0.270000 0.010000 0.280000 ( 0.273250) | |
assign double 0.260000 0.000000 0.260000 ( 0.264455) | |
assign interp 0.270000 0.000000 0.270000 ( 0.265007) | |
concat single 0.630000 0.000000 0.630000 ( 0.637348) | |
concat double 0.630000 0.010000 0.640000 ( 0.634218) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment