Here is the proof that raise is slower than if
require 'benchmark' n = 5000000 puts "convertions" Benchmark.bm do |x| x.report("rescues") { n.times do ; true rescue ''; end } x.report("ifs") { n.times do ; raise '' if false; end } end
The results
user system total realrescues 0.880000 0.000000 0.880000 ( 0.880214)ifs 0.790000 0.000000 0.790000 ( 0.791239)
You win 0.09 seconds per 5m requests.
If you serve one page for 0.20 sec you have to made apx 10m page views and you will have one free as a reward of using ifs
But did you win? How ugly is your code?