1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
// Copyright (c) 2012-2013, IGN France.
// Copyright (c) 2012-2024, Oslandia.
// Copyright (c) 2024-2025, SFCGAL team.
// SPDX-License-Identifier: LGPL-2.0-or-later
#include "../test_config.h"
#include "Bench.h"
#include <boost/test/unit_test.hpp>
#include "SFCGAL/MultiPolygon.h"
#include "SFCGAL/detail/GetPointsVisitor.h"
#include "SFCGAL/detail/generator/sierpinski.h"
using namespace boost::unit_test;
using namespace SFCGAL;
BOOST_AUTO_TEST_SUITE(SFCGAL_BenchPredicate)
double
randf()
{
return double(rand()) / RAND_MAX;
}
BOOST_AUTO_TEST_CASE(testPointCompare)
{
std::vector<CGAL::Point_3<Kernel>> points;
for (size_t i = 0; i < 10000; i++) {
points.push_back(CGAL::Point_3<Kernel>(randf(), randf(), randf()));
}
bench().start("xyz");
for (size_t i = 0; i < points.size(); i++) {
for (size_t j = 0; j < points.size(); j++) {
points[i].x() < points[j].x();
}
}
bench().stop();
bench().start("compare");
for (size_t i = 0; i < points.size(); i++) {
for (size_t j = 0; j < points.size(); j++) {
CGAL::compare_x<Kernel>(points[i], points[j]);
}
}
bench().stop();
}
BOOST_AUTO_TEST_SUITE_END()
|