Created
July 9, 2013 20:21
-
-
Save bryanwoods/5960928 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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