Hi,
I’ve read in multiple places that JRuby is supposed to be faster than
standard ruby 1.8.7. I am seeing the exact opposite. I would love to
find the problem.
My setup
-Ubuntu 11.04
-Open JDK “java version "1.6.0_22"”
-JRuby 1.6.2 downloaded from jruby.org and unzipped
-Ruby 1.8.7 (patchlevel 302)
I am running a simple script that calculates the n’th number in the
fibonacci sequence.
-----------Code (fib.rb)-----------
def calcFibN(num)
fib_array = [0,1]
(num-2).times do |i|
fib_array << (fib_array[i] + fib_array[i+1])
end
puts fib_array.join(", ")
end
calcFibN(ARGV[0].to_i)
-----------End (fib.rb)-----------
what I see
time ruby fib.rb 30
real: 0m0.018s
time jruby fib.rb 30
real: 0m1.925s
I also tried jruby’s benchmark mode and it returned 420ms, which is
still much more than what ‘time ruby fib.rb 30’ returned
This performace is not only slower than ruby, it’s practically unusable.
What have I done wrong?
Thank you all
Whit
-----------Edit-------------
For further info. I have a very similar java app written and I get
time java Fib 30
real: 0m0.125s
and a copy written in gnu c99
time ./fib 30
real: 0m0.005ms