[Numpy-discussion] In-place operations

Charles R Harris charlesr.harris at gmail.com
Wed Sep 13 20:24:28 CDT 2006


On 9/13/06, Francesc Altet <faltet at carabos.com> wrote:
>
> El dt 12 de 09 del 2006 a les 13:28 -0600, en/na Travis Oliphant va
> escriure:
> > >[BTW, numpy.empty seems twice as slower in my machine. Why?
> > >
> > >
> > >>>>Timer("a=numpy.empty(10000,dtype=numpy.complex128)", "import
> > >>>>
> > >>>>
> > >numpy").repeat(3,10000)
> > >[0.37033700942993164, 0.31780219078063965, 0.31607294082641602]
> > >]
> > >
> > >
> > Now, you are creating an empty array with 10000 elements in it.
>
> Ups, my bad. So, here are the correct times for array creation:
>
> >>> Timer("a=numpy.empty(10,dtype=numpy.complex128)", "import
> numpy").repeat(3,10000)
> [0.083303928375244141, 0.080381870269775391, 0.077172040939331055]
> >>> Timer("a=numpy.empty(100,dtype=numpy.complex128)", "import
> numpy").repeat(3,10000)
> [0.086454868316650391, 0.084085941314697266, 0.083555936813354492]
> >>> Timer("a=numpy.empty(1000,dtype=numpy.complex128)", "import
> numpy").repeat(3,10000)
> [0.084996223449707031, 0.082299947738647461, 0.081347942352294922]
> >>> Timer("a=numpy.empty(10000,dtype=numpy.complex128)", "import
> numpy").repeat(3,10000)
> [0.31068897247314453, 0.30376386642456055, 0.30176281929016113]
> >>> Timer("a=numpy.empty(100000,dtype=numpy.complex128)", "import
> numpy").repeat(3,10000)
> [0.42552995681762695, 0.36864185333251953, 0.36870002746582031]
> >>> Timer("a=numpy.empty(1000000,dtype=numpy.complex128)", "import
> numpy").repeat(3,10000)
> [0.48045611381530762, 0.41251182556152344, 0.40645909309387207]
>
> So, it seems that there are a certain time dependency with size
>
> array of 10 elements       -->  7.7 us
> array of 100 elements      -->  8.4 us
> array of 1000 elements     -->  8.1 us
> array of 10000 elements    --> 30.2 us
> array of 100000 elements   --> 36.9 us
> array of 1000000 elements  --> 40.6 us



The transition looks a bit like a cache effect, although I don't see why the
cache should enter in. But all the allocations look pretty fast to me.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060913/b3a50b07/attachment-0001.html 


More information about the Numpy-discussion mailing list