[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

why Ruby 1.8.2 is faster?

SpringFlowers AutumnMoon

9/20/2007 3:53:00 PM

I had Ruby 1.8.2 on the Mac so it was able to run a program with 10,000
iterations per second.

and then I installed 1.8.6 with Locomotive and then the program will
only run at about 6,500 iterations per second.

so i wonder why 1.8.2 is so much faster? obviously 1.8.6 has a lot more
features added to it.
--
Posted via http://www.ruby-....

3 Answers

Eric Hodel

9/20/2007 7:24:00 PM

0

On Sep 20, 2007, at 08:52, SpringFlowers AutumnMoon wrote:
> I had Ruby 1.8.2 on the Mac so it was able to run a program with
> 10,000
> iterations per second.
>
> and then I installed 1.8.6 with Locomotive and then the program will
> only run at about 6,500 iterations per second.
>
> so i wonder why 1.8.2 is so much faster? obviously 1.8.6 has a lot
> more
> features added to it.

What program?

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars



SpringFlowers AutumnMoon

9/20/2007 10:44:00 PM

0

Eric Hodel wrote:
>
> What program?



How about something just like:

on my Mac, the 1.8.2 runs about 46% faster than 1.8.6

------


n = 1_000_000

start_time = Time.now

for i in 1..n
t = (1..10).inject {|x, y| x + y }
end

finish_time = Time.now

p t

puts
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"




--
Posted via http://www.ruby-....

Eric Hodel

9/20/2007 11:17:00 PM

0

On Sep 20, 2007, at 15:44, SpringFlowers AutumnMoon wrote:
> Eric Hodel wrote:
>> What program?
> How about something just like:
>
> on my Mac, the 1.8.2 runs about 46% faster than 1.8.6
>
> [...]
>
> print "Ruby ", RUBY_VERSION, " patch ", RUBY_PATCHLEVEL, " on ",
> RUBY_PLATFORM

This program doesn't run on ruby 1.8.2, there is no RUBY_PATCHLEVEL.

$ /usr/bin/ruby -ve 'RUBY_PATCHLEVEL'
ruby 1.8.2 (2004-12-25) [universal-darwin8.0]
-e:1: warning: useless use of a constant in void context
-e:1: uninitialized constant RUBY_PATCHLEVEL (NameError)

I used this one, which seems to be the core of it:

for i in 1..1_000_000
t = (1..10).inject {|x, y| x + y }
end

And I got opposite results:

$ pbpaste | time ruby -v -
ruby 1.8.6 (2007-06-30 patchlevel 5000) [i686-darwin8.10.1]
12.37 real 12.29 user 0.01 sys
$ pbpaste | time /usr/bin/ruby -v -
ruby 1.8.2 (2004-12-25) [universal-darwin8.0]
16.23 real 16.13 user 0.02 sys

1.8.6 is 24% faster in this test.

and for what its worth:

$ pbpaste | time ruby19 -v -
ruby 1.9.0 (2007-09-15 patchlevel 0) [i686-darwin8.10.1]
syck.so: warning: method redefined; discarding old value
3.57 real 3.50 user 0.01 sys

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars