-
Notifications
You must be signed in to change notification settings - Fork 13
/
perf.py
71 lines (61 loc) · 1.95 KB
/
perf.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
66
67
68
69
70
71
import dijkstra3d
import numpy as np
import time
def edf():
print("Running edf.")
N = 1
sx, sy, sz = 256, 256, 256
values = np.ones((sx,sy,sz), dtype=bool)
for i in range(5):
s = time.time()
dijkstra3d.euclidean_distance_field(values, (100,100,100))
e = time.time()
accum = e-s
mvx = N * sx * sy * sz / accum / 1000000
print(f"{mvx:.3f} MVx/sec ({accum:.3f} sec)")
def bidiagonal_ones():
print("Running bidiagonal_ones.")
N = 1
sx, sy, sz = 512, 512, 512
values = np.ones((sx,sy,sz), dtype=np.uint32)
s = time.time()
dijkstra3d.dijkstra(values, (0,0,0), (sx-1,sy-1,sz-1), bidirectional=True)
e = time.time()
accum = e-s
mvx = N * sx * sy * sz / accum / 1000000
print(f"{mvx:.3f} MVx/sec ({accum:.3f} sec)")
def diagonal_ones():
print("Running diagonal_ones.")
N = 1
sx, sy, sz = 512, 512, 512
values = np.ones((sx,sy,sz), dtype=np.uint32)
s = time.time()
dijkstra3d.dijkstra(values, (0,0,0), (sx-1,sy-1,sz-1), compass=False)
e = time.time()
accum = e-s
mvx = N * sx * sy * sz / accum / 1000000
print(f"{mvx:.3f} MVx/sec ({accum:.3f} sec)")
def random_paths():
print("Running random_paths.")
values = np.random.randint(1,255, size=(7,7,7))
values = np.asfortranarray(values)
start = np.random.randint(0,7, size=(3,))
target = np.random.randint(0,7, size=(3,))
N = 1
sx, sy, sz = 500, 500, 500
for n in range(1, 100, 1):
accum = 0
for i in range(N):
values = np.random.randint(1,n+1, size=(sx,sy,sz))
values = np.asfortranarray(values)
# values = np.ones((sx,sy,sz)) / 1000
start = np.random.randint(0,min(sx,sy,sz), size=(3,))
target = np.random.randint(0,min(sx,sy,sz), size=(3,))
s = time.time()
path_orig = dijkstra3d.dijkstra(values, start, target, bidirectional=True)
accum += (time.time() - s)
mvx = N * sx * sy * sz / accum / 1000000
print(f"{n} {mvx:.3f} MVx/sec ({accum:.3f} sec)")
# edf()
bidiagonal_ones()
random_paths()