From: Jian Lin on 6 Jun 2010 07:21 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/.
From: Josh Cheek on 6 Jun 2010 15:19 [Note: parts of this message were removed to make it a legal post.] On Sun, Jun 6, 2010 at 6:21 AM, Jian Lin <blueskybreeze(a)gmail.com> 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.
From: Chuck Remes on 7 Jun 2010 08:04 On Jun 6, 2010, at 6:21 AM, Jian Lin wrote: > Program changed a little: Someone is going to point this out sooner or later so it may as well be me. Your "benchmark" doesn't test Ruby performance. It tests the performance of the Enumerable#inject method. Each runtime will have different results for running that one method but you can't really draw any conclusions about overall runtime performance. It's a micro-benchmark without a lot of usefulness. cr
From: Robert Dober on 7 Jun 2010 09:04 On Sun, Oct 28, 2007 at 9:33 PM, Daniel Berger <djberg96(a)gmail.com> wrote: > On Sep 20, 4:49 pm, SpringFlowers AutumnMoon > <summercooln...(a)gmail.com> wrote: >> How fast does your Ruby run? > > How fast does my Ruby run?! You've never heard of The Millenium Ruby? > It's the version that made the GNU/Kessel run in less than 12 > parsecs! > > It's run faster than Imperial programming languages. Not the local > bulk Java installs, mind you. I'm talking the big MS C# installs. Actually it runs slower than those, but it seems faster because the others normally depart when the Millenium Ruby has already arrived. Well depends on the pilot too. R.
From: Jian Lin on 7 Jun 2010 09:26 Chuck Remes wrote: > On Jun 6, 2010, at 6:21 AM, Jian Lin wrote: > >> Program changed a little: > > Someone is going to point this out sooner or later so it may as well be > me. > > Your "benchmark" doesn't test Ruby performance. It tests the performance > of the Enumerable#inject method. Each runtime will have different > results for running that one method but you can't really draw any > conclusions about overall runtime performance. It's a micro-benchmark > without a lot of usefulness. It is just to get an idea, really. How comprehensive do you expect the benchmark to be when the test is only 2 nested loops in 3 lines? -- Posted via http://www.ruby-forum.com/.
|
Next
|
Last
Pages: 1 2 Prev: [ANN] clogger 0.5.0 - body.to_path forwarding Next: libruby-nntp doesn't exist any more ? |