-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add google benchmark for NormalEstimation
- Loading branch information
Showing
5 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
set(SUBSYS_NAME benchmarks) | ||
set(SUBSYS_DESC "Point cloud library benchmarks") | ||
set(SUBSYS_DEPS common features search kdtree io) | ||
set(DEFAULT OFF) | ||
set(build TRUE) | ||
set(REASON "Disabled by default") | ||
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ${DEFAULT} "${REASON}") | ||
PCL_SUBSYS_DEPEND(build "${SUBSYS_NAME}" DEPS ${SUBSYS_DEPS}) | ||
if(NOT build) | ||
return() | ||
endif() | ||
|
||
find_package(benchmark REQUIRED) | ||
add_executable(benchmark_features features.cpp) | ||
target_link_libraries(benchmark_features benchmark::benchmark pcl_io pcl_search pcl_features) | ||
set_target_properties(benchmark_features PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) | ||
#add_test(NAME benchmark_features COMMAND benchmark_features ${PCL_SOURCE_DIR}/test/table_scene_mug_stereo_textured.pcd CONFIGURATIONS benchmarks) | ||
add_custom_target(run_benchmark_features benchmark_features ${PCL_SOURCE_DIR}/test/table_scene_mug_stereo_textured.pcd) | ||
add_custom_target(run_benchmarks) | ||
add_dependencies(run_benchmarks run_benchmark_features) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <benchmark/benchmark.h> | ||
#include <pcl/features/normal_3d.h> // for NormalEstimation | ||
#include <pcl/io/pcd_io.h> // for PCDReader | ||
|
||
static void BM_NormalEstimation(benchmark::State& state, const std::string& file) { | ||
// Perform setup here | ||
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>); | ||
pcl::PCDReader reader; | ||
reader.read (file, *cloud); | ||
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne; | ||
ne.setInputCloud (cloud); | ||
ne.setKSearch (100); | ||
pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>); | ||
for (auto _ : state) { | ||
// This code gets timed | ||
ne.compute (*cloud_normals); | ||
} | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
if (argc < 2) | ||
{ | ||
std::cerr << "No test file given. Please download `table_scene_mug_stereo_textured.pcd` and pass its path to the test." << std::endl; | ||
return (-1); | ||
} | ||
benchmark::RegisterBenchmark("BM_NormalEstimation", BM_NormalEstimation, argv[1]); | ||
benchmark::Initialize(&argc, argv); | ||
benchmark::RunSpecifiedBenchmarks(); | ||
} |