optional boost bench

This commit is contained in:
2019-05-09 00:02:24 +07:00
parent a8bcd40cdd
commit 916ba1bd7f
3 changed files with 31 additions and 11 deletions

View File

@@ -7,8 +7,8 @@ project(flat.hpp.unbench)
# boost # boost
# #
find_package(Boost REQUIRED find_package(Boost
COMPONENTS container) OPTIONAL_COMPONENTS container)
# #
# google benchmark # google benchmark
@@ -33,8 +33,16 @@ endif()
file(GLOB UNBENCH_SOURCES "*.cpp" "*.hpp") file(GLOB UNBENCH_SOURCES "*.cpp" "*.hpp")
add_executable(${PROJECT_NAME} ${UNBENCH_SOURCES}) add_executable(${PROJECT_NAME} ${UNBENCH_SOURCES})
target_link_libraries(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME}
Boost::container
benchmark_main benchmark_main
flat.hpp) flat.hpp)
if(Boost_CONTAINER_FOUND)
target_link_libraries(${PROJECT_NAME}
Boost::container)
target_compile_definitions(${PROJECT_NAME}
PRIVATE BOOST_CONTAINER_FOUND)
endif()
add_test(${PROJECT_NAME} ${PROJECT_NAME}) add_test(${PROJECT_NAME} ${PROJECT_NAME})

View File

@@ -10,7 +10,9 @@ using namespace flat_hpp_unbench;
#include <flat_hpp/flat_map.hpp> #include <flat_hpp/flat_map.hpp>
using namespace flat_hpp; using namespace flat_hpp;
#include <boost/container/flat_map.hpp> #ifdef BOOST_CONTAINER_FOUND
# include <boost/container/flat_map.hpp>
#endif
namespace namespace
{ {
@@ -26,6 +28,7 @@ namespace
} }
} }
#ifdef BOOST_CONTAINER_FOUND
template < typename Value > template < typename Value >
void boost_flat_map_insert(benchmark::State& state) { void boost_flat_map_insert(benchmark::State& state) {
std::vector<int> v; std::vector<int> v;
@@ -37,6 +40,7 @@ namespace
} }
} }
} }
#endif
template < typename Value > template < typename Value >
void std_map_insert(benchmark::State& state) { void std_map_insert(benchmark::State& state) {
@@ -67,9 +71,11 @@ BENCHMARK_TEMPLATE(flat_map_insert, vec4)
->ComputeStatistics("min", min_bench_statistics) ->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50); ->DenseRange(1,401,50);
BENCHMARK_TEMPLATE(boost_flat_map_insert, vec4) #ifdef BOOST_CONTAINER_FOUND
->ComputeStatistics("min", min_bench_statistics) BENCHMARK_TEMPLATE(boost_flat_map_insert, vec4)
->DenseRange(1,401,50); ->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#endif
BENCHMARK_TEMPLATE(std_map_insert, vec4) BENCHMARK_TEMPLATE(std_map_insert, vec4)
->ComputeStatistics("min", min_bench_statistics) ->ComputeStatistics("min", min_bench_statistics)

View File

@@ -10,7 +10,9 @@ using namespace flat_hpp_unbench;
#include <flat_hpp/flat_set.hpp> #include <flat_hpp/flat_set.hpp>
using namespace flat_hpp; using namespace flat_hpp;
#include <boost/container/flat_set.hpp> #ifdef BOOST_CONTAINER_FOUND
# include <boost/container/flat_set.hpp>
#endif
namespace namespace
{ {
@@ -26,6 +28,7 @@ namespace
} }
} }
#ifdef BOOST_CONTAINER_FOUND
template < typename Key > template < typename Key >
void boost_flat_set_insert(benchmark::State& state) { void boost_flat_set_insert(benchmark::State& state) {
std::vector<int> v; std::vector<int> v;
@@ -37,6 +40,7 @@ namespace
} }
} }
} }
#endif
template < typename Key > template < typename Key >
void std_set_insert(benchmark::State& state) { void std_set_insert(benchmark::State& state) {
@@ -67,9 +71,11 @@ BENCHMARK_TEMPLATE(flat_set_insert, vec4)
->ComputeStatistics("min", min_bench_statistics) ->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50); ->DenseRange(1,401,50);
BENCHMARK_TEMPLATE(boost_flat_set_insert, vec4) #ifdef BOOST_CONTAINER_FOUND
->ComputeStatistics("min", min_bench_statistics) BENCHMARK_TEMPLATE(boost_flat_set_insert, vec4)
->DenseRange(1,401,50); ->ComputeStatistics("min", min_bench_statistics)
->DenseRange(1,401,50);
#endif
BENCHMARK_TEMPLATE(std_set_insert, vec4) BENCHMARK_TEMPLATE(std_set_insert, vec4)
->ComputeStatistics("min", min_bench_statistics) ->ComputeStatistics("min", min_bench_statistics)