Skip to content

Commit

Permalink
Add benchmark for nearest point calculation in triangle geometry (exa…
Browse files Browse the repository at this point in the history
…mple)
  • Loading branch information
loumalouomega committed Nov 24, 2024
1 parent e7df3b3 commit c4a47de
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions kratos/benchmarks/example_benchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Vicente Mataix Ferrandiz
//

// System includes

// External includes
#include <benchmark/benchmark.h>

// Project includes
#include "geometries/point.h"
#include "geometries/triangle_3d_3.h"
#include "utilities/geometry_utilities/nearest_point_utilities.h"

namespace Kratos
{

// Sample data for benchmarking
Point::Pointer p_point_1(make_shared<Point>( 0.0, 0.0, 0.0));
Point::Pointer p_point_2(make_shared<Point>( 1.0, 0.0, 0.0));
Point::Pointer p_point_3(make_shared<Point>( 0.0, 1.0, 0.0));

Triangle3D3<Point> triangle(p_point_1, p_point_3, p_point_2);
Point nearest_point(0.0, 0.0, 0.0);
Point inside_point(0.2, 0.1, 0.00);

static void BM_TriangleNearestPoint(benchmark::State& state) {
for (auto _ : state) {
NearestPointUtilities::TriangleNearestPoint(inside_point, triangle, nearest_point);
}
}

// Register the function as a benchmark
BENCHMARK(BM_TriangleNearestPoint);

} // namespace Kratos

BENCHMARK_MAIN();

0 comments on commit c4a47de

Please sign in to comment.