[Numpy-discussion] A comparative test

Colin J. Williams cjw at sympatico.ca
Thu Oct 6 11:57:37 CDT 2005


# NumericNumarrayTest.py
''' A test, provided by Francesc Altet
    
http://sourceforge.net/mailarchive/forum.php?thread_id=6396059&forum_id=4890
    '''
from timeit import Timer
setup = "import Numeric; a = Numeric.arange(2000);a.shape=(1000,2)"
print 'Timer-Numeric23.8:', Timer("for i in range(len(a)): row=a[i]", 
setup).timeit(number=100)
 
#
setup = "import numarray; a = numarray.arange(2000);a.shape=(1000,2)"
print 'Timer-numarray1.3.3:', Timer("for i in range(len(a)): row=a[i]", 
setup).timeit(number=100)

# scipy/Numeric3 added
setup = "import scipy.base; a = scipy.base.arange(2000);a.shape=(1000,2)"
print 'Timer-Numeric3:', Timer("for i in range(len(a)): row=a[i]", 
setup).timeit(number=100)

RESULTS:
 >pythonw -u "NumericNumarrayTest.py"
Timer-Numeric23.8: 0.179712784725
Timer-numarray1.3.3: 0.21674933546
Timer-Numeric3: 0.253077136899
 >Exit code: 0
 
Colin W.




More information about the Numpy-discussion mailing list