-
Notifications
You must be signed in to change notification settings - Fork 1
/
ke_timing.py
executable file
·59 lines (40 loc) · 1.33 KB
/
ke_timing.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
#! /usr/bin/ipython
import numpy as np
import ke
from gplot import *
from pause import *
ke._Ecs(0.0001, 1., n=15)
ke.E(0.0001, 1., n=15, typ='atr')
x=np.arange(0,10,0.001); y=1*x; ke._ke_newton.v_cos(x,y, x.size); gplot(x,y-np.cos(x))
x=np.arange(0,10,0.001); y=1*x; ke._ke_newton.v_sin(x,y, x.size); gplot(x,y-np.sin(x))
e = 1.0
E = np.arange(-10,6,0.001)
E = np.arange(0,3,0.001); M = ke.M(E, e)
if 0:
gplot(M, E, ke._E_newton(M, e), ke.E(M, e, n=55, typ='atr'), ' us 1:3, "" us 1:4')
gplot('"" us 1:($3-$2), "" us 1:($4-$2)')
gplot(M, np.log10(np.abs(ke._E(M, e, n=55)-E)))
pause()
M = np.arange(0, np.pi, np.pi/1000);
timeit ke._E(M, e, n=29)
#1000 loops, best of 3: 1.51 ms per loop
timeit ke.E(M, e, n=29)
#1000 loops, best of 3: 1.51 ms per loop
timeit ke._Ecs(M, e, n=29)
#1000 loops, best of 3: 1.54 ms per loop
timeit ke.E(M, e, n=29, typ='pn')
#1000 loops, best of 3: 1.7 ms per loop
timeit ke.E(M, e, n=29, typ='atr')
#100 loops, best of 3: 2.1 ms per loop
timeit ke._E1N(M, e, n=19)
#1000 loops, best of 3: 966 µs per loop
timeit ke._E_newton(M, e)
#100 loops, best of 3: 2.95 ms per loop
timeit ke._E_newton(M, e)
#100 loops, best of 3: 3.22 ms per loop
timeit ke._E_newton(M, e, typ="my")
#100 loops, best of 3: 2.43 ms per loop
timeit ke.E(M, e, n=29)
timeit ke.E(M, e, n=2, typ="N")
# ~ same speed =>
# 29/2