Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v0.5.0
Fetching contributors…

Cannot retrieve contributors at this time

58 lines (44 sloc) 1.388 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
print key
for stmt in statements[key]:
for shortname in setups:
t = autotimeit(stmt, setups[shortname])
results.append((stmt, shortname, t))
if verbose:
print
print '\t' + stmt
print '\t' + shortname
print '\t' + str(t)
return la.larry.fromtuples(results)
def fx(shape):
lar = la.randn(*shape)
lar.shufflelabel()
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()',
'x.exp()',
'x.sqrt()',
'x.power(q=2)']
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.