From: Francesc A. <fa...@op...> - 2003-02-12 13:03:17
|
Hi, Some days ago, I've also done some benchmarks on this issue, and I think that could be good to share my results.=20 I'm basically reproducing the figures of Tim, although that with a difference still bigger in favour of Numeric for small matrix (2x2). The benchmarks are made with a combination of Python and Pyrex (in order to t= est also some functions in Numeric and numarray C API). The figures I'm getting are, roughly: Matrix multiplication: In Python: matrixmultiply (double(2,2) x double(2,)) in Numeric: 70 us matrixmultiply (double(2,2) x double(2,)) in numarray: 4800 us In Pyrex: numarray multiply in Pyrex, using NA_InputArray: 620 us numarray multiply in Pyrex, using PyObject_AsWriteBuffer: 146 us zeros: In Python: double(2,) in Numeric: 58 us double(2,) in numarray: 3100 us In Pyrex (using PyArray_FromDims): double(2,) with Numeric: 26 us double(2,) with numarray: 730 us As, you can see, in pure Python, numarray has a factor of 50 (for zeros) = and up to 70 (for matrix multiply) times more overhead than Numeric. Increasi= ng the matrix to a 200x20 the overhead difference falls down to factor of 16 (for matrix multiply) and 50 (for zeros) always in favor of Numeric. With Pyrex (i.e. making the C calls), the differences are not so big, but there is still a difference. In particular, when assuming a contiguous matrix and calling PyObject_AsWriteBuffer directly upon the object._data memory buffer, the factor falls down to 2. Increasing the matrix to 200x2= 0, the overhead for zeros (using PyArray_FromDims) is the same for numarray than Numeric (around 700 us), while multiply in Pyrex can't beat the matrixmultiply in Numeric (Numeric is still 2 times faster). Hope that helps. I also can send you my testbeds if you are interested in= =2E --=20 Francesc Alted |