Skip to content

Instantly share code, notes, and snippets.

@GilesBathgate
Created March 9, 2022 10:16
Show Gist options
  • Save GilesBathgate/6a50e72772fdf7c36f90cb7ad5305fd1 to your computer and use it in GitHub Desktop.
Save GilesBathgate/6a50e72772fdf7c36f90cb7ad5305fd1 to your computer and use it in GitHub Desktop.
Sphere circle benchmark
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Kernel/global_functions.h>
#include <CGAL/Nef_S2/Sphere_circle.h>
#include <CGAL/point_generators_3.h>
#include <benchmark/benchmark.h>
using K = CGAL::Exact_predicates_exact_constructions_kernel;
using Point = CGAL::Point_3<K>;
using Plane = CGAL::Plane_3<K>;
using Sphere_circle = CGAL::Sphere_circle<K>;
static void BM_Plane(benchmark::State& state) {
CGAL::Random_points_on_sphere_3<Point> rnd;
for (auto _ : state) {
Point p1=*rnd++;
Point p2=*rnd++;
auto v1 = K().construct_orthogonal_vector_3_object()(p1,p2,Point(CGAL::ORIGIN));
Plane h(CGAL::ORIGIN,v1);
Sphere_circle c(h);
benchmark::DoNotOptimize(c);
}
}
static void BM_NoPlane(benchmark::State& state) {
CGAL::Random_points_on_sphere_3<Point> rnd;
for (auto _ : state) {
Point p1=*rnd++;
Point p2=*rnd++;
auto v1 = K().construct_orthogonal_vector_3_object()(p1,p2,Point(CGAL::ORIGIN));
Sphere_circle c(CGAL::ORIGIN,v1);
benchmark::DoNotOptimize(c);
}
}
BENCHMARK(BM_Plane);
BENCHMARK(BM_NoPlane);
BENCHMARK_MAIN();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment