Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
18 lines (13 sloc) 231 Bytes
require 'benchmark/ips'
SLUG = 'writing-fast-ruby'
def slow
SLUG.gsub('-', ' ')
end
def fast
SLUG.tr('-', ' ')
end
Benchmark.ips do |x|
x.report('String#gsub') { slow }
x.report('String#tr') { fast }
x.compare!
end
You can’t perform that action at this time.