Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
24 lines (20 sloc) 286 Bytes
require 'benchmark/ips'
def slow
begin
writing
rescue
'fast ruby'
end
end
def fast
if respond_to?(:writing)
writing
else
'fast ruby'
end
end
Benchmark.ips do |x|
x.report('begin...rescue') { slow }
x.report('respond_to?') { fast }
x.compare!
end
You can’t perform that action at this time.