Created
February 11, 2021 20:25
-
-
Save tarellel/83526c47ebf5ad226085ead25c835fde to your computer and use it in GitHub Desktop.
Ruby Single VS Double Quotes
This file contains hidden or 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' | |
Benchmark.ips do |x| | |
x.report('Single quotes') { 'String of Characters' } | |
x.report('Double Quotes') { "String of Characters" } | |
x.compare! | |
end | |
# Warming up -------------------------------------- | |
# Single quotes 1.745M i/100ms | |
# Double Quotes 1.736M i/100ms | |
# Calculating ------------------------------------- | |
# Single quotes 17.583M (± 1.1%) i/s - 89.016M in 5.063070s | |
# Double Quotes 17.241M (± 2.9%) i/s - 86.818M in 5.040132s | |
# | |
# Comparison: | |
# Single quotes: 17583468.6 i/s | |
# Double Quotes: 17241297.9 i/s - same-ish: difference falls within error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment