-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath_benchmark.cpp
More file actions
49 lines (37 loc) · 1.25 KB
/
math_benchmark.cpp
File metadata and controls
49 lines (37 loc) · 1.25 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) Omar Boukli-Hacene. All rights reserved.
// Distributed under an MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT
#include <limits>
#include <catch2/catch_test_macros.hpp>
#include <nanobench.h>
#include <nameof.hpp>
#include "forfun/common/math.hpp"
TEST_CASE("Integer division ceiling benchmarking", "[benchmark][math]")
{
using namespace forfun::common::math;
ankerl::nanobench::Bench()
.title("Integer division ceiling")
.relative(true)
.run(
NAMEOF_RAW(alternative::div_ceil).c_str(),
[] noexcept -> void {
auto const volatile r{alternative::div_ceil(
std::numeric_limits<int>::max(),
std::numeric_limits<int>::max() - 1
)};
ankerl::nanobench::doNotOptimizeAway(&r);
}
)
.run(
NAMEOF_RAW(core::div_ceil).c_str(),
[] noexcept -> void {
auto const volatile r{core::div_ceil(
std::numeric_limits<int>::max(),
std::numeric_limits<int>::max() - 1
)};
ankerl::nanobench::doNotOptimizeAway(&r);
}
)
;
}