Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 709954369a
Fetching contributors…

Cannot retrieve contributors at this time

58 lines (44 sloc) 1.36 KB
import numpy as np
import la
from autotimeit import autotimeit
def bench(verbose=True):
statements, setups = suite()
results = []
for key in statements:
if verbose:
print key
for stmt in statements[key]:
for shortname in setups:
t = autotimeit(stmt, setups[shortname])
results.append((stmt, shortname, t))
if verbose:
print '\t' + stmt
print '\t' + shortname
print '\t' + str(t)
return la.larry.fromtuples(results)
def fx(shape):
lar = la.randn(*shape)
return lar
def suite():
statements = {}
setups = {}
setups['(1000,)'] = "from bench import fx; N = 1000; x = fx((N,)); y = fx((N,)); idx = range(N)[::-1]"
setups['(500,500)'] = "from bench import fx; N = 500; x = fx((N, N)); y = fx((N, N)); idx = range(N)[::-1]"
# Unary
s = ['x.log()',
statements['unary'] = s
# Binary
s = ['x + x',
'x + y']
statements['binary'] = s
# Alignment
s = ['x.morph(idx, axis=0)',
'x.merge(y, update=True)']
statements['alignment'] = s
return statements, setups
Jump to Line
Something went wrong with that request. Please try again.