[Numpy-discussion] How fast are small arrays currently?

David M. Cooke cookedm at physics.mcmaster.ca
Tue Jan 20 12:33:01 CST 2004

On Tue, Jan 20, 2004 at 02:42:03PM -0500, Edward C. Jones wrote:
> Has anyone recently benchmarked the speed of numarray vs. Numeric?

Just what I was doing :-)

Check out http://arbutus.mcmaster.ca/dmc/numpy/ for a graph comparing
the two.

Basically, I get on my machine (a 1.3 GHz Athlon running Linux), for an
array of size N (of Float), the time to do a+a is

Numeric:  3.7940e-6 + 2.2556e-8 * N seconds
numarray: 3.7062e-5 + 5.8497e-9 * N

For sin(a), 
Numeric:  1.7824e-6 + 1.1341e-7 * N
numarray: 2.8994e-5 + 9.8985e-8 * N

So the slowness of numarray vs. Numeric for small arrays is because of
an overhead of 3.7e-5 s for numarray, as opposed to 3.8e-6 s for
Numeric. Otherwise, numarray is 4 times faster for large arrays
for addition (and multiplication, which I've also checked).

The crossover is at arrays of about 2000 elements.

If this overhead could be reduced by a factor of 3 or 4, I'd be much
happier with using numarray for small arrays. But for now, it's not
good enough.

|David M. Cooke                      http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca

More information about the Numpy-discussion mailing list