Skip to content

Instantly share code, notes, and snippets.

@bryanwoods
Created July 9, 2013 20:21
Show Gist options
  • Save bryanwoods/5960928 to your computer and use it in GitHub Desktop.
Save bryanwoods/5960928 to your computer and use it in GitHub Desktop.
require 'benchmark'
def no_rescue
1 + 1
end
def rescued
1 + 1
rescue Exception
end
Benchmark.bm do |x|
x.report do
100_000_000.times do
no_rescue
end
end
end
Benchmark.bm do |x|
x.report do
100_000_000.times do
rescued
end
end
end
__END__
howaboutwe@colvin:~$ ruby rescue_bench.rb
user system total real
8.240000 0.010000 8.250000 ( 8.300086)
user system total real
8.280000 0.010000 8.290000 ( 8.327114)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment