forked from ksheedlo/chaos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrkperf.py
56 lines (47 loc) · 1.3 KB
/
rkperf.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
###############################################################################
#
# CSCI 4446 - Chaotic Dynamics
# File: rkperf.py
# Author: Ken Sheedlo
#
# Runge-Kutta profiling and performance analysis.
#
###############################################################################
from __future__ import division
import cProfile
import getopt
import lorenz
import numpy
import rungekutta
import sys
def runit():
lfunc = lorenz.lorenz(16, 45, 4)
ts, xxs = rungekutta.rk4(
lfunc,
0.0,
numpy.array([-13.0, -12.0, 52.0], dtype=numpy.float64),
0.0001,
100000
)
def main(argv=None):
if argv is None:
argv = sys.argv
filename = None
sort = None
try:
options, args = getopt.getopt(argv[1:], 'o:s:')
for opt, arg in options:
if opt == '-o':
filename = arg
if opt == '-s':
sort = arg
except getopt.GetoptError as err:
print str(err)
return 2
if sort is None:
cProfile.run(runit.func_code, filename)
else:
cProfile.run(runit.func_code, filename, sort)
return 0
if __name__ == "__main__":
sys.exit(main())