Skip to content

Commit 73a2832

Browse files
committed
Updated Python performance test.
1 parent 3c3b702 commit 73a2832

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

examples/python/kd_tree.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,20 @@ def performance_test_pico_tree():
112112
# benchmark", explains how to generate a scans.bin file from an online
113113
# dataset.
114114
try:
115-
p = np.fromfile(Path(__file__).parent / "scans.bin",
116-
np.float64).reshape((-1, 3))
115+
p0 = np.fromfile(Path(__file__).parent / "scans0.bin",
116+
np.float32).reshape((-1, 3))
117+
p1 = np.fromfile(Path(__file__).parent / "scans1.bin",
118+
np.float32).reshape((-1, 3))
117119
except FileNotFoundError as e:
118120
print(f"Skipping test. File does not exist: {e.filename}")
119121
return
120122

121123
cnt_build_time_before = perf_counter()
122124
# Tree creation is only slightly slower in Python vs C++ using the bindings.
123-
t = pt.KdTree(p, pt.Metric.L2Squared, 10)
124-
#t = spKDTree(p, leafsize=10)
125-
#t = spcKDTree(p, leafsize=10)
126-
#t = skKDTree(p, leaf_size=10)
125+
t = pt.KdTree(p0, pt.Metric.L2Squared, 10)
126+
#t = spKDTree(p0, leafsize=10)
127+
#t = spcKDTree(p0, leafsize=10)
128+
#t = skKDTree(p0, leaf_size=10)
127129
cnt_build_time_after = perf_counter()
128130
print(f"{t} was built in {(cnt_build_time_after - cnt_build_time_before) * 1000.0}ms")
129131
# Use the OMP_NUM_THREADS environment variable to influence the number of
@@ -142,11 +144,11 @@ def performance_test_pico_tree():
142144
# TODO The actual overhead is probably very similar to that of the KdTree
143145
# creation, but it would be nice to measure the overhead w.r.t. the actual
144146
# query.
145-
unused_knns = t.search_knn(p, k)
146-
# unused_dd, unused_ii = t.query(p, k=k)
147+
unused_knns = t.search_knn(p1, k)
148+
#unused_dd, unused_ii = t.query(p1, k=k)
147149
cnt_query_time_after = perf_counter()
148150
print(
149-
f"{len(p)} points queried in {(cnt_query_time_after - cnt_query_time_before) * 1000.0}ms")
151+
f"{len(p1)} points queried in {(cnt_query_time_after - cnt_query_time_before) * 1000.0}ms")
150152
print()
151153

152154

0 commit comments

Comments
 (0)