forked from compas-dev/compas_cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.py
46 lines (26 loc) · 901 Bytes
/
benchmark.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
from compas.geometry import Translation
from compas.geometry import transform_points
import time
# USING NATIVE PYTHON
pts = [[i, 0, 0] for i in range(0, 10000)]
T = Translation([100, 0, 0]).matrix
start = time.time()
for i in range(0, 100):
pts = transform_points(pts, T)
result1 = pts
end = time.time()
print('transform 10k points 100 times (native python): ', end - start, 's')
# USING CLOUD WITH CACHE
from compas_cloud import Proxy
proxy = Proxy()
transform_points_numpy = proxy.function('compas.geometry.transform_points_numpy', cache=True)
pts = [[i, 0, 0] for i in range(0, 10000)]
T = Translation([100, 0, 0]).matrix
start = time.time()
pts = proxy.cache(pts)
for i in range(0, 100):
pts = transform_points_numpy(pts, T)
result2 = proxy.get(pts)
end = time.time()
print('transform 10k points 100 times (cloud numpy): ', end - start, 's')
assert result1 == result2