Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (29 sloc) 415 Bytes
require 'benchmark'
require 'benchmark/ips'
class RecurBench
def recur_fib(n)
if n == 0
0
else
recur(n - 1)
end
end
def normal_fib(n)
if n == 0
0
else
normal_fib(n - 1)
end
end
end
#
@b = Recurbench.new
Benchmark.ips do |x|
x.compare!
x.report "normal_fib" do
@b.normal_fib(9000)
end
x.report "recur_fib" do
@b.recur_fib(9000)
end
end