Skip to content

Instantly share code, notes, and snippets.

@brixen
Created September 3, 2009 07:34
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 brixen/180170 to your computer and use it in GitHub Desktop.
Save brixen/180170 to your computer and use it in GitHub Desktop.
def fib(n)
return n if n < 2
fib(n-1) + fib(n-2)
end
Benchmark.bm do |x|
x.report { fib 40 }
end
gauss:rubinius brian$ ruby -r benchmark fib.rb
user system total real
153.620000 0.360000 153.980000 (157.128205)
gauss:rubinius brian$ ruby1.9 -r benchmark fib.rb
user system total real
33.450000 0.100000 33.550000 ( 34.083818)
gauss:rubinius brian$ bin/rbx -r benchmark fib.rb
user system total real
27.729074 0.000000 27.729074 ( 27.729094)
gauss:rubinius brian$ bin/rbx -XJ -r benchmark fib.rb
user system total real
9.568518 0.000000 9.568518 ( 9.568531)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment