-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
executable file
·65 lines (54 loc) · 1.82 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
from __future__ import division
import timeit
import sys
from pylab import *
import euler_01, euler_02, euler_03, euler_04, euler_05
import euler_06, euler_07, euler_08, euler_09, euler_10
import euler_11, euler_12, euler_13, euler_14, euler_15
import euler_16, euler_17, euler_18, euler_19, euler_20
x0 = array([0., 1.])
t = arange(0, 10, 0.01)
setup = '''
from __main__ import (euler_01, euler_02, euler_03, euler_04, euler_05,
euler_06, euler_07, euler_08, euler_09, euler_10,
euler_11, euler_12, euler_13, euler_14, euler_15,
euler_16, euler_17, euler_18, euler_19, euler_20, x0, t)
'''
statements = [
'euler_01.euler(euler_01.func, x0, t)',
'euler_02.euler(euler_02.func, x0, t)',
'euler_03.euler(euler_03.func, x0, t)',
'euler_04.euler(x0, t)',
'euler_05.euler(x0, t)',
'euler_06.euler(x0, t)',
'euler_07.euler(x0, t)',
'euler_08.euler(x0, t)',
'euler_09.euler(x0, t)',
'euler_10.euler(x0, t)',
'euler_11.euler(x0, t)',
'euler_12.euler(x0, t) # py - euler_11',
'euler_13.euler(x0, t)',
'euler_14.euler(x0, t) # py - euler_13',
'euler_15.euler(x0, t)',
'euler_16.euler(x0, t) # py - euler_15',
'euler_17.euler(x0, t)',
'euler_18.euler(x0, t) # py - euler_17',
'euler_19.euler(x0, t)',
'euler_20.euler(x0, t) # py - euler_19',
]
args = sys.argv[1:]
# Time all the statements
if not args:
REPEAT = 100
for stmt in statements:
result = timeit.timeit(stmt, setup, number=REPEAT)
usecs = int(1e6 * result / REPEAT)
print 'stmt: {0:40} t: {1} usecs'.format(stmt, usecs)
# Plot the results from executing a particular statement
elif len(args) == 1:
stmt = statements[int(args[0]) - 1]
print stmt
X = eval(stmt)
plot(t, X)
show()