From: Alex Young Date: 2007-07-30T23:35:14+09:00 Subject: Re: Performance diffrence between ifs and case Gregory Brown wrote: > On 7/30/07, Alex Young wrote: > >> Benchmark.bmbm(20) do |x| >> x.report("if"){for i in 0..1000000 do > > Yuck! > > 1000000.times do ... end > Meh. require 'benchmark' def nop end Benchmark.bmbm(20) do |x| x.report("range"){for i in 0..1000000 do nop end} x.report("times"){1000000.times do nop end} end Rehearsal ------------------------------------------------------- range 0.578000 0.000000 0.578000 ( 0.594000) times 0.531000 0.000000 0.531000 ( 0.578000) ---------------------------------------------- total: 1.109000sec user system total real range 0.578000 0.000000 0.578000 ( 0.594000) times 0.578000 0.000000 0.578000 ( 0.578000) -- Alex