public
Created — forked from ngauthier/readme.md

  • Download Gist
benchmark.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
require 'benchmark'
 
def ifelse
if true
1
else
2
end
end
 
def raiserescue
begin
raise
rescue
2
end
end
 
Benchmark.bm do |x|
x.report("if/else ") { 10_000.times { ifelse } }
x.report("raise/rescue") { 10_000.times { raiserescue } }
end
readme.md
Markdown

Using Exceptions to manage control flow in Rails Controllers...

is very very slow

results
1 2 3 4
~ $ ruby benchmark.rb
user system total real
if/else 0.000000 0.000000 0.000000 ( 0.000985)
raise/rescue 0.100000 0.000000 0.100000 ( 0.102185)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.