]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/reporting/performance/logaddexp_performance.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / reporting / performance / logaddexp_performance.cpp
CommitLineData
1e59de90
TL
1// (C) Copyright Matt Borland 2022.
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 <limits>
8#include <benchmark/benchmark.h>
9#include <boost/math/special_functions/logaddexp.hpp>
10
11using boost::math::logaddexp;
12
13template <typename Real>
14void logaddexp_performance(benchmark::State& state)
15{
16 std::random_device rd;
17 std::mt19937_64 mt {rd()};
18 std::uniform_real_distribution<long double> dist(1e-50, 5e-50);
19
20 Real x = static_cast<Real>(dist(mt));
21 Real y = static_cast<Real>(dist(mt));
22
23 for (auto _ : state)
24 {
25 benchmark::DoNotOptimize(logaddexp(x, y));
26 x += std::numeric_limits<Real>::epsilon();
27 y += std::numeric_limits<Real>::epsilon();
28 }
29}
30
31BENCHMARK_TEMPLATE(logaddexp_performance, float);
32BENCHMARK_TEMPLATE(logaddexp_performance, double);
33BENCHMARK_TEMPLATE(logaddexp_performance, long double);
34
35BENCHMARK_MAIN();