forked from mass2010chromium/motion-c
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile_vo.py
More file actions
40 lines (35 loc) · 711 Bytes
/
profile_vo.py
File metadata and controls
40 lines (35 loc) · 711 Bytes
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
#from klampt.math import vectorops as vo1
import motionlib.vectorops as vo2
import numpy as np
import numpy.linalg as la
import time
v1 = [1.0, 1.5, -2.8]
v2 = [0.6, -0.7, 0.2]
v3 = [0.0, 0.0, 0.0]
c = 2
v1 += v1
v2 += v2
NITER = 10000
#ts = time.time()
#for i in range(NITER):
# v3 = vo1.madd(v1, v2, c)
# c = vo1.norm(v2)
# #v3 = vo1.add(v1, v2)
#te = time.time()
#print(te - ts)
ts = time.time()
for i in range(NITER):
v3 = vo2.madd(v1, v2, c)
c = vo2.norm(v2)
#v3 = vo2.add(v1, v2)
te = time.time()
print(te - ts)
v1 = np.array(v1)
v2 = np.array(v2)
ts = time.time()
for i in range(NITER):
v3 = v1 + v2 * c
c = la.norm(v2)
#v3 = v1 + v2
te = time.time()
print(te - ts)