From: jzakiya Date: 2007-09-26T06:30:05+09:00 Subject: Re: How fast does your Ruby run? On Sep 20, 7:35 pm, Todd Burch wrote: > Todd Burch wrote: > > SpringFlowers AutumnMoon wrote: > >> How fast does your Ruby run? > > Ruby 1.8.2 on universal-darwin8.0 > > It took 6.383342 seconds to run. 156657 iterations per second. > > > (I had to take out RUBY_PATCHLEVEL, as that's not defined, but I suspect > > I could have put a begin/rescue/end in around and STILL have eaten your > > lunch. LOLOLOLOL > > Ruby 1.8.2 on universal-darwin8.0 > It took 5.920011 seconds to run. 168918 iterations per second. > > I changed the scope of x & y and eeked out some more speed. > > x, y = nil > for i in 1..n > t = (1..10).inject {|x, y| x + y } > end > > -- > Posted viahttp://www.ruby-forum.com/. -------------------------------------------------- n = 1_000_000 start_time = Time.now for i in 1..n t = (1..10).inject {|x, y| x + y } end run_time = start_time - Time.now p t puts print "Ruby ", RUBY_VERSION, " patch ", RUBY_PATCHLEVEL, " on ", RUBY_PLATFORM puts print "It took #{runt_time} seconds to run." print " #{(n / run-time).to_i} iterations per second.\n" --