From b7101494f2f89652d382245f52c76d25d994347b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 1 Jul 2022 19:15:28 +0300 Subject: [PATCH] Add tsl::hopscotch_map to string.cpp --- benchmark/string.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/benchmark/string.cpp b/benchmark/string.cpp index a069a7be..08b9f358 100644 --- a/benchmark/string.cpp +++ b/benchmark/string.cpp @@ -14,6 +14,9 @@ # include "absl/container/node_hash_map.h" # include "absl/container/flat_hash_map.h" #endif +#ifdef HAVE_TSL_HOPSCOTCH +# include "tsl/hopscotch_map.h" +#endif #include #include #include @@ -295,6 +298,16 @@ template using absl_flat_hash_map = #endif +#ifdef HAVE_TSL_HOPSCOTCH + +template using tsl_hopscotch_map = + tsl::hopscotch_map, std::equal_to, allocator_for>; + +template using tsl_hopscotch_pg_map = + tsl::hopscotch_pg_map, std::equal_to, allocator_for>; + +#endif + // fnv1a_hash template struct fnv1a_hash_impl; @@ -363,6 +376,16 @@ template using absl_flat_hash_map_fnv1a = #endif +#ifdef HAVE_TSL_HOPSCOTCH + +template using tsl_hopscotch_map_fnv1a = + tsl::hopscotch_map, allocator_for>; + +template using tsl_hopscotch_pg_map_fnv1a = + tsl::hopscotch_pg_map, allocator_for>; + +#endif + // int main() @@ -382,6 +405,13 @@ int main() #endif +#ifdef HAVE_TSL_HOPSCOTCH + + test( "tsl::hopscotch_map" ); + test( "tsl::hopscotch_pg_map" ); + +#endif + #endif test( "std::unordered_map, FNV-1a" ); @@ -393,13 +423,20 @@ int main() test( "absl::node_hash_map, FNV-1a" ); test( "absl::flat_hash_map, FNV-1a" ); +#endif + +#ifdef HAVE_TSL_HOPSCOTCH + + test( "tsl::hopscotch_map, FNV-1a" ); + test( "tsl::hopscotch_pg_map, FNV-1a" ); + #endif std::cout << "---\n\n"; for( auto const& x: times ) { - std::cout << std::setw( 30 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; + std::cout << std::setw( 31 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms, " << std::setw( 9 ) << x.bytes_ << " bytes in " << x.count_ << " allocations\n"; } }