Created
December 20, 2022 09:56
-
-
Save cooljl31/059253cc1519117c884cb8fbb9906dab to your computer and use it in GitHub Desktop.
Benchmark example
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
Benchmark.ips do |x| | |
x.config(time: 30, warmup: 2) | |
x.report('gsub') { string.gsub(/ /, '') } | |
x.report('gsub, no regex') { string.gsub(' ', '') } | |
x.report('tr') { string.tr(' ','') } | |
x.report('delete') { string.delete(' ') } | |
x.compare! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment