From: Josh Cheek Date: 2010-06-07T04:19:01+09:00 Subject: Re: How fast does your Ruby run? --0016e6d784e8880fc60488616def Content-Type: text/plain; charset=ISO-8859-1 On Sun, Jun 6, 2010 at 6:21 AM, Jian Lin wrote: > Program changed a little: > > n = 3_000_000 > > start_time = Time.now > > t = 0 > 1.upto(n) do |i| > t = (1..10).inject {|x, y| x + y } > end > > finish_time = Time.now > > p t > > puts > RUBY_VERSION ||= "unknown version" > RUBY_PATCHLEVEL ||= "unknown patchlevel" > RUBY_PLATFORM ||= "unknown platform" > > print "Ruby ", RUBY_VERSION, " patch ", RUBY_PATCHLEVEL, " on ", > RUBY_PLATFORM > > puts > print "It took #{finish_time - start_time} seconds to run." > print " #{(n / (finish_time - start_time)).to_i} iterations per > second.\n" > > > D:\>ruby calc.rb > 55 > > Ruby 1.9.1 patch 378 on i386-mingw32 > It took 6.414366 seconds to run. 467700 iterations per second. > > Dell with Intel Quad Core Q6600 > > ================================================================= > > C:\>ruby19\bin\ruby.exe calc.rb > 55 > > Ruby 1.9.1 patch 378 on i386-mingw32 > It took 5.289302 seconds to run. 567182 iterations per second. > > Dell with Intel i7 920, 2.67GHz > > the same machine, but using Ruby 1.8.7: > > Ruby 1.8.7 patch 249 on i386-mingw32 > It took 20.26816 seconds to run. 148015 iterations per second. > > -- > Posted via http://www.ruby-forum.com/. > > $rvm list rvm rubies jruby-1.4.0 [ [x86_64-java] ] jruby-1.5.0 [ [x86_64-java] ] macruby-0.6 [ x86_64 ] rbx-head [ x86_64 ] ruby-1.8.6-p399 [ x86_64 ] ruby-1.8.7-p174 [ x86_64 ] ruby-1.8.7-p249 [ x86_64 ] ruby-1.9.1-p378 [ x86_64 ] ruby-1.9.2-preview3 [ x86_64 ] # ===== 1.8.7 ===== $ rvm use 1.8.7-p249 info: Using ruby 1.8.7 p249 $ ruby calc.rb Ruby 1.8.7 patch 249 on i686-darwin10.3.0 It took 22.411302 seconds to run. 133861 iterations per second. # ===== 1.9.1 ===== $ rvm use 1.9.1 info: Using ruby 1.9.1 p378 $ ruby calc.rb Ruby 1.9.1 patch 378 on i386-darwin10.3.0 It took 4.696109 seconds to run. 638826 iterations per second. # ===== JRuby 1.5.0 ===== $ rvm use jruby info: Using jruby 1.5.0 $ ruby calc.rb Ruby 1.8.7 patch 249 on java It took 9.12 seconds to run. 328947 iterations per second. # ===== MacRuby 0.6 ===== $ rvm use macruby info: Using macruby 0.6 $ ruby calc.rb Ruby 1.9.0 patch 0 on universal-darwin10.0 It took 5.059672 seconds to run. 592923 iterations per second. # ===== Rubinius 1.0 ===== $ rvm use rbx-head info: Using rbx head $ ruby -v rubinius 1.0.0 (1.8.7 32151bb2 2010-05-14 JI) [x86_64-apple-darwin10.3.0] $ ruby calc.rb Ruby 1.8.7 patch 174 on x86_64-apple-darwin10.3.0 It took 19.90644 seconds to run. 150704 iterations per second. $ruby calc.rb Ruby 1.8.7 patch 174 on x86_64-apple-darwin10.3.0 It took 19.840837 seconds to run. 151203 iterations per second. Results are interesting, I still use 1.8.7 most of the time, because, regardless of what this test says, the only time I ever notice the speed of my Ruby is when I am running specs or rake tasks and 1.8.7 runs them noticeably faster (than 1.9.1, at least. I should try with some of the others, but since my last rvm update, I just seem to be having a lot of trouble with gems and versions). My Rubinius result seems unlikely to be an accurate reflection of that project, I thought the first time you run it it takes a long time b/c it has to compile bytecode, then after that, it uses the bytecode, and is much quicker. But it took just as long both times. I scanned their getting_started, and FAQ, and didn't see anything to suggest I am doing it wrong, so IDK. Perhaps I misunderstand the project, or need to optimize rbx by hand rather than letting rvm deal with it. --0016e6d784e8880fc60488616def--