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