Skip to content

Instantly share code, notes, and snippets.

@tak1n
Created June 5, 2014 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tak1n/a5236394137ad0a58118 to your computer and use it in GitHub Desktop.
Save tak1n/a5236394137ad0a58118 to your computer and use it in GitHub Desktop.
Ruby Fibonacci "Benchmark"
def fib(n)
if n == 0 || n == 1
n
else
fib(n-1) + fib(n-2)
end
end
36.times do |i|
puts "n=#{i} => #{fib(i)}"
end
Ruby HEAD - 7,36s user 0,02s system 99% cpu 7,390 total
Ruby 2.1.2 - 7,09s user 0,02s system 99% cpu 7,122 total
Ruby 2.1.1 - 7,02s user 0,01s system 99% cpu 7,049 total
Ruby 2.0.0 - 7,43s user 0,02s system 99% cpu 7,470 total
Ruby 1.9.3 - 10,75s user 0,02s system 99% cpu 10,787 total
Rubinius 2.2.7 - 2,50s user 0,05s system 106% cpu 2,388 total
Jruby 1.7.12 - 7,95s user 0,16s system 156% cpu 5,177 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment