Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 58 lines (44 sloc) 1.388 kb
2bf9ae0 @kwgoodman * sandbox, sandbox/autotimeit.py, sandbox/bench.py: Added a sandbox ...
authored
1
2 import numpy as np
3
4 import la
5
6 from autotimeit import autotimeit
7
8 def bench(verbose=True):
9 statements, setups = suite()
10 results = []
11 for key in statements:
12 if verbose:
13 print
14 print key
15 for stmt in statements[key]:
16 for shortname in setups:
17 t = autotimeit(stmt, setups[shortname])
18 results.append((stmt, shortname, t))
19 if verbose:
20 print
21 print '\t' + stmt
22 print '\t' + shortname
23 print '\t' + str(t)
24 return la.larry.fromtuples(results)
25
26 def fx(shape):
c8be5a2 @kwgoodman * doc/source/archive.rst, func.py, tests/io_test.py, sandbox/bench.p...
authored
27 lar = la.randn(*shape)
2bf9ae0 @kwgoodman * sandbox, sandbox/autotimeit.py, sandbox/bench.py: Added a sandbox ...
authored
28 lar.shufflelabel()
29 return lar
30
31 def suite():
32
33 statements = {}
34 setups = {}
35
36 setups['(1000,)'] = "from bench import fx; N = 1000; x = fx((N,)); y = fx((N,)); idx = range(N)[::-1]"
37 setups['(500,500)'] = "from bench import fx; N = 500; x = fx((N, N)); y = fx((N, N)); idx = range(N)[::-1]"
38
39 # Unary
40 s = ['x.log()',
41 'x.exp()',
42 'x.sqrt()',
43 'x.power(q=2)']
44 statements['unary'] = s
45
46 # Binary
47 s = ['x + x',
48 'x + y']
49 statements['binary'] = s
50
51 # Alignment
52 s = ['x.morph(idx, axis=0)',
53 'x.merge(y, update=True)']
54 statements['alignment'] = s
55
56 return statements, setups
57
Something went wrong with that request. Please try again.