// Copyright 2017, 2018 Peter Dimov. // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template void test_( int N ) { typedef std::chrono::steady_clock clock_type; clock_type::time_point t1 = clock_type::now(); double r = 0; H h; for( int i = 0; i < N; ++i ) { using boost::hash2::get_integral_result; r += get_integral_result( h ); r += 0.5; } clock_type::time_point t2 = clock_type::now(); long long ms = std::chrono::duration_cast( t2 - t1 ).count(); r /= N; // Standard deviation of Bates distribution double stddev = static_cast( std::numeric_limits::max() ) - static_cast( std::numeric_limits::min() ) / std::sqrt( 12.0 * N ); r /= stddev; 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::type_name().c_str() ); test_( N ); test_( N ); test_( N ); test_( N ); test_( N ); test_( N ); test_( N ); test_( N ); test_( N ); test_( N ); test_( N ); test_( N ); test_( N ); test_( N ); test_( N ); test_( N ); puts( "" ); } int main() { int const N = 64 * 1024 * 1024; test( N ); test( N ); test( N ); test( N ); }