Skip to content

Instantly share code, notes, and snippets.

@ogarci5
Created October 20, 2014 22:10
Show Gist options
  • Save ogarci5/e8f2895543a706af52f7 to your computer and use it in GitHub Desktop.
Save ogarci5/e8f2895543a706af52f7 to your computer and use it in GitHub Desktop.
Benchmarking rescue versus conditional
require 'benchmark'
n = 1_000_000
Benchmark.bm do |x|
x.report { n.times {nil.asd if nil} }
x.report { n.times {nil.asd rescue nil} }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment