Ruby 1.9 might just be faster than Python

I ran a micro-benchmark with Ruby 1.8.6, Ruby 1.9 and Python 2.5.1,
and was stunned by Ruby 1.9's improvements. Incidentally for my
particular test (which is a silly one...), Ruby was more than twice as
fast as Python!

We can't say for sure yet, but chances are that Ruby 1.9 is going to
be faster than CPython in most situations, which would be a great
accomplishment and step forward for the Ruby community. It's not a
competition, but a speed boost of this caliber is super welcomed. :slight_smile:

Cheers,
Antonio

what about python3.0? 5month is not a long time.

···

--------------------------------------------------
From: "Antonio Cangiano" <acangiano@gmail.com>
Sent: Wednesday, November 28, 2007 6:25 PM
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Subject: Ruby 1.9 might just be faster than Python

I ran a micro-benchmark with Ruby 1.8.6, Ruby 1.9 and Python 2.5.1,
and was stunned by Ruby 1.9's improvements. Incidentally for my
particular test (which is a silly one...), Ruby was more than twice as
fast as Python!

Holy Shmoly, Ruby 1.9 smokes Python away! | Programming Zen

We can't say for sure yet, but chances are that Ruby 1.9 is going to
be faster than CPython in most situations, which would be a great
accomplishment and step forward for the Ruby community. It's not a
competition, but a speed boost of this caliber is super welcomed. :slight_smile:

Cheers,
Antonio

As pointed numerous times on this list, this is perhaps because of
special changes that has went into
Ruby 1.9 for fixed point mathematics ( or integer math as charles tells us )

However, other benchmarks on programming shootout website still show
even Ruby1.9 slower than Python.....

But anyway..we never were mad about performance right?

···

On Nov 28, 2007 3:55 PM, Antonio Cangiano <acangiano@gmail.com> wrote:

I ran a micro-benchmark with Ruby 1.8.6, Ruby 1.9 and Python 2.5.1,
and was stunned by Ruby 1.9's improvements. Incidentally for my
particular test (which is a silly one...), Ruby was more than twice as
fast as Python!

Holy Shmoly, Ruby 1.9 smokes Python away! | Programming Zen

We can't say for sure yet, but chances are that Ruby 1.9 is going to
be faster than CPython in most situations, which would be a great
accomplishment and step forward for the Ruby community. It's not a
competition, but a speed boost of this caliber is super welcomed. :slight_smile:

--
Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.

http://gnufied.org

I'm also pleased to see how well 1.9 is advancing. :slight_smile: But it is still
possible to be faster. Here's another silly micro-benchmark...

==== bench.rb ====
require 'benchmark'

def test(n)
  n.times {
    h = Hash.new
    a = %w{a b c d e f g h i j k l m n
           o p q r s t u v w x y z}
    a.each { |l| h[l] = l.upcase }
    p =
    h.each { |k,v| p << [k, v] }
    p.each { |p1,p2| h.delete(p1) }
  }
end

Benchmark.bm { | x |
  x.report { test(100000) }
}

···

On Nov 28, 4:24 am, Antonio Cangiano <acangi...@gmail.com> wrote:

I ran a micro-benchmark with Ruby 1.8.6, Ruby 1.9 and Python 2.5.1,
and was stunned by Ruby 1.9's improvements. Incidentally for my
particular test (which is a silly one...), Ruby was more than twice as
fast as Python!

http://antoniocangiano.com/2007/11/28/holy-shmoly-ruby-19-smokes-pyth\.\.\.

We can't say for sure yet, but chances are that Ruby 1.9 is going to
be faster than CPython in most situations, which would be a great
accomplishment and step forward for the Ruby community. It's not a
competition, but a speed boost of this caliber is super welcomed. :slight_smile:

Cheers,
Antonio

==================

==== bench.py ====
from cProfile import run

def test(n):
  for i in xrange(n):
    h = dict()
    a = 'a b c d e f g h i j k l m n ' \
        'o p q r s t u v w x y z'
    for l in a.split():
      h[l] = l.upper()
    p =
    for k, v in h.items():
      p.append([k, v])
    for p1, p2 in p:
      del h[p1]

run('test(100000)')

Results:

$ ruby -v && ruby bench.rb
ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-linux]
      user system total real
24.340000 1.920000 26.260000 ( 28.686532)

$ ruby19 -v && ruby19 bench.rb
ruby 1.9.0 (2007-10-15 patchlevel 0) [i686-linux]
      user system total real
17.570000 0.050000 17.620000 ( 19.293883)

$ python -V && python bench.py
Python 2.5.1
         5400003 function calls in 14.798 CPU seconds

   Ordered by: standard name

   ncalls tottime percall cumtime percall
filename:lineno(function)
        1 0.000 0.000 14.798 14.798 <string>:1(<module>)
        1 11.015 11.015 14.798 14.798 bench.py:3(test)
  2600000 1.447 0.000 1.447 0.000 {method 'append' of
'list' objects}
        1 0.000 0.000 0.000 0.000 {method 'disable' of
'_lsprof.Profiler' objects}
   100000 0.279 0.000 0.279 0.000 {method 'items' of
'dict' objects}
   100000 0.509 0.000 0.509 0.000 {method 'split' of 'str'
objects}
  2600000 1.548 0.000 1.548 0.000 {method 'upper' of 'str'
objects}

So 1.8.6 comes it at 28.686532 seconds.
Version 1.9 shows a 33% improvement at 19.293883.
But python still takes the cake at 14.798 (49% improvement).

But like others have said, people don't use ruby because it's the
fastest language in the world. A beautiful person may be stupid, and a
smart person may be ugly; but no one ever asked to paint a portrait of
an ugly person, no matter how smart they were. :wink: Still, the fact that
current ruby 1.9 performed within 16% of python in this bechmark is
nice.

Regards,
Jordan

Python 3.0 might be faster, but it could just as well be slower. I've
not tested it, but it would be cool to include it in future testing.

Cheers,
Antonio

···

On Nov 28, 5:33 am, 庞旭晓 <longxux...@hotmail.com> wrote:

what about python3.0? 5month is not a long time.

"hemant" <gethemant@gmail.com> wrote in message
news:fb283d5e0711280259g5f40e5b0n6b97f5787c0bf414@mail.gmail.com...

···

On Nov 28, 2007 3:55 PM, Antonio Cangiano <acangiano@gmail.com> wrote:

I ran a micro-benchmark with Ruby 1.8.6, Ruby 1.9 and Python 2.5.1,
and was stunned by Ruby 1.9's improvements. Incidentally for my
particular test (which is a silly one...), Ruby was more than twice as
fast as Python!

Holy Shmoly, Ruby 1.9 smokes Python away! | Programming Zen

We can't say for sure yet, but chances are that Ruby 1.9 is going to
be faster than CPython in most situations, which would be a great
accomplishment and step forward for the Ruby community. It's not a
competition, but a speed boost of this caliber is super welcomed. :slight_smile:

As pointed numerous times on this list, this is perhaps because of
special changes that has went into
Ruby 1.9 for fixed point mathematics ( or integer math as charles tells
us )

However, other benchmarks on programming shootout website still show
even Ruby1.9 slower than Python.....

But anyway..we never were mad about performance right?

    Indeed, as Python moves towards iterators over actual lists, it will
only get faster...

I think what could be more important would be speedups on somewhat
bigger stuff like RoR or some heavy RMagick processing :slight_smile:

(I wouldnt think pythonistas nor ruby ciders did choose the one or the
other because of speed reasons anyway...)

···

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