6#define _USE_MATH_DEFINES
7#include <benchmark/benchmark.h>
17#define M_PI 3.14159265358979323846
24 std::vector<Point> vertices;
25 for (
int i = 0; i < state.range(0); ++i) {
26 double angle = 2.0 *
M_PI * i / state.range(0);
27 vertices.emplace_back(100 * cos(angle), 100 * sin(angle));
32 for (
auto _ : state) {
33 double area = poly.
area();
34 benchmark::DoNotOptimize(area);
37 state.SetComplexityN(state.range(0));
43 std::vector<Point> vertices;
44 for (
int i = 0; i < 100; ++i) {
45 double angle = 2.0 *
M_PI * i / 100;
46 vertices.emplace_back(100 * cos(angle), 100 * sin(angle));
51 std::random_device rd;
53 std::uniform_real_distribution<> dis(-150.0, 150.0);
55 for (
auto _ : state) {
56 Point test_point(dis(gen), dis(gen));
58 benchmark::DoNotOptimize(contains);
65 std::vector<Point> vertices;
66 std::random_device rd;
68 std::uniform_real_distribution<> dis(0.0, 1000.0);
70 for (
int i = 0; i < state.range(0); ++i) {
71 vertices.emplace_back(dis(gen), dis(gen));
76 for (
auto _ : state) {
78 benchmark::DoNotOptimize(sharp_angles);
81 state.SetComplexityN(state.range(0));
87 std::vector<Point> vertices1 = {
90 std::vector<Point> vertices2 = {
97 for (
auto _ : state) {
static void BM_PointInPolygon(benchmark::State &state)
static void BM_PolygonDistance(benchmark::State &state)
BENCHMARK(BM_PolygonArea) -> Range(8, 8<< 8) ->Complexity()
static void BM_SharpAngleDetection(benchmark::State &state)
static void BM_PolygonArea(benchmark::State &state)
2D point with high-precision coordinates and utility methods
Polygon class supporting both convex and concave polygons.
double distance_to(const Polygon &other) const
Calculate minimum distance to another polygon.
std::vector< size_t > get_sharp_angles(double threshold_degrees=30.0) const
Find vertices with sharp angles.
bool contains_point(const Point &point) const
Check if point is inside polygon (ray casting algorithm)
double area() const
Calculate polygon area using shoelace formula.
double distance(const Point &p1, const Point &p2)
Calculate distance between two points.
2D Point class for geometric calculations
Polygon class for complex geometric shapes and EDA components.
Axis-aligned rectangle class for bounding boxes and simple components.