summaryrefslogtreecommitdiff
path: root/benchmarks/casting.py
diff options
context:
space:
mode:
Diffstat (limited to 'benchmarks/casting.py')
-rw-r--r--benchmarks/casting.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/benchmarks/casting.py b/benchmarks/casting.py
new file mode 100644
index 000000000..5624fddfa
--- /dev/null
+++ b/benchmarks/casting.py
@@ -0,0 +1,17 @@
+from benchmark import Benchmark
+
+modules = ['numpy','Numeric','numarray']
+
+b = Benchmark(modules,
+ title='Casting a (10,10) integer array to float.',
+ runs=3,reps=10000)
+
+N = [10,10]
+b['numpy'] = ('b = a.astype(int)',
+ 'a=numpy.zeros(shape=%s,dtype=float)' % N)
+b['Numeric'] = ('b = a.astype("l")',
+ 'a=Numeric.zeros(shape=%s,typecode="d")' % N)
+b['numarray'] = ("b = a.astype('l')",
+ "a=numarray.zeros(shape=%s,typecode='d')" % N)
+
+b.run()