Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
How fast does your Ruby run?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Jian Lin, post: 4664920"] 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. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
How fast does your Ruby run?
Top