Skip to content

Instantly share code, notes, and snippets.

@cooljl31
Created December 20, 2022 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cooljl31/059253cc1519117c884cb8fbb9906dab to your computer and use it in GitHub Desktop.
Save cooljl31/059253cc1519117c884cb8fbb9906dab to your computer and use it in GitHub Desktop.
Benchmark example
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