nanoflann
nanoflann copied to clipboard
Tree building time in the example pointcloud_kdd_radius.cpp is far slow then expected
Hi I try to estimate the time consumed in building the KDtree for NN search. In the example pointcloud_kdd_radius.cpp I add the following clock() to tick the time for 100k points. But the results are both float and double cost around 150ms to build the tree. From the figures provided in main page the performance vs leaf max size, if we use default size 10, the tree building time would be around 40ms. Can anyone help explain this issue? Did I miss something to achieve the fastest speed? Thanks.
clock_t time_3 = clock();
// construct a kd-tree index:
typedef KDTreeSingleIndexAdaptor<
L2_Simple_Adaptor<num_t, PointCloud<num_t> > ,
PointCloud<num_t>,
3 /* dim */
> my_kd_tree_t;
my_kd_tree_t index(3 /*dim*/, cloud, KDTreeSingleIndexAdaptorParams(10 /* max leaf */) );
index.buildIndex();
clock_t time_4 = clock();
printf("buildTreeIndex Time: %f ms\n", ((float)(time_4-time_3))/CLOCKS_PER_SEC*1000);
Results of the example:
Generating 100000 point cloud...done
buildTreeIndex Time: 146.358994 ms
knnSearch(): num_results=5
idx[0]=25064 dist[0]=0.0069
idx[1]=19130 dist[1]=0.0347
idx[2]=38107 dist[2]=0.0372
idx[3]=6804 dist[3]=0.0392
idx[4]=73725 dist[4]=0.0393
radiusSearch(): radius=0.1 -> 9 matches
idx[0]=25064 dist[0]=0.0069
idx[1]=19130 dist[1]=0.0347
idx[2]=38107 dist[2]=0.0372
idx[3]=6804 dist[3]=0.0392
idx[4]=73725 dist[4]=0.0393
idx[5]=85821 dist[5]=0.0609
idx[6]=82218 dist[6]=0.0612
idx[7]=88824 dist[7]=0.0746
idx[8]=9122 dist[8]=0.0835
Generating 100000 point cloud...done
buildTreeIndex Time: 149.559006 ms
knnSearch(): num_results=5
idx[0]=612 dist[0]=0.0273
idx[1]=11864 dist[1]=0.0336
idx[2]=72817 dist[2]=0.0354
idx[3]=82734 dist[3]=0.0362
idx[4]=14155 dist[4]=0.0677
radiusSearch(): radius=0.1 -> 7 matches
idx[0]=612 dist[0]=0.0273
idx[1]=11864 dist[1]=0.0336
idx[2]=72817 dist[2]=0.0354
idx[3]=82734 dist[3]=0.0362
idx[4]=14155 dist[4]=0.0677
idx[5]=89222 dist[5]=0.0763
idx[6]=13352 dist[6]=0.0986
Check if your app is not in swap mode because of limited memory.