Created
March 21, 2013 17:25
-
-
Save toothrot/5214870 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' | |
Benchmark.bmbm do |x| | |
x.report "double quotes" do | |
10_000_000.times do | |
"foo" | |
end | |
end | |
x.report "single quotes" do | |
10_000_000.times do | |
'foo' | |
end | |
end | |
end |
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
$ ruby strings_bench.rb | |
Rehearsal ------------------------------------------------- | |
double quotes 2.810000 0.010000 2.820000 ( 2.809821) | |
single quotes 2.810000 0.000000 2.810000 ( 2.815568) | |
---------------------------------------- total: 5.630000sec | |
user system total real | |
double quotes 2.810000 0.000000 2.810000 ( 2.808336) | |
single quotes 2.810000 0.000000 2.810000 ( 2.812794) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment