[Numpy-discussion] strange sin/cos performance
Andrew Friedley
afriedle@indiana....
Mon Aug 3 08:32:57 CDT 2009
While working on GSoC stuff I came across this weird performance
behavior for sine and cosine -- using float32 is way slower than
float64. On a 2ghz opteron:
sin float32 1.12447786331
sin float64 0.133481025696
cos float32 1.14155912399
cos float64 0.131420135498
The times are in seconds, and are best of three runs of ten iterations
of numpy.{sin,cos} over a 1000-element array (script attached). I've
produced similar results on a PS3 system also. The opteron is running
Python 2.6.1 and NumPy 1.3.0, while the PS3 has Python 2.5.1 and NumPy
1.1.1.
I haven't jumped into the code yet, but does anyone know why sin/cos are
~8.5x slower for 32-bit floats compared to 64-bit doubles?
Side question: I see people in emails writing things like 'timeit
foo(x)' and having it run some sort of standard benchmark, how exactly
do I do that? Is that some environment other than a normal Python?
Thanks,
Andrew
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cos.py
Url: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090803/927ed646/attachment.pl
More information about the NumPy-Discussion
mailing list