From 5cb3d759d601455e7e94b59d1baaf167782f3544 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Sat, 17 Feb 2007 18:36:16 +0000 Subject: Refactor benchmarks. --- benchmarks/creating.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'benchmarks/creating.py') diff --git a/benchmarks/creating.py b/benchmarks/creating.py index 462d2cd19..981c7fe47 100644 --- a/benchmarks/creating.py +++ b/benchmarks/creating.py @@ -1,9 +1,14 @@ -import timeit +from benchmark import Benchmark + +modules = ['numpy','Numeric','numarray'] + N = [10,10] -t1 = timeit.Timer('a=N.zeros(shape,type)','import numpy as N; shape=%s;type=float'%N) -t2 = timeit.Timer('a=N.zeros(shape,type)','import Numeric as N; shape=%s;type=N.Float'%N) -t3 = timeit.Timer('a=N.zeros(shape,type)',"import numarray as N; shape=%s;type=N.Float"%N) -print "shape = ", N -print "NumPy: ", t1.repeat(3,10000) -print "Numeric: ", t2.repeat(3,10000) -print "Numarray: ", t3.repeat(3,10000) +b = Benchmark(modules, + title='Creating %s zeros.' % N, + runs=3,reps=10000) + +b['numpy'] = ('a=N.zeros(shape,type)', 'shape=%s;type=float' % N) +b['Numeric'] = ('a=N.zeros(shape,type)', 'shape=%s;type=N.Float' % N) +b['numarray'] = ('a=N.zeros(shape,type)', "shape=%s;type=N.Float" % N) + +b.run() -- cgit v1.2.1