Compares the performance of CDT.NET against other C# and native CDT/Delaunay triangulation libraries on the same input datasets used by the CDT.NET test suite.
| Category | Description |
|---|---|
VerticesOnly |
Delaunay triangulation of all vertices, no constraint edges |
Constrained |
Full CDT — vertices + constraint edges |
The dataset used is "Constrained Sweden" (~2 600 vertices, ~2 600 constraint edges), the same dataset used by the upstream C++ CDT benchmark suite.
The C# libraries (CDT.NET, Triangle.NET, NetTopologySuite) are fetched automatically by NuGet.
The three native wrappers (artem-ogre/CDT, CGAL, Spade) are compiled from source as part of dotnet build. CGAL and its required Boost sub-libraries are downloaded automatically by CMake FetchContent on first build (~20 MB total, cached afterwards). No manual installation of CGAL or Boost is required.
| Tool | Purpose | Install |
|---|---|---|
cmake ≥ 3.20 |
Builds the C++ wrappers | Package manager or https://cmake.org/download/ |
| C++17 compiler | gcc/clang |
sudo apt install build-essential / xcode-select --install |
git |
CMake FetchContent (downloads artem-ogre/CDT) | Usually pre-installed |
cargo (Rust stable) |
Builds the Rust wrapper | https://rustup.rs/ |
# Ubuntu / Debian
sudo apt install cmake build-essential git
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh# macOS
brew install cmake
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh| Tool | Purpose | Install |
|---|---|---|
| Visual Studio 2022 (or Build Tools) with the "Desktop development with C++" workload | C++17 compiler (MSVC) | https://visualstudio.microsoft.com/downloads/ |
| CMake ≥ 3.20 | Builds the C++ wrappers | Bundled with VS 2022, or https://cmake.org/download/ (tick "Add to PATH") |
| Git for Windows | CMake FetchContent (downloads artem-ogre/CDT, CGAL, Boost sub-libs) | https://git-scm.com/download/win |
| Rust (stable, MSVC ABI) | Builds the Rust wrapper | https://rustup.rs/ → choose x86_64-pc-windows-msvc |
Tip: Install Visual Studio first, then Rust. The Rust installer auto-detects the MSVC linker.
Open a Developer Command Prompt for VS 2022 (or a normal terminal after runningvcvarsall.bat) so thatcmake,cl, andcargoare all on your PATH.CGAL and Boost are downloaded automatically by CMake — no manual install required.
If any of these tools are missing, dotnet build will print a clear error message pointing to the missing tool before failing.
# From the repository root — Release configuration is required for BenchmarkDotNet
dotnet run --project benchmark/CDT.Comparison.Benchmarks -c ReleaseBenchmarkDotNet will present an interactive menu to select which benchmark class / category to run. To run all benchmarks non-interactively:
dotnet run --project benchmark/CDT.Comparison.Benchmarks -c Release -- --filter "*"Results are written to BenchmarkDotNet.Artifacts/ in the current directory.
| Library | Limitation |
|---|---|
| NetTopologySuite | Uses conforming CDT — Steiner points may be inserted, so the triangle count and layout differ from true CDT results |
| artem-ogre/CDT (C++) | Triangle count includes all convex-hull triangles (same behaviour as CDT.NET before EraseSuperTriangle) |
| CGAL (C++) | number_of_faces() counts all finite triangles in the triangulation, consistent with artem-ogre/CDT. First build downloads CGAL 6.1.1 library headers (~10 MB) and the required Boost sub-library headers (~10 MB ZIPs, ~60 MB staged); subsequent builds use the cmake cache. |
| Spade (Rust) | num_inner_faces() returns only inner (non-convex-hull) triangles, which is fewer than the C++ CDT counts |
Constrained Delaunay Triangulation
--------------------------------------
CDT.NET 5.239 triangles
artem-ogre/CDT (C++) 5.239 triangles
Spade (Rust) 5.204 triangles
CGAL (C++) 5.204 triangles
Triangle.NET 5.204 triangles
--------------------------------------
Conforming Delaunay Triangulation
--------------------------------------
CDT.NET 5.343 triangles
artem-ogre/CDT (C++) 5.343 triangles
Spade (Rust) 5.308 triangles
CGAL (C++) 5.324 triangles
NTS 5.764 triangles
Triangle.NET 5.204 triangles
--------------------------------------
12th Gen Intel Core i7-12700KF 3.60GHz, 1 CPU, 20 logical and 12 physical cores
- CDT.NET matches the original C++ implementation (artem-ogre/CDT) and Spade within ≤13%.
- CGAL runs at ~2× CDT.NET. CGAL's
Constrained_Delaunay_triangulation_2uses a more complex data structure (half-edge DCEL) with additional bookkeeping overhead vs. CDT.NET's compact flat arrays. For raw triangulation throughput CDT.NET is faster. - CDT.NET allocates 5–120× less managed memory than Triangle.NET and NTS: Triangle.NET allocates ~5.7× more, NTS ~121× more.
- NTS (conforming CDT) is ~30× slower and allocates ~120× more memory — Steiner-point insertion is the main cost, and the result is semantically different (not true CDT).
- Native wrappers (artem-ogre/CDT, CGAL, Spade) show zero managed allocations as expected for P/Invoke calls into unmanaged code.
