]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/reporting/performance/rsqrt_performance.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / math / reporting / performance / rsqrt_performance.cpp
CommitLineData
20effc67
TL
1// (C) Copyright Nick Thompson 2020.
2// Use, modification and distribution are subject to the
3// Boost Software License, Version 1.0. (See accompanying file
4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#include <random>
7#include <benchmark/benchmark.h>
8#include <boost/math/special_functions/rsqrt.hpp>
9#include <boost/multiprecision/float128.hpp>
10#include <boost/multiprecision/mpfr.hpp>
11#include <boost/multiprecision/cpp_bin_float.hpp>
12
13using boost::multiprecision::number;
14using boost::multiprecision::mpfr_float_backend;
15using boost::multiprecision::float128;
16using boost::multiprecision::cpp_bin_float_50;
17using boost::multiprecision::cpp_bin_float_100;
18using boost::math::rsqrt;
19
20template<class Real>
21void Rsqrt(benchmark::State& state)
22{
23 std::random_device rd;
24 std::mt19937_64 mt(rd());
25 std::uniform_real_distribution<long double> unif(1,100);
26
27 Real x = static_cast<Real>(unif(mt));
28 for (auto _ : state)
29 {
30 benchmark::DoNotOptimize(rsqrt(x));
31 x += std::numeric_limits<Real>::epsilon();
32 }
33}
34
35BENCHMARK_TEMPLATE(Rsqrt, float);
36BENCHMARK_TEMPLATE(Rsqrt, double);
37BENCHMARK_TEMPLATE(Rsqrt, long double);
38BENCHMARK_TEMPLATE(Rsqrt, float128);
39BENCHMARK_TEMPLATE(Rsqrt, number<mpfr_float_backend<100>>);
40BENCHMARK_TEMPLATE(Rsqrt, number<mpfr_float_backend<200>>);
41BENCHMARK_TEMPLATE(Rsqrt, number<mpfr_float_backend<300>>);
42BENCHMARK_TEMPLATE(Rsqrt, number<mpfr_float_backend<400>>);
43BENCHMARK_TEMPLATE(Rsqrt, number<mpfr_float_backend<1000>>);
44BENCHMARK_TEMPLATE(Rsqrt, cpp_bin_float_50);
45BENCHMARK_TEMPLATE(Rsqrt, cpp_bin_float_100);
46
47BENCHMARK_MAIN();