From 5bcdd7fdf0e2a14bc6eae3d25d614798209fe4e3 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 22 Jul 2022 18:18:35 +0300 Subject: [PATCH] Change uint32.cpp to use byteswapped indices instead of shifted indices --- benchmark/uint32.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/benchmark/uint32.cpp b/benchmark/uint32.cpp index 9095bd38..b7acf05a 100644 --- a/benchmark/uint32.cpp +++ b/benchmark/uint32.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #ifdef HAVE_ABSEIL @@ -65,7 +66,7 @@ static void init_indices() for( unsigned i = 1; i <= N*2; ++i ) { - indices3.push_back( (std::uint32_t)i << 11 ); + indices3.push_back( boost::endian::endian_reverse( static_cast( i ) ) ); } } @@ -90,7 +91,7 @@ template BOOST_NOINLINE void test_insert( Map& map, std::chrono::stea map.insert( { indices3[ i ], i } ); } - print_time( t1, "Consecutive shifted insert", 0, map.size() ); + print_time( t1, "Consecutive reversed insert", 0, map.size() ); std::cout << std::endl; } @@ -136,7 +137,7 @@ template BOOST_NOINLINE void test_lookup( Map& map, std::chrono::stea } } - print_time( t1, "Consecutive shifted lookup", s, map.size() ); + print_time( t1, "Consecutive reversed lookup", s, map.size() ); std::cout << std::endl; } @@ -187,7 +188,7 @@ template BOOST_NOINLINE void test_erase( Map& map, std::chrono::stead map.erase( indices3[ i ] ); } - print_time( t1, "Consecutive shifted erase", 0, map.size() ); + print_time( t1, "Consecutive reversed erase", 0, map.size() ); std::cout << std::endl; }