diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33ed001b..962fe68e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,7 +71,7 @@ jobs: shell: bash run: | cd build - ctest -j4 --output-on-failure + ctest -j1 --output-on-failure --verbose - name: Check installed executables shell: bash diff --git a/tests/test_point_in_volume.cpp b/tests/test_point_in_volume.cpp index 57a5b2d2..048e90e8 100644 --- a/tests/test_point_in_volume.cpp +++ b/tests/test_point_in_volume.cpp @@ -4,6 +4,8 @@ // xdg includes #include "xdg/mesh_manager_interface.h" #include "xdg/ray_tracing_interface.h" +#include + #include "mesh_mock.h" @@ -22,10 +24,18 @@ TEST_CASE("Test Point in Volume") bool result = rti->point_in_volume(volume_tree, point); REQUIRE(result == true); + BENCHMARK("point_in_vol [Inside]"){ + return rti->point_in_volume(volume_tree, point); + }; + point = {0.0, 0.0, 1000.0}; result = rti->point_in_volume(volume_tree, point); REQUIRE(result == false); + BENCHMARK("point_in_vol [Outside]"){ + return rti->point_in_volume(volume_tree, point); + }; + // test a point just inside the positive x boundary point = {4.0 - 1e-06, 0.0, 0.0}; result = rti->point_in_volume(volume_tree, point); diff --git a/tests/test_ray_fire.cpp b/tests/test_ray_fire.cpp index b87e9f2a..6b5bd572 100644 --- a/tests/test_ray_fire.cpp +++ b/tests/test_ray_fire.cpp @@ -2,6 +2,7 @@ // for testing #include #include +#include // xdg includes #include "xdg/constants.h" @@ -29,6 +30,18 @@ TEST_CASE("Test Ray Fire Mesh Mock") intersection = rti->ray_fire(volume_tree, origin, direction); REQUIRE_THAT(intersection.first, Catch::Matchers::WithinAbs(5.0, 1e-6)); + // benchmark firing from inside the cube to a face + BENCHMARK("ray_fire_from_inside"){ + return rti->ray_fire(volume_tree, origin, direction); + }; + + // advanced benchmark + BENCHMARK_ADVANCED("Advanced ray_fire benchmark")(Catch::Benchmark::Chronometer meter){ + meter.measure([]{ + return rti->ray_fire(volume_tree, origin, direction); + }); + }; + direction *= -1; intersection = rti->ray_fire(volume_tree, origin, direction); REQUIRE_THAT(intersection.first, Catch::Matchers::WithinAbs(2.0, 1e-6)); @@ -56,6 +69,10 @@ TEST_CASE("Test Ray Fire Mesh Mock") intersection = rti->ray_fire(volume_tree, origin, direction); REQUIRE_THAT(intersection.first, Catch::Matchers::WithinAbs(15.0, 1e-6)); + BENCHMARK("ray_fire_from_outside_vol [Exiting]"){ + return rti->ray_fire(volume_tree, origin, direction); + }; + origin = {10.0, 0.0, 0.0}; direction = {-1.0, 0.0, 0.0}; intersection = rti->ray_fire(volume_tree, origin, direction); @@ -68,6 +85,10 @@ TEST_CASE("Test Ray Fire Mesh Mock") intersection = rti->ray_fire(volume_tree, origin, direction, INFTY, HitOrientation::ENTERING); REQUIRE_THAT(intersection.first, Catch::Matchers::WithinAbs(8.0, 1e-6)); + BENCHMARK("ray_fire_from_outside_vol [Entering]"){ + return rti->ray_fire(volume_tree, origin, direction); + }; + origin = {10.0, 0.0, 0.0}; direction = {-1.0, 0.0, 0.0}; intersection = rti->ray_fire(volume_tree, origin, direction, INFTY, HitOrientation::ENTERING); @@ -98,3 +119,18 @@ TEST_CASE("Test Ray Fire Mesh Mock") intersection = rti->ray_fire(volume_tree, origin, direction, INFTY, HitOrientation::EXITING, &exclude_primitives); REQUIRE(intersection.second == ID_NONE); } + + +// TEST_CASE("Micro-Benchmark ray_fire()") +// { +// std::shared_ptr mm = std::make_shared(); +// mm->init(); // this should do nothing, just good practice to call it +// REQUIRE(mm->mesh_library() == MeshLibrary::INTERNAL); + +// std::shared_ptr rti = std::make_shared(); +// TreeID volume_tree = rti->register_volume(mm, mm->volumes()[0]); + +// Position origin {0.0, 0.0, 0.0}; +// Direction direction {1.0, 0.0, 0.0}; +// std::pair intersection; +// } \ No newline at end of file