[Numpy-discussion] How fast are small arrays currently?
Perry Greenfield
perry at stsci.edu
Tue Jan 20 12:39:03 CST 2004
David M. Cooke writes:
> 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.
>
How many times do you do the operation for each size? Because of
caching, the first result may be much slower than the rest.
If you didn't could you try computing it by discarding the first
numarray time (or start timing after doing the first iteration)?
Thanks, Perry
More information about the Numpy-discussion
mailing list