Skip to content

Performance degradation of boolean set operation when upgrade CGAL from 5.2.3 to 5.3. #6092

@Supranaturaler

Description

@Supranaturaler

Issue Details

Performance degradation of boolean set operation when upgrade CGAL from 5.2.3 to 5.3.
Here is a simple test:
CGAL 5.2.3
image

CGAL 5.3
image

Source Code

#include <iostream>
#include <vector>

#include "CGAL/Exact_predicates_exact_constructions_kernel.h"
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;

#include "CGAL/Polygon_2.h"
typedef CGAL::Polygon_2<Kernel> Polygon_2;

#include "CGAL/Polygon_set_2.h"
typedef CGAL::Polygon_set_2<Kernel> Polygon_set_2;

int main(int argc, char* argv[])
{
    auto startTime = std::chrono::high_resolution_clock::now();
    const size_t polygonSize = 2000;
    std::vector<Polygon_2> vecPolygons(polygonSize);
    for (size_t i = 0; i < polygonSize; ++i)
    {
        vecPolygons[i].push_back(Point_2(i - 0.5, i - 0.5));
        vecPolygons[i].push_back(Point_2(i + 0.5, i - 0.5));
        vecPolygons[i].push_back(Point_2(i + 0.5, i + 0.5));
        vecPolygons[i].push_back(Point_2(i - 0.5, i + 0.5));
    }
    Polygon_set_2 polygonSet;
    polygonSet.join(vecPolygons.begin(), vecPolygons.end());

    for (size_t i = 0; i < polygonSize; ++i)
    {
        polygonSet.do_intersect(vecPolygons[i]);
    }
    
    auto endTime = std::chrono::high_resolution_clock::now();
    auto diffTime = endTime - startTime;
    std::cout << "Total cost: " << diffTime.count() * 1e-9 << std::endl;
    return 0;
}

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits): Windows 11 home basic 64 bits
  • Compiler: MSVC-2019-Community
  • Release or debug mode: Release
  • Specific flags used (if any):
  • CGAL version: CGAL5.2.3 CGAL5.3
  • Boost version: boost_1_76_0
  • Other libraries versions if used (Eigen, TBB, etc.):

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions