Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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