36TEST_CASE(
"Int Math Bench 01a",
"[abs][benchmark][arithmetic][math]" ) {
37 BENCHMARK(
"jau::abs Benchmark") {
40 REQUIRE( 1_i64 ==
jau::abs( 1_i64) );
41 REQUIRE( 1_i64 ==
jau::abs(-1_i64) );
43 REQUIRE( INT32_MAX ==
jau::abs( INT32_MAX ) );
46TEST_CASE(
"Int Math Bench 01b",
"[ct_abs][benchmark][arithmetic][math]" ) {
47 BENCHMARK(
"jau::ct_abs Benchmark") {
58TEST_CASE(
"Int Math Bench 01c",
"[abs][benchmark][arithmetic][math]" ) {
59 BENCHMARK(
"std::abs Benchmark") {
62 REQUIRE( 1_i64 ==
std::abs( 1_i64) );
63 REQUIRE( 1_i64 ==
std::abs(-1_i64) );
65 REQUIRE( INT32_MAX ==
std::abs( INT32_MAX ) );
69TEST_CASE(
"Int Math Bench 02a",
"[min][max][benchmark][arithmetic][math]" ) {
70 BENCHMARK(
"MinMax Benchmark") {
71 REQUIRE( 0 ==
jau::min( 0, INT32_MAX ) );
72 REQUIRE( INT32_MAX ==
jau::max( 0, INT32_MAX ) );
73 REQUIRE( INT32_MAX-1==
jau::min( INT32_MAX-1, INT32_MAX ) );
74 REQUIRE( INT32_MAX ==
jau::max( INT32_MAX-1, INT32_MAX ) );
75 REQUIRE( INT32_MIN ==
jau::min( 0, INT32_MIN ) );
76 REQUIRE( 0 ==
jau::max( 0, INT32_MIN ) );
77 REQUIRE( INT32_MIN ==
jau::min( INT32_MIN+1, INT32_MIN ) );
78 REQUIRE( INT32_MIN+1==
jau::max( INT32_MIN+1, INT32_MIN ) );
81TEST_CASE(
"Int Math Bench 03a",
"[ct_min][ct_max][benchmark][arithmetic][math]" ) {
82 BENCHMARK(
"Min2Max2 Benchmark") {
84 REQUIRE( INT32_MAX ==
jau::ct_max( 0, INT32_MAX ) );
85 REQUIRE( INT32_MAX-1==
jau::ct_min( INT32_MAX-1, INT32_MAX ) );
86 REQUIRE( INT32_MAX ==
jau::ct_max( INT32_MAX-1, INT32_MAX ) );
87 REQUIRE( INT32_MIN+1 ==
jau::ct_min( 0, INT32_MIN+1 ) );
89 REQUIRE( INT32_MIN ==
jau::ct_min( INT32_MIN+1, INT32_MIN ) );
90 REQUIRE( INT32_MIN+1==
jau::ct_max( INT32_MIN+1, INT32_MIN ) );
constexpr T ct_abs(const T x) noexcept
Returns the absolute value of an arithmetic number (w/o branching) in O(1) and constant time (CT),...
constexpr T ct_max(const T x, const T y) noexcept
Returns the maximum of two integrals for MIN <= x - y <= MAX (w/o branching) in O(1) and constant tim...
constexpr T ct_min(const T x, const T y) noexcept
Returns the minimum of two integrals for MIN <= x - y <= MAX (w/o branching) in O(1) and constant tim...
constexpr T min(const T x, const T y) noexcept
Returns the minimum of two integrals (w/ branching) in O(1)
constexpr T max(const T x, const T y) noexcept
Returns the maximum of two integrals (w/ branching) in O(1)
constexpr T abs(const T x) noexcept
Returns the absolute value of an arithmetic number (w/ branching) in O(1)
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
TEST_CASE("Int Math Bench 01a", "[abs][benchmark][arithmetic][math]")