]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/reporting/performance/chebyshev_clenshaw.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / reporting / performance / chebyshev_clenshaw.cpp
CommitLineData
1e59de90
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
20effc67
TL
6#include <vector>
7#include <random>
8#include <benchmark/benchmark.h>
9#include <boost/math/special_functions/chebyshev.hpp>
10
11
12template<class Real>
13void ChebyshevClenshaw(benchmark::State& state)
14{
15 std::vector<Real> v(state.range(0));
16 std::random_device rd;
17 std::mt19937_64 mt(rd());
18 std::uniform_real_distribution<Real> unif(-1,1);
19 for (size_t i = 0; i < v.size(); ++i)
20 {
21 v[i] = unif(mt);
22 }
23
24 using boost::math::chebyshev_clenshaw_recurrence;
25 Real x = unif(mt);
26 for (auto _ : state)
27 {
28 benchmark::DoNotOptimize(chebyshev_clenshaw_recurrence(v.data(), v.size(), x));
29 }
30 state.SetComplexityN(state.range(0));
31}
32
33template<class Real>
34void TranslatedChebyshevClenshaw(benchmark::State& state)
35{
36 std::vector<Real> v(state.range(0));
37 std::random_device rd;
38 std::mt19937_64 mt(rd());
39 std::uniform_real_distribution<Real> unif(-1,1);
40 for (size_t i = 0; i < v.size(); ++i)
41 {
42 v[i] = unif(mt);
43 }
44
45 using boost::math::detail::unchecked_chebyshev_clenshaw_recurrence;
46 Real x = unif(mt);
47 Real a = -2;
48 Real b = 5;
49 for (auto _ : state)
50 {
51 benchmark::DoNotOptimize(unchecked_chebyshev_clenshaw_recurrence(v.data(), v.size(), a, b, x));
52 }
53 state.SetComplexityN(state.range(0));
54}
55
56
57BENCHMARK_TEMPLATE(TranslatedChebyshevClenshaw, double)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity(benchmark::oN);
58BENCHMARK_TEMPLATE(ChebyshevClenshaw, double)->RangeMultiplier(2)->Range(1<<1, 1<<22)->Complexity(benchmark::oN);
59
60
61
1e59de90 62BENCHMARK_MAIN();