diff options
author | Travis Oliphant <oliphant@enthought.com> | 2005-12-31 04:07:26 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2005-12-31 04:07:26 +0000 |
commit | c548d825f4bed8db889c9cc5928f5d073e6e3c12 (patch) | |
tree | 85f9803e385fd028521eb94c5bca3ffcf67e37d1 /benchmarks | |
parent | f0e7d011d97164370f47034fbee123beb4e8aaae (diff) | |
download | numpy-c548d825f4bed8db889c9cc5928f5d073e6e3c12.tar.gz |
Added benchmarks folder
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/sorting.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/benchmarks/sorting.py b/benchmarks/sorting.py new file mode 100644 index 000000000..c7869616f --- /dev/null +++ b/benchmarks/sorting.py @@ -0,0 +1,36 @@ +import timeit + +N = 10000 +t1 = timeit.Timer('a=array(None,shape=%d);a.sort()'%N,'from numarray import array') +t2 = timeit.Timer('a=empty(shape=%d);a.sort()'%N,'from scipy import empty') +t3 = timeit.Timer('a=empty(shape=%d);sort(a)'%N,'from Numeric import empty,sort') + +print "1-D length = ", N +print "Numarray: ", t1.repeat(3,100) +print "SciPy: ", t2.repeat(3,100) +print "Numeric: ", t3.repeat(3,100) + +N1,N2 = 100,100 +t1 = timeit.Timer('a=array(None,shape=(%d,%d));a.sort()'%(N1,N2),'from numarray import array') +t2 = timeit.Timer('a=empty(shape=(%d,%d));a.sort()'%(N1,N2),'from scipy import empty') +t3 = timeit.Timer('a=empty(shape=(%d,%d));sort(a)'%(N1,N2),'from Numeric import empty,sort') + +print "2-D shape = (%d,%d), last-axis" % (N1,N2) +print "Numarray: ", t1.repeat(3,100) +print "SciPy: ", t2.repeat(3,100) +print "Numeric: ", t3.repeat(3,100) + +N1,N2 = 100,100 +t1 = timeit.Timer('a=array(None,shape=(%d,%d));a.sort(0)'%(N1,N2),'from numarray import array') +t2 = timeit.Timer('a=empty(shape=(%d,%d));a.sort(0)'%(N1,N2),'from scipy import empty') +t3 = timeit.Timer('a=empty(shape=(%d,%d));sort(a,0)'%(N1,N2),'from Numeric import empty,sort') + +print "2-D shape = (%d,%d), first-axis" % (N1,N2) +print "Numarray: ", t1.repeat(3,100) +print "SciPy: ", t2.repeat(3,100) +print "Numeric: ", t3.repeat(3,100) + + + + + |