From 1dc949b2b5c03ef86227f247872f9eb65efc58ad Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 26 Oct 2022 21:08:51 +0300 Subject: [PATCH] Add boost::unordered_flat_map to benchmarks --- benchmark/string.cpp | 13 +++++++++++-- benchmark/string_view.cpp | 13 +++++++++++-- benchmark/uint32.cpp | 7 ++++++- benchmark/uint64.cpp | 7 ++++++- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/benchmark/string.cpp b/benchmark/string.cpp index 9e72246d..ff7288e4 100644 --- a/benchmark/string.cpp +++ b/benchmark/string.cpp @@ -5,6 +5,7 @@ #define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING #include +#include #include #include #include @@ -294,6 +295,9 @@ template using std_unordered_map = template using boost_unordered_map = boost::unordered_map, std::equal_to, allocator_for>; +template using boost_unordered_flat_map = + boost::unordered_flat_map, std::equal_to, allocator_for>; + #ifdef HAVE_ABSEIL template using absl_node_hash_map = @@ -374,6 +378,9 @@ std::unordered_map, allocator_for>; template using boost_unordered_map_fnv1a = boost::unordered_map, allocator_for>; +template using boost_unordered_flat_map_fnv1a = + boost::unordered_flat_map, allocator_for>; + template using multi_index_map_fnv1a = multi_index_container< pair, indexed_by< @@ -418,10 +425,11 @@ int main() { init_indices(); -#if 0 +#if 1 test( "std::unordered_map" ); test( "boost::unordered_map" ); + test( "boost::unordered_flat_map" ); test( "multi_index_map" ); #ifdef HAVE_ABSEIL @@ -449,6 +457,7 @@ int main() test( "std::unordered_map, FNV-1a" ); test( "boost::unordered_map, FNV-1a" ); + test( "boost::unordered_flat_map, FNV-1a" ); test( "multi_index_map, FNV-1a" ); #ifdef HAVE_ABSEIL @@ -476,7 +485,7 @@ int main() for( auto const& x: times ) { - std::cout << std::setw( 31 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; + std::cout << std::setw( 35 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; } } diff --git a/benchmark/string_view.cpp b/benchmark/string_view.cpp index 826c964f..a07a699d 100644 --- a/benchmark/string_view.cpp +++ b/benchmark/string_view.cpp @@ -5,6 +5,7 @@ #define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING #include +#include #include #include #include @@ -295,6 +296,9 @@ template using std_unordered_map = template using boost_unordered_map = boost::unordered_map, std::equal_to, allocator_for>; +template using boost_unordered_flat_map = + boost::unordered_flat_map, std::equal_to, allocator_for>; + #ifdef HAVE_ABSEIL template using absl_node_hash_map = @@ -375,6 +379,9 @@ std::unordered_map, allocator_for>; template using boost_unordered_map_fnv1a = boost::unordered_map, allocator_for>; +template using boost_unordered_flat_map_fnv1a = + boost::unordered_flat_map, allocator_for>; + template using multi_index_map_fnv1a = multi_index_container< pair, indexed_by< @@ -419,10 +426,11 @@ int main() { init_indices(); -#if 0 +#if 1 test( "std::unordered_map" ); test( "boost::unordered_map" ); + test( "boost::unordered_flat_map" ); test( "multi_index_map" ); #ifdef HAVE_ABSEIL @@ -450,6 +458,7 @@ int main() test( "std::unordered_map, FNV-1a" ); test( "boost::unordered_map, FNV-1a" ); + test( "boost::unordered_flat_map, FNV-1a" ); test( "multi_index_map, FNV-1a" ); #ifdef HAVE_ABSEIL @@ -477,7 +486,7 @@ int main() for( auto const& x: times ) { - std::cout << std::setw( 31 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; + std::cout << std::setw( 35 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; } } diff --git a/benchmark/uint32.cpp b/benchmark/uint32.cpp index 95a26bc4..986f9669 100644 --- a/benchmark/uint32.cpp +++ b/benchmark/uint32.cpp @@ -5,6 +5,7 @@ #define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING #include +#include #include #include #include @@ -311,6 +312,9 @@ template using std_unordered_map = template using boost_unordered_map = boost::unordered_map, std::equal_to, allocator_for>; +template using boost_unordered_flat_map = + boost::unordered_flat_map, std::equal_to, allocator_for>; + #ifdef HAVE_ABSEIL template using absl_node_hash_map = @@ -347,6 +351,7 @@ int main() test( "std::unordered_map" ); test( "boost::unordered_map" ); + test( "boost::unordered_flat_map" ); test( "multi_index_map" ); #ifdef HAVE_ABSEIL @@ -374,7 +379,7 @@ int main() for( auto const& x: times ) { - std::cout << std::setw( 25 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; + std::cout << std::setw( 27 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; } } diff --git a/benchmark/uint64.cpp b/benchmark/uint64.cpp index a2c1b3a3..e8b5161d 100644 --- a/benchmark/uint64.cpp +++ b/benchmark/uint64.cpp @@ -5,6 +5,7 @@ #define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING #include +#include #include #include #include @@ -311,6 +312,9 @@ template using std_unordered_map = template using boost_unordered_map = boost::unordered_map, std::equal_to, allocator_for>; +template using boost_unordered_flat_map = + boost::unordered_flat_map, std::equal_to, allocator_for>; + #ifdef HAVE_ABSEIL template using absl_node_hash_map = @@ -347,6 +351,7 @@ int main() test( "std::unordered_map" ); test( "boost::unordered_map" ); + test( "boost::unordered_flat_map" ); test( "multi_index_map" ); #ifdef HAVE_ABSEIL @@ -374,7 +379,7 @@ int main() for( auto const& x: times ) { - std::cout << std::setw( 25 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; + std::cout << std::setw( 27 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; } }