summaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-02-28 18:46:35 -0700
committerCharles Harris <charlesr.harris@gmail.com>2013-02-28 18:46:35 -0700
commitd1e6fc3b81bc0557d74771cfffa04af2c62012f7 (patch)
treef3a82f46b98cc82bd4142b1bc71f7f9f8f4bac0c /benchmarks
parent0934653e151969f6912c911b5113306bd5f450f1 (diff)
downloadpython-numpy-d1e6fc3b81bc0557d74771cfffa04af2c62012f7.tar.gz
python-numpy-d1e6fc3b81bc0557d74771cfffa04af2c62012f7.tar.bz2
python-numpy-d1e6fc3b81bc0557d74771cfffa04af2c62012f7.zip
REM: Remove benchmarks files.
The files are very basic, old benchmarks testing numpy against numeric and numarray. The competitors are almost defunct and, while benchmarks are awesome, we really need a more polished and complete framework that runs against the current competition. I think the early results from these benchmarks were posted, maybe even presented, and could be found in a search. Closes #3088 ;) So old a tuple parameter was used.
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/benchmark.py42
-rw-r--r--benchmarks/casting.py17
-rw-r--r--benchmarks/creating.py14
-rw-r--r--benchmarks/simpleindex.py48
-rw-r--r--benchmarks/sorting.py25
5 files changed, 0 insertions, 146 deletions
diff --git a/benchmarks/benchmark.py b/benchmarks/benchmark.py
deleted file mode 100644
index 047379451..000000000
--- a/benchmarks/benchmark.py
+++ /dev/null
@@ -1,42 +0,0 @@
-from timeit import Timer
-
-class Benchmark(dict):
- """Benchmark a feature in different modules."""
-
- def __init__(self,modules,title='',runs=3,reps=1000):
- self.module_test = dict((m,'') for m in modules)
- self.runs = runs
- self.reps = reps
- self.title = title
-
- def __setitem__(self,module,(test_str,setup_str)):
- """Set the test code for modules."""
- if module == 'all':
- modules = self.module_test.keys()
- else:
- modules = [module]
-
- for m in modules:
- setup_str = 'import %s; import %s as np; ' % (m,m) \
- + setup_str
- self.module_test[m] = Timer(test_str, setup_str)
-
- def run(self):
- """Run the benchmark on the different modules."""
- module_column_len = max(len(mod) for mod in self.module_test)
-
- if self.title:
- print self.title
- print 'Doing %d runs, each with %d reps.' % (self.runs,self.reps)
- print '-'*79
-
- for mod in sorted(self.module_test):
- modname = mod.ljust(module_column_len)
- try:
- print "%s: %s" % (modname, \
- self.module_test[mod].repeat(self.runs,self.reps))
- except Exception as e:
- print "%s: Failed to benchmark (%s)." % (modname,e)
-
- print '-'*79
- print
diff --git a/benchmarks/casting.py b/benchmarks/casting.py
deleted file mode 100644
index 5624fddfa..000000000
--- a/benchmarks/casting.py
+++ /dev/null
@@ -1,17 +0,0 @@
-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()
diff --git a/benchmarks/creating.py b/benchmarks/creating.py
deleted file mode 100644
index 6f8dc0217..000000000
--- a/benchmarks/creating.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from benchmark import Benchmark
-
-modules = ['numpy','Numeric','numarray']
-
-N = [10,10]
-b = Benchmark(modules,
- title='Creating %s zeros.' % N,
- runs=3,reps=10000)
-
-b['numpy'] = ('a=np.zeros(shape,type)', 'shape=%s;type=float' % N)
-b['Numeric'] = ('a=np.zeros(shape,type)', 'shape=%s;type=np.Float' % N)
-b['numarray'] = ('a=np.zeros(shape,type)', "shape=%s;type=np.Float" % N)
-
-b.run()
diff --git a/benchmarks/simpleindex.py b/benchmarks/simpleindex.py
deleted file mode 100644
index e4e541d96..000000000
--- a/benchmarks/simpleindex.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import timeit
-# This is to show that NumPy is a poorer choice than nested Python lists
-# if you are writing nested for loops.
-# This is slower than Numeric was but Numeric was slower than Python lists were
-# in the first place.
-
-N = 30
-
-code2 = r"""
-for k in xrange(%d):
- for l in xrange(%d):
- res = a[k,l].item() + a[l,k].item()
-""" % (N,N)
-
-code3 = r"""
-for k in xrange(%d):
- for l in xrange(%d):
- res = a[k][l] + a[l][k]
-""" % (N,N)
-
-code = r"""
-for k in xrange(%d):
- for l in xrange(%d):
- res = a[k,l] + a[l,k]
-""" % (N,N)
-
-setup3 = r"""
-import random
-a = [[None for k in xrange(%d)] for l in xrange(%d)]
-for k in xrange(%d):
- for l in xrange(%d):
- a[k][l] = random.random()
-""" % (N,N,N,N)
-
-numpy_timer1 = timeit.Timer(code, 'import numpy as np; a = np.random.rand(%d,%d)' % (N,N))
-numeric_timer = timeit.Timer(code, 'import MLab as np; a=np.rand(%d,%d)' % (N,N))
-numarray_timer = timeit.Timer(code, 'import numarray.mlab as np; a=np.rand(%d,%d)' % (N,N))
-numpy_timer2 = timeit.Timer(code2, 'import numpy as np; a = np.random.rand(%d,%d)' % (N,N))
-python_timer = timeit.Timer(code3, setup3)
-numpy_timer3 = timeit.Timer("res = a + a.transpose()","import numpy as np; a=np.random.rand(%d,%d)" % (N,N))
-
-print "shape = ", (N,N)
-print "NumPy 1: ", numpy_timer1.repeat(3,100)
-print "NumPy 2: ", numpy_timer2.repeat(3,100)
-print "Numeric: ", numeric_timer.repeat(3,100)
-print "Numarray: ", numarray_timer.repeat(3,100)
-print "Python: ", python_timer.repeat(3,100)
-print "Optimized: ", numpy_timer3.repeat(3,100)
diff --git a/benchmarks/sorting.py b/benchmarks/sorting.py
deleted file mode 100644
index 5a23506b5..000000000
--- a/benchmarks/sorting.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from benchmark import Benchmark
-
-modules = ['numpy','Numeric','numarray']
-b = Benchmark(modules,runs=3,reps=100)
-
-N = 10000
-b.title = 'Sorting %d elements' % N
-b['numarray'] = ('a=np.array(None,shape=%d,typecode="i");a.sort()'%N,'')
-b['numpy'] = ('a=np.empty(shape=%d, dtype="i");a.sort()'%N,'')
-b['Numeric'] = ('a=np.empty(shape=%d, typecode="i");np.sort(a)'%N,'')
-b.run()
-
-N1,N2 = 100,100
-b.title = 'Sorting (%d,%d) elements, last axis' % (N1,N2)
-b['numarray'] = ('a=np.array(None,shape=(%d,%d),typecode="i");a.sort()'%(N1,N2),'')
-b['numpy'] = ('a=np.empty(shape=(%d,%d), dtype="i");a.sort()'%(N1,N2),'')
-b['Numeric'] = ('a=np.empty(shape=(%d,%d),typecode="i");np.sort(a)'%(N1,N2),'')
-b.run()
-
-N1,N2 = 100,100
-b.title = 'Sorting (%d,%d) elements, first axis' % (N1,N2)
-b['numarray'] = ('a=np.array(None,shape=(%d,%d), typecode="i");a.sort(0)'%(N1,N2),'')
-b['numpy'] = ('a=np.empty(shape=(%d,%d),dtype="i");np.sort(a,0)'%(N1,N2),'')
-b['Numeric'] = ('a=np.empty(shape=(%d,%d),typecode="i");np.sort(a,0)'%(N1,N2),'')
-b.run()