Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
2 contributors

Users who have contributed to this file

@sshaw @JuanitoFatas
18 lines (13 sloc) 248 Bytes
require 'benchmark/ips'
SLUG = 'ABCD'
def slow
SLUG.downcase == 'abcd'
end
def fast
SLUG.casecmp('abcd') == 0
end
Benchmark.ips do |x|
x.report('String#downcase + ==') { slow }
x.report('String#casecmp') { fast }
x.compare!
end
You can’t perform that action at this time.