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 11, 2020
1 parent 09f705e commit 310ba9b
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 2 deletions.
3 changes: 2 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 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
1 change: 1 addition & 0 deletions .dev/docker/env/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN apt-get update \
libflann-dev \
libglew-dev \
libgtest-dev \
libbenchmark-dev \
libopenni-dev \
libopenni2-dev \
libproj-dev \
Expand Down
16 changes: 16 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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(example example.cpp)
target_link_libraries(example benchmark::benchmark pcl_io pcl_search pcl_features)
#TODO set_target_properties?
22 changes: 22 additions & 0 deletions benchmarks/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#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) {
// Perform setup here
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::PCDReader reader;
reader.read ("/home/markus/pcd_files/milk_cartoon_all_small_clorox.pcd", *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);
}
}
// Register the function as a benchmark
BENCHMARK(BM_NormalEstimation);
// Run the benchmark
BENCHMARK_MAIN();

0 comments on commit 310ba9b

Please sign in to comment.