forked from stan-dev/perf-math
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlgamma.cpp
35 lines (26 loc) · 782 Bytes
/
lgamma.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <benchmark/benchmark.h>
#include <boost/math/special_functions/gamma.hpp>
#include <cmath>
const int N = 10000;
typedef boost::math::policies::policy<
boost::math::policies::overflow_error<
boost::math::policies::errno_on_error>,
boost::math::policies::pole_error<boost::math::policies::errno_on_error>,
boost::math::policies::promote_double<false> > boost_policy_t;
static void BM_boost(benchmark::State& state) {
for (auto _ : state) {
for (int i=0; i != N; i++) {
boost::math::lgamma(i +0.5, boost_policy_t());
}
}
}
BENCHMARK(BM_boost);
static void BM_std(benchmark::State& state) {
for (auto _ : state) {
for (int i=0+0.5; i != N; i++) {
std::lgamma(i+0.5);
}
}
}
BENCHMARK(BM_std);
BENCHMARK_MAIN();