Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/test_point_in_volume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// xdg includes
#include "xdg/mesh_manager_interface.h"
#include "xdg/ray_tracing_interface.h"
#include <catch2/benchmark/catch_benchmark.hpp>


#include "mesh_mock.h"

Expand All @@ -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);
Expand Down
36 changes: 36 additions & 0 deletions tests/test_ray_fire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// for testing
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/benchmark/catch_benchmark.hpp>

// xdg includes
#include "xdg/constants.h"
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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<MeshManager> mm = std::make_shared<MeshMock>();
// mm->init(); // this should do nothing, just good practice to call it
// REQUIRE(mm->mesh_library() == MeshLibrary::INTERNAL);

// std::shared_ptr<RayTracer> rti = std::make_shared<RayTracer>();
// 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<double, MeshID> intersection;
// }