[Numpy-discussion] Ruby benchmark -- numpy is slower.... was: Re: Ruby's NMatrix and NVector

Anne Archibald peridot.faceted@gmail....
Fri May 16 10:00:51 CDT 2008

2008/5/16 David Cournapeau <david@ar.media.kyoto-u.ac.jp>:
> Sebastian Haase wrote:
>> Hi,
>> can someone comment on these timing numbers ?
>> http://narray.rubyforge.org/bench.html.en
>> Is the current numpy faster ?
> It is hard to know without getting the same machine or having the
> benchmark sources. But except for add, all other operations rely on
> underlying blas/lapack (only matrix operations do if you have no cblas),
> so I am a bit surprised by the results.
> FWIW, doing 100 x "c = a + b" with 1e6 elements on a PIV prescott @ 3.2
> Ghz is about 2 sec, and I count numpy start:
> import numpy as np
> a = np.random.randn(1e6)
> b = np.random.randn(1e6)
> for i in range(100):
>    a + b
> And np.dot(a, b) for 3 iterations and 500x500 takes 0.5 seconds (again
> taking into account numpy import), but what you really do here is
> benchmarking your underlying BLAS (if numpy.dot does use BLAS, again,
> which it does at least when built with ATLAS).

There are four benchmarks: add, multiply, dot, and solve. dot and
solve use BLAS, and for them numpy ruby and octave are comparable. Add
and multiply are much slower in numpy, but they are implemented in
numpy itself.

Exactly why add and multiply are slower is an interesting question -
loop overhead? striding? cache behaviour?


More information about the Numpy-discussion mailing list