15#include <jau/test/catch2_ext.hpp>
28 bool __attribute__ ((noinline))
31 return hi.x >= o.lo.x &&
36 bool __attribute__ ((noinline))
39 return !(
hi.x < o.lo.x ||
44 bool __attribute__ ((noinline))
49 return lo_.
x <= hi_.
x && lo_.
y <= hi_.
y;
54 return hi.x >= o.
lo.
x &&
61 return !(
hi.x < o.
lo.
x ||
70 return lo_.
x <= hi_.
x && lo_.
y <= hi_.
y;
75 return out <<
"aabb[bl " << v.lo <<
", tr " << v.hi <<
"]";
80TEST_CASE(
"Float Math Bench 04a",
"[intersect][benchmark][arithmetic][math]" ) {
84 std::uniform_int_distribution<int32_t> rint(0,50);
86 const int loops = catch_auto_run ? 1000 : 1000000;
88 std::vector<AABBox2f> va0, vb0;
89 std::vector<AABBox> va, vb;
90 for(
int i=0; i<
loops; ++i) {
91 Point2f lo((
float)rint(rng), (
float)rint(rng));
92 Point2f hi(lo.
x+(
float)rint(rng), lo.
y+(
float)rint(rng));
95 lo =
Point2f((
float)rint(rng), (
float)rint(rng));
96 hi =
Point2f(lo.
x+(
float)rint(rng), lo.
y+(
float)rint(rng));
103 bool i0 = a0.intersects(b0);
104 bool i1a = a.intersects1a(b);
105 bool i1b = a.intersects1b(b);
106 bool i1c = a.intersects1c(b);
113 REQUIRE( i1a == i1b );
114 REQUIRE( i1a == i1c );
115 REQUIRE( i1a == i0 );
117 bool i2a = a.intersects2a(b);
118 bool i2b = a.intersects2b(b);
119 bool i2c = a.intersects2c(b);
120 REQUIRE( i1a == i2a );
121 REQUIRE( i2a == i2b );
122 REQUIRE( i2a == i2c );
123 REQUIRE( i2a == i0 );
125 std::cout <<
"isect_count " << isect_count <<
"/" << va.size() <<
", " << 100.0f*( (float)isect_count / (float)va.size() ) <<
"%" << std::endl;
127 BENCHMARK(
"Intersect0 Benchmark") {
129 for(
size_t i = 0; i < va0.size(); ++i) {
136 BENCHMARK(
"Intersect1a Benchmark") {
138 for(
size_t i = 0; i < va.size(); ++i) {
145 BENCHMARK(
"Intersect1b Benchmark") {
147 for(
size_t i = 0; i < va.size(); ++i) {
154 BENCHMARK(
"Intersect1c Benchmark") {
156 for(
size_t i = 0; i < va.size(); ++i) {
163 BENCHMARK(
"Intersect2a Benchmark") {
165 for(
size_t i = 0; i < va.size(); ++i) {
172 BENCHMARK(
"Intersect2b Benchmark") {
174 for(
size_t i = 0; i < va.size(); ++i) {
181 BENCHMARK(
"Intersect2c Benchmark") {
183 for(
size_t i = 0; i < va.size(); ++i) {
Axis Aligned Bounding Box.
bool intersects(const AABBox2f &o) const noexcept
std::ostream & operator<<(std::ostream &out, const cow_darray< Value_type, Size_type, Alloc_type > &c)
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)
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
bool intersects1b(const AABBox &o) const
bool intersects2c(const AABBox &o) const
bool intersects1c(const AABBox &o) const
bool intersects2b(const AABBox &o) const
bool intersects1a(const AABBox &o) const
bool intersects2a(const AABBox &o) const
TEST_CASE("Float Math Bench 04a", "[intersect][benchmark][arithmetic][math]")