Skip to content

Commit

Permalink
Add google benchmark for NormalEstimation
Browse files Browse the repository at this point in the history
  • Loading branch information
mvieth committed Nov 13, 2020
1 parent 09f705e commit 88131d4
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .ci/azure-pipelines/build/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ steps:
# find the commit hash on a quick non-forced update too
fetchDepth: 10
- script: |
brew install cmake pkg-config boost eigen flann glew libusb qhull vtk glew qt5 libpcap libomp brewsci/science/openni
brew install cmake pkg-config boost eigen flann glew libusb qhull vtk glew qt5 libpcap libomp google-benchmark brewsci/science/openni
git clone https://github.com/abseil/googletest.git $GOOGLE_TEST_DIR # the official endpoint changed to abseil/googletest
cd $GOOGLE_TEST_DIR && git checkout release-1.8.1
displayName: 'Install Dependencies'
Expand All @@ -19,6 +19,7 @@ steps:
-DPCL_ONLY_CORE_POINT_TYPES=ON \
-DBUILD_simulation=ON \
-DBUILD_global_tests=ON \
-DBUILD_benchmarks=ON \
-DBUILD_examples=ON \
-DBUILD_tools=ON \
-DBUILD_apps=ON \
Expand All @@ -34,6 +35,8 @@ steps:
displayName: 'Build Library'
- script: cd $BUILD_DIR && cmake --build . -- tests
displayName: 'Run Unit Tests'
- script: cd $BUILD_DIR && cmake --build . -- run_benchmarks
displayName: 'Run Benchmarks'
- task: PublishTestResults@2
inputs:
testResultsFormat: 'CTest'
Expand Down
1 change: 1 addition & 0 deletions .ci/azure-pipelines/build/ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ steps:
-DBUILD_simulation=ON \
-DBUILD_surface_on_nurbs=ON \
-DBUILD_global_tests=ON \
-DBUILD_benchmarks=ON \
-DBUILD_examples=ON \
-DBUILD_tools=ON \
-DBUILD_apps=ON \
Expand Down
3 changes: 2 additions & 1 deletion .ci/azure-pipelines/build/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ steps:
- pwsh: Get-PSDrive
displayName: "Check free space"
- script: |
vcpkg.exe install eigen3 flann gtest qhull --triplet %PLATFORM%-windows && vcpkg.exe list
vcpkg.exe install eigen3 flann gtest qhull benchmark --triplet %PLATFORM%-windows && vcpkg.exe list
displayName: 'Install C++ Dependencies Via Vcpkg'
- script: |
mkdir %BUILD_DIR% && cd %BUILD_DIR%
Expand All @@ -24,6 +24,7 @@ steps:
-DPCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32=ON ^
-DPCL_BUILD_WITH_QHULL_DYNAMIC_LINKING_WIN32=ON ^
-DBUILD_global_tests=ON ^
-DBUILD_benchmarks=ON ^
-DBUILD_tools=OFF ^
-DBUILD_surface_on_nurbs=ON
displayName: 'CMake Configuration'
Expand Down
20 changes: 20 additions & 0 deletions benchmarks/CMakeLists.txt
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)
29 changes: 29 additions & 0 deletions benchmarks/features.cpp
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();
}

0 comments on commit 88131d4

Please sign in to comment.