-
Notifications
You must be signed in to change notification settings - Fork 165
/
app_benchmark_detail.h
34 lines (25 loc) · 1.13 KB
/
app_benchmark_detail.h
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
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef APP_BENCHMARK_DETAIL_2018_10_02_H
#define APP_BENCHMARK_DETAIL_2018_10_02_H
#include <cmath>
#include <limits>
namespace app { namespace benchmark { namespace detail {
template<typename NumericType>
auto is_close_fraction(const NumericType a, // NOLINT(bugprone-easily-swappable-parameters)
const NumericType b, // NOLINT(bugprone-easily-swappable-parameters)
const NumericType tol = NumericType(std::numeric_limits<NumericType>::epsilon() * NumericType(100))) -> bool
{
using std::fabs;
const NumericType ratio = fabs(NumericType((NumericType(1) * a) / b));
const NumericType closeness = fabs(NumericType(1 - ratio));
return (closeness < tol);
}
} // namespace detail
} // namespace benchmark
} // namespace app
#endif // APP_BENCHMARK_DETAIL_2018_10_02_H