From 0911877a0cf8383977b9559d9a454bde2ad50b1d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 30 Nov 2023 17:19:04 +0200 Subject: [PATCH] Update benchmarks --- benchmark/Jamfile | 8 ++++---- benchmark/average.cpp | 14 +++++++------- benchmark/buffer.cpp | 16 ++++++++++------ benchmark/keys.cpp | 18 +++++++++--------- benchmark/unordered.cpp | 41 +++++++++++++++-------------------------- test/Jamfile | 1 + 6 files changed, 46 insertions(+), 52 deletions(-) diff --git a/benchmark/Jamfile b/benchmark/Jamfile index 4ce06c8..eb0f75b 100644 --- a/benchmark/Jamfile +++ b/benchmark/Jamfile @@ -3,7 +3,7 @@ project : default-build release static ; -exe buffer : buffer.cpp /boost//chrono ; -exe unordered : unordered.cpp /boost//chrono ; -exe average : average.cpp /boost//chrono ; -exe keys : keys.cpp /boost//chrono ; +exe buffer : buffer.cpp ; +exe unordered : unordered.cpp ; +exe average : average.cpp ; +exe keys : keys.cpp ; diff --git a/benchmark/average.cpp b/benchmark/average.cpp index bd7a7d3..83152cf 100644 --- a/benchmark/average.cpp +++ b/benchmark/average.cpp @@ -1,6 +1,6 @@ - // Copyright 2017, 2018 Peter Dimov. // Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt #include #include @@ -11,8 +11,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -22,7 +22,7 @@ template void test_( int N ) { - typedef boost::chrono::steady_clock clock_type; + typedef std::chrono::steady_clock clock_type; clock_type::time_point t1 = clock_type::now(); @@ -39,7 +39,7 @@ template void test_( int N ) clock_type::time_point t2 = clock_type::now(); - long long ms = boost::chrono::duration_cast( t2 - t1 ).count(); + long long ms = std::chrono::duration_cast( t2 - t1 ).count(); r /= N; @@ -48,12 +48,12 @@ template void test_( int N ) r /= stddev; - printf( "%s: r=%e, %lld ms\n", boost::core::demangle( typeid(H).name() ).c_str(), r, ms ); + printf( "%s: r=%e, %lld ms\n", boost::core::type_name().c_str(), r, ms ); } template void test( int N ) { - printf( "Integral result type `%s`:\n\n", boost::core::demangle( typeid(R).name() ).c_str() ); + printf( "Integral result type `%s`:\n\n", boost::core::type_name().c_str() ); test_( N ); test_( N ); diff --git a/benchmark/buffer.cpp b/benchmark/buffer.cpp index 102d8e4..13fdb4a 100644 --- a/benchmark/buffer.cpp +++ b/benchmark/buffer.cpp @@ -1,4 +1,8 @@ -#include +// Copyright 2017-2020 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include #include #include #include @@ -7,8 +11,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -17,7 +21,7 @@ template void test_( unsigned char const * p, int N, int M ) { H h; - typedef boost::chrono::steady_clock clock_type; + typedef std::chrono::steady_clock clock_type; clock_type::time_point t1 = clock_type::now(); @@ -28,12 +32,12 @@ template void test_( unsigned char const * p, int N, int M ) clock_type::time_point t2 = clock_type::now(); - long long ms = boost::chrono::duration_cast( t2 - t1 ).count(); + long long ms = std::chrono::duration_cast( t2 - t1 ).count(); using boost::hash2::get_integral_result; unsigned r = get_integral_result( h.result() ); - std::printf( "%s (N=%d): %u: %lld ms, %.2f MB/s\n", boost::core::demangle( typeid( H ).name() ).c_str(), N, r, ms, 1000.0 * N * M / ms / 1048576 ); + std::printf( "%s (N=%d): %u: %lld ms, %.2f MB/s\n", boost::core::type_name().c_str(), N, r, ms, 1000.0 * N * M / ms / 1048576 ); } extern unsigned char data[]; diff --git a/benchmark/keys.cpp b/benchmark/keys.cpp index a746453..a1fd287 100644 --- a/benchmark/keys.cpp +++ b/benchmark/keys.cpp @@ -1,6 +1,6 @@ - // Copyright 2017-2020 Peter Dimov. // Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt #define _CRT_SECURE_NO_WARNINGS @@ -13,10 +13,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -252,7 +252,7 @@ template class hasher4 template void test3( int N, V const& v, std::size_t seed ) { - typedef boost::chrono::steady_clock clock_type; + typedef std::chrono::steady_clock clock_type; clock_type::time_point t1 = clock_type::now(); @@ -267,9 +267,9 @@ template void test3( int N, V const& v, std::size_t seed ) clock_type::time_point t2 = clock_type::now(); - long long ms1 = boost::chrono::duration_cast( t2 - t1 ).count(); + long long ms1 = std::chrono::duration_cast( t2 - t1 ).count(); - std::string hash = boost::core::demangle( typeid(H).name() ); + std::string hash = boost::core::type_name(); #if defined( _MSC_VER ) @@ -300,7 +300,7 @@ int main() { v.reserve( N ); - boost::mt19937_64 rnd; + std::mt19937_64 rnd; for( int i = 0; i < N; ++i ) { diff --git a/benchmark/unordered.cpp b/benchmark/unordered.cpp index 42a07ed..df89c91 100644 --- a/benchmark/unordered.cpp +++ b/benchmark/unordered.cpp @@ -1,6 +1,6 @@ - // Copyright 2017-2019 Peter Dimov. // Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt #define _CRT_SECURE_NO_WARNINGS @@ -13,11 +13,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -210,7 +210,7 @@ template class hasher4 template void test4( int N, V const& v, char const * hash, S s ) { - typedef boost::chrono::steady_clock clock_type; + typedef std::chrono::steady_clock clock_type; clock_type::time_point t1 = clock_type::now(); @@ -230,37 +230,26 @@ template void test4( int N, V const& v, char const * hash, S s clock_type::time_point t3 = clock_type::now(); - long long ms1 = boost::chrono::duration_cast( t2 - t1 ).count(); - long long ms2 = boost::chrono::duration_cast( t3 - t2 ).count(); + long long ms1 = std::chrono::duration_cast( t2 - t1 ).count(); + long long ms2 = std::chrono::duration_cast( t3 - t2 ).count(); std::size_t n = s.bucket_count(); - std::size_t m = 0; - - for( std::size_t i = 0; i < n; ++i ) - { - std::size_t k = s.bucket_size( i ); - - if( k > m ) - { - m = k; - } - } #if defined( _MSC_VER ) - std::printf( "%s: n=%Iu, m=%Iu, q=%Iu, %lld + %lld ms\n", hash, n, m, q, ms1, ms2 ); + std::printf( "%s: n=%Iu, q=%Iu, %lld + %lld ms\n", hash, n, q, ms1, ms2 ); #else - std::printf( "%s: n=%zu, m=%zu, q=%zu, %lld + %lld ms\n", hash, n, m, q, ms1, ms2 ); + std::printf( "%s: n=%zu, q=%zu, %lld + %lld ms\n", hash, n, q, ms1, ms2 ); #endif } template void test3( int N, V const& v, std::size_t seed ) { - boost::unordered_set s( 0, H( seed ) ); - test4( N, v, boost::core::demangle( typeid(H).name() ).c_str(), s ); + boost::unordered_flat_set s( 0, H( seed ) ); + test4( N, v, boost::core::type_name().c_str(), s ); } template void test2( int N, V const& v ) @@ -281,7 +270,7 @@ int main() { v.reserve( N * 16 ); - boost::mt19937_64 rnd; + std::mt19937_64 rnd; for( int i = 0; i < 16 * N; ++i ) { @@ -305,7 +294,7 @@ int main() typedef std::string K; { - boost::unordered_set s; + boost::unordered_flat_set s; test4( N, v, "default", s ); std::puts( "" ); } diff --git a/test/Jamfile b/test/Jamfile index f697c50..3a89b4d 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -59,3 +59,4 @@ run integral_result.cpp ; compile ../benchmark/buffer.cpp ; compile ../benchmark/unordered.cpp ; compile ../benchmark/average.cpp ; +compile ../benchmark/keys.cpp ;