diff options
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/casting.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/benchmarks/casting.py b/benchmarks/casting.py new file mode 100644 index 000000000..84558a088 --- /dev/null +++ b/benchmarks/casting.py @@ -0,0 +1,9 @@ +import timeit +N = [1000,100] +t1 = timeit.Timer('b = a.astype(int)','import numpy;a=numpy.zeros(shape=%s,dtype=float)'%N) +t2 = timeit.Timer('b = a.astype("l")','import Numeric;a=Numeric.zeros(shape=%s,typecode="d")'%N) +t3 = timeit.Timer("b = a.astype('l')","import numarray; a=numarray.zeros(shape=%s,typecode='d')"%N) +print "1-D length = ", N +print "NumPy: ", t1.repeat(3,100) +print "Numeric: ", t2.repeat(3,100) +print "Numarray: ", t3.repeat(3,100) |