Skip to content

Instantly share code, notes, and snippets.

@rafaelss
Created August 5, 2014 16:21
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 rafaelss/aba61e9108faf11b988b to your computer and use it in GitHub Desktop.
Save rafaelss/aba61e9108faf11b988b to your computer and use it in GitHub Desktop.
require "benchmark/ips"
email = nil
Benchmark.ips do |x|
x.report('com if') { email.downcase.strip if email }
x.report('sem if') { email.to_s.downcase.strip }
end
Calculating -------------------------------------
com if 75866 i/100ms
sem if 56268 i/100ms
-------------------------------------------------
com if 7040009.2 (±18.0%) i/s - 33381040 in 5.003623s
sem if 1728021.7 (±20.0%) i/s - 8046324 in 5.000922s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment