From 4d9f7b89311982de41f8c3792a170f45bf2787b7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 1 Dec 2022 02:22:07 +0200 Subject: [PATCH] Add ankerl::unordered_dense::hash to benchmarks --- benchmark/unordered.cpp | 24 ++++++++++++++++++------ benchmark/unordered_flat.cpp | 11 ++++++++++- benchmark/word_count.cpp | 11 ++++++++++- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/benchmark/unordered.cpp b/benchmark/unordered.cpp index 6550adf..232e71c 100644 --- a/benchmark/unordered.cpp +++ b/benchmark/unordered.cpp @@ -13,6 +13,9 @@ #ifdef HAVE_ABSEIL # include "absl/hash/hash.h" #endif +#ifdef HAVE_ANKERL_UNORDERED_DENSE +# include "ankerl/unordered_dense.h" +#endif #ifdef HAVE_MULXP_HASH # include "mulxp_hash.hpp" #endif @@ -245,11 +248,11 @@ template void test_hash_speed( int N, V const& v ) #if defined( _MSC_VER ) - std::printf( "%53s : q=%20Iu, %lld ms\n", hash.c_str(), q, ms1 ); + std::printf( "%57s : q=%20Iu, %lld ms\n", hash.c_str(), q, ms1 ); #else - std::printf( "%53s : q=%20zu, %lld ms\n", hash.c_str(), q, ms1 ); + std::printf( "%57s : q=%20zu, %lld ms\n", hash.c_str(), q, ms1 ); #endif } @@ -270,11 +273,11 @@ template void test_hash_collision( int N, V const& v, std::siz #if defined( _MSC_VER ) - std::printf( "%53s : c=%Iu\n", hash.c_str(), n - s.size() ); + std::printf( "%57s : c=%Iu\n", hash.c_str(), n - s.size() ); #else - std::printf( "%53s : c=%zu\n", hash.c_str(), n - s.size() ); + std::printf( "%57s : c=%zu\n", hash.c_str(), n - s.size() ); #endif } @@ -327,11 +330,11 @@ template void test4( int N, V const& v, char const * hash, S s #if defined( _MSC_VER ) - std::printf( "%53s : n=%Iu, m=%Iu, c=%Iu, q=%Iu, %4lld + %4lld = %4lld ms\n", hash, n, m, c, q, ms1, ms2, ms1 + ms2 ); + std::printf( "%57s : n=%Iu, m=%Iu, c=%Iu, q=%Iu, %4lld + %4lld = %4lld ms\n", hash, n, m, c, q, ms1, ms2, ms1 + ms2 ); #else - std::printf( "%53s : n=%zu, m=%zu, c=%zu, q=%zu, %4lld + %4lld = %4lld ms\n", hash, n, m, c, q, ms1, ms2, ms1 + ms2 ); + std::printf( "%57s : n=%zu, m=%zu, c=%zu, q=%zu, %4lld + %4lld = %4lld ms\n", hash, n, m, c, q, ms1, ms2, ms1 + ms2 ); #endif } @@ -383,6 +386,9 @@ int main() #ifdef HAVE_ABSEIL test_hash_speed >( N * 16, v ); #endif +#ifdef HAVE_ANKERL_UNORDERED_DENSE + test_hash_speed >( N * 16, v ); +#endif #ifdef HAVE_MULXP_HASH test_hash_speed( N * 16, v ); test_hash_speed( N * 16, v ); @@ -418,6 +424,9 @@ int main() #ifdef HAVE_ABSEIL test_hash_collision >( N * 16, v, n ); #endif +#ifdef HAVE_ANKERL_UNORDERED_DENSE + test_hash_collision >( N * 16, v, n ); +#endif #ifdef HAVE_MULXP_HASH test_hash_collision( N * 16, v, n ); test_hash_collision( N * 16, v, n ); @@ -442,6 +451,9 @@ int main() #ifdef HAVE_ABSEIL test_container_speed >( N, v ); #endif +#ifdef HAVE_ANKERL_UNORDERED_DENSE + test_container_speed >( N, v ); +#endif #ifdef HAVE_MULXP_HASH test_container_speed( N, v ); test_container_speed( N, v ); diff --git a/benchmark/unordered_flat.cpp b/benchmark/unordered_flat.cpp index f6a9395..52a8f6b 100644 --- a/benchmark/unordered_flat.cpp +++ b/benchmark/unordered_flat.cpp @@ -11,6 +11,9 @@ #ifdef HAVE_ABSEIL # include "absl/hash/hash.h" #endif +#ifdef HAVE_ANKERL_UNORDERED_DENSE +# include "ankerl/unordered_dense.h" +#endif #ifdef HAVE_MULXP_HASH # include "mulxp_hash.hpp" #endif @@ -470,6 +473,12 @@ int main() #endif +#ifdef HAVE_ANKERL_UNORDERED_DENSE + + test< ankerl::unordered_dense::hash >( "ankerl::unordered_dense::hash" ); + +#endif + #ifdef HAVE_MULXP_HASH test< mulxp0_hash_ >( "mulxp0_hash" ); @@ -484,7 +493,7 @@ int main() for( auto const& x: times ) { - std::cout << std::setw( 22 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms\n"; + std::cout << std::setw( 32 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms\n"; } } diff --git a/benchmark/word_count.cpp b/benchmark/word_count.cpp index 566330e..8ba42aa 100644 --- a/benchmark/word_count.cpp +++ b/benchmark/word_count.cpp @@ -9,6 +9,9 @@ #ifdef HAVE_ABSEIL # include "absl/hash/hash.h" #endif +#ifdef HAVE_ANKERL_UNORDERED_DENSE +# include "ankerl/unordered_dense.h" +#endif #ifdef HAVE_MULXP_HASH # include "mulxp_hash.hpp" #endif @@ -395,6 +398,12 @@ int main() #endif +#ifdef HAVE_ANKERL_UNORDERED_DENSE + + test< ankerl::unordered_dense::hash >( "ankerl::unordered_dense::hash" ); + +#endif + #ifdef HAVE_MULXP_HASH test< mulxp0_hash_ >( "mulxp0_hash" ); @@ -409,7 +418,7 @@ int main() for( auto const& x: times ) { - std::cout << std::setw( 22 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms\n"; + std::cout << std::setw( 32 ) << ( x.label_ + ": " ) << std::setw( 5 ) << x.time_ << " ms\n"; } }