Created
September 19, 2011 01:33
-
-
Save IndianGuru/1225814 to your computer and use it in GitHub Desktop.
JRuby Compiler course example1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
def factorial(n) | |
(1..n).inject(1) { |product, value| product * value } | |
end | |
3.times do | |
timing = Benchmark.measure do | |
result = factorial(10000) | |
end | |
puts timing | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment