-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speed comparison with cKDTree in Python #100
Comments
Output:
The second one's slower speed might make sense, but I don't understand why the third one is dramatically slower than the first one. |
Thanks for reporting the issue. I'm so curious about the performance gap. |
Oh my bad. I think now it should work. Could you retry it?: https://drive.google.com/file/d/1JCwTGCj8hMwKz5IDhKeWM3F2HuNN0vYJ/view?usp=sharing I also do not agree that the |
Thanks a lot! I did a quick benchmark and found that I replaced them with simple The benchmark code is as follows, which is based on your previous benchmark code. Please note that #!/bin/env python3
import time
import itertools
import small_gicp
import open3d as o3d
import numpy as np
from scipy.spatial import cKDTree
if __name__ == "__main__":
full_pcd = o3d.io.read_point_cloud("/home/koide/datasets/small_gicp/scene_rgb.ply")
f = open('result.csv', 'w')
print('num_threads,k,ckd_build,ckd_query,sg_build,sg_query')
print('num_threads,k,ckd_build,ckd_query,sg_build,sg_query', file=f)
def trial(k, num_threads):
locs_in = np.array(full_pcd.points)
start = time.time()
tree_pcd = cKDTree(locs_in)
mid = time.time()
dis, idx = tree_pcd.query(np.asarray(full_pcd.points), k=k, workers=num_threads)
end = time.time()
ckd_times = mid - start, end - mid
pcd1_cloud = small_gicp.PointCloud(locs_in)
start = time.time()
sg_tree2 = small_gicp.KdTree(pcd1_cloud, num_threads=num_threads)
mid = time.time()
k_indices, k_sq_dists = sg_tree2.batch_knn_search(locs_in, k, num_threads)
end = time.time()
sg_times = mid - start, end - mid
print('{},{},{},{},{},{}'.format(num_threads, k, ckd_times[0], ckd_times[1], sg_times[0], sg_times[1]))
print('{},{},{},{},{},{}'.format(num_threads, k, ckd_times[0], ckd_times[1], sg_times[0], sg_times[1]), file=f)
ks = [1, 2, 3, 4, 5, 10, 20]
num_threads = [1, 2, 4, 6, 8, 10, 12]
for k, n in itertools.product(ks, num_threads):
trial(k, n) #!/bin/env python3
import pandas
from matplotlib import pyplot
def main():
df = pandas.read_csv('result.csv')
ks = df['k'].unique()
fig, axes = pyplot.subplots(len(ks), 3, figsize=(15, 15))
for i, k in enumerate(ks):
data = df[df['k'] == k]
axes[i, 0].plot(data['num_threads'], data['ckd_build'], label='ckd')
axes[i, 1].plot(data['num_threads'], data['ckd_query'], label='ckd')
axes[i, 2].plot(data['num_threads'], data['ckd_build'] + data['ckd_query'], label='ckd')
axes[i, 0].plot(data['num_threads'], data['sg_build'], label='sg')
axes[i, 1].plot(data['num_threads'], data['sg_query'], label='sg')
axes[i, 2].plot(data['num_threads'], data['sg_build'] + data['sg_query'], label='sg')
axes[i, 0].legend()
axes[i, 1].legend()
axes[i, 2].legend()
axes[i, 0].set_title('build (k={})'.format(k))
axes[i, 1].set_title('query (k={})'.format(k))
axes[i, 2].set_title('total (k={})'.format(k))
axes[i, 0].set_ylabel('time [s]')
axes[i, 0].set_xlabel('num_threads')
axes[i, 1].set_xlabel('num_threads')
axes[i, 2].set_xlabel('num_threads')
fig.tight_layout()
pyplot.show()
if __name__ == '__main__':
main() Side note: |
Yep, it has been reproduced! Now you can merge the branch to the main in #101. It was also remarkable that we can build KdTree in multi-threading mode. |
P.S. I don't mind it because what I only use is |
I experienced the fast speed of small-gicp and wanted to use it in my Python code as follows:
However, surprisingly, it was slower than
cKDTree
in scipy.If you have some time, could you please give me some advice on this situation? The point cloud file can be downloaded here: https://drive.google.com/file/d/1JCwTGCj8hMwKz5IDhKeWM3F2HuNN0vYJ/view?usp=drive_link
The text was updated successfully, but these errors were encountered: