[Numpy-discussion] [ANN] Nanny, faster NaN functions

Charles R Harris charlesr.harris@gmail....
Sat Nov 20 22:41:18 CST 2010

```On Sat, Nov 20, 2010 at 4:39 PM, Keith Goodman <kwgoodman@gmail.com> wrote:

> On Fri, Nov 19, 2010 at 7:42 PM, Keith Goodman <kwgoodman@gmail.com>
> wrote:
> > I should make a benchmark suite.
>
> >> ny.benchit(verbose=False)
> Nanny performance benchmark
>    Nanny 0.0.1dev
>    Numpy 1.4.1
>    Speed is numpy time divided by nanny time
>    NaN means all NaNs
>   Speed   Test                Shape        dtype    NaN?
>   6.6770  nansum(a, axis=-1)  (500,500)    int64
>   4.6612  nansum(a, axis=-1)  (10000,)     float64
>   9.0351  nansum(a, axis=-1)  (500,500)    int32
>   3.0746  nansum(a, axis=-1)  (500,500)    float64
>  11.5740  nansum(a, axis=-1)  (10000,)     int32
>   6.4484  nansum(a, axis=-1)  (10000,)     int64
>  51.3917  nansum(a, axis=-1)  (500,500)    float64  NaN
>  13.8692  nansum(a, axis=-1)  (10000,)     float64  NaN
>   6.5327  nanmax(a, axis=-1)  (500,500)    int64
>   8.8222  nanmax(a, axis=-1)  (10000,)     float64
>   0.2059  nanmax(a, axis=-1)  (500,500)    int32
>   6.9262  nanmax(a, axis=-1)  (500,500)    float64
>   5.0688  nanmax(a, axis=-1)  (10000,)     int32
>   6.5605  nanmax(a, axis=-1)  (10000,)     int64
>  48.4850  nanmax(a, axis=-1)  (500,500)    float64  NaN
>  14.6289  nanmax(a, axis=-1)  (10000,)     float64  NaN
>
>
Here's what I get using (my current) np.fmax.reduce in place of nanmax.

Speed   Test                Shape        dtype    NaN?
3.3717  nansum(a, axis=-1)  (500,500)    int64
5.1639  nansum(a, axis=-1)  (10000,)     float64
3.8308  nansum(a, axis=-1)  (500,500)    int32
6.0854  nansum(a, axis=-1)  (500,500)    float64
8.7821  nansum(a, axis=-1)  (10000,)     int32
1.1716  nansum(a, axis=-1)  (10000,)     int64
5.5777  nansum(a, axis=-1)  (500,500)    float64  NaN
5.8718  nansum(a, axis=-1)  (10000,)     float64  NaN
0.5419  nanmax(a, axis=-1)  (500,500)    int64
2.8732  nanmax(a, axis=-1)  (10000,)     float64
0.0301  nanmax(a, axis=-1)  (500,500)    int32
2.7437  nanmax(a, axis=-1)  (500,500)    float64
0.7868  nanmax(a, axis=-1)  (10000,)     int32
0.5535  nanmax(a, axis=-1)  (10000,)     int64
2.8715  nanmax(a, axis=-1)  (500,500)    float64  NaN
2.5937  nanmax(a, axis=-1)  (10000,)     float64  NaN

I think the really small int32 ratio is due to timing granularity. For
random ints in the range 0..99 the results are not quite as good for fmax,
which I find puzzling.

Speed   Test                Shape        dtype    NaN?
3.4021  nansum(a, axis=-1)  (500,500)    int64
5.5913  nansum(a, axis=-1)  (10000,)     float64
4.4569  nansum(a, axis=-1)  (500,500)    int32
6.6202  nansum(a, axis=-1)  (500,500)    float64
7.1847  nansum(a, axis=-1)  (10000,)     int32
2.0448  nansum(a, axis=-1)  (10000,)     int64
6.0257  nansum(a, axis=-1)  (500,500)    float64  NaN
6.3172  nansum(a, axis=-1)  (10000,)     float64  NaN
0.9598  nanmax(a, axis=-1)  (500,500)    int64
3.2407  nanmax(a, axis=-1)  (10000,)     float64
0.0520  nanmax(a, axis=-1)  (500,500)    int32
3.1954  nanmax(a, axis=-1)  (500,500)    float64
1.5538  nanmax(a, axis=-1)  (10000,)     int32
0.3716  nanmax(a, axis=-1)  (10000,)     int64
3.2372  nanmax(a, axis=-1)  (500,500)    float64  NaN
2.5633  nanmax(a, axis=-1)  (10000,)     float64  NaN

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20101120/086b8127/attachment-0001.html
```