From: Mike McKinney Date: 2008-06-10T23:24:21+09:00 Subject: Re: Ruby vs JRuby Performance ------=_Part_15338_8955167.1213107872487 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline The JVM is built for long running processes, optimizing things over time (jruby takes advantage of this), MRI is going to remain the same speed over time. (for the most part, see below) here is a quick example... first the somewhat silly example code: ####################################### require 'benchmark' num = ARGV[0] || 10 puts "Running #{num} times" puts Benchmark.measure { num.to_i.times do 234 + 89239423 + 23482903 + 34892389423 + 234823 end }.total ####################################### now run it 10 times each: ( ruby/jruby speed.rb 10) ruby: 0.0 jruby: 0.0519 10,000 times: ruby:0.03 jruby:0.105 100,000 times: ruby: 0.26 jruby: 0.217 1,000,000 times: ruby: 2.61 jruby: 1.303 now with some additional optimization for the jvm: jruby -J-server speed.rb 1000000 jruby: 0.845 This is obviously a silly little test, but can possibly shed light on the start-up cost diffs between JRuby and MRI... and where the benefit lies. So who is faster? MRI? (yes) JRuby? (yes) just depends on what problem you are trying to solve. On Tue, Jun 10, 2008 at 9:24 AM, Leslie Viljoen wrote: > Just put a loop in your Ruby program: > > 12.times do > > ...main code > > end > > by restarting the JVM each time, you are not seeing any of JRuby's > benefits. > > Les > > -- Aloha! Mike McKinney (http://blog.huikau.com) ------=_Part_15338_8955167.1213107872487--