# Delaunay Library Performance Results

This file contains performance benchmarks and analysis for the delaunay library.
The results are automatically generated and updated by the benchmark infrastructure.

**Last Updated**: 2026-04-25 15:39:16 UTC
**Generated By**: benchmark_utils.py
**Git Commit**: 7e42be8fba9abe571d0137710fbd7ed0151ebc85
**Hardware**: Apple M4 Max (16 cores)
**Memory**: 64.0 GB
**OS**: macOS
**Rust**: rustc 1.95.0 (59807616e 2026-04-14)

## Performance Results Summary

### Circumsphere Performance Results

#### Version 0.7.6 Results (2026-04-25)

#### Single Query Performance (2D)

| Test Case | insphere | insphere_distance | insphere_lifted | Winner |
|-----------|----------|------------------|-----------------|---------|
| Basic 2D | 15 ns | 25 ns | 7 ns | **insphere_lifted** |
| Boundary vertex | 2 ns | 24 ns | 196 ns | **insphere** |
| Far vertex | 15 ns | 25 ns | 7 ns | **insphere_lifted** |

#### Single Query Performance (3D)

| Test Case | insphere | insphere_distance | insphere_lifted | Winner |
|-----------|----------|------------------|-----------------|---------|
| Basic 3D | 2.1 µs | 25 ns | 17 ns | **insphere_lifted** |
| Boundary vertex | 2 ns | 26 ns | 432 ns | **insphere** |
| Far vertex | 2.1 µs | 26 ns | 17 ns | **insphere_lifted** |

#### Single Query Performance (4D)

| Test Case | insphere | insphere_distance | insphere_lifted | Winner |
|-----------|----------|------------------|-----------------|---------|
| Basic 4D | 5.1 µs | 53 ns | 2.9 µs | **insphere_distance** |
| Boundary vertex | 2 ns | 60 ns | 1.5 µs | **insphere** |
| Far vertex | 3.2 µs | 53 ns | 1.8 µs | **insphere_distance** |

#### Single Query Performance (5D)

| Test Case | insphere | insphere_distance | insphere_lifted | Winner |
|-----------|----------|------------------|-----------------|---------|
| Basic 5D | 8.3 µs | 80 ns | 4.8 µs | **insphere_distance** |
| Boundary vertex | 2 ns | 81 ns | 2.3 µs | **insphere** |
| Far vertex | 4.9 µs | 79 ns | 2.8 µs | **insphere_distance** |

## Triangulation Data Structure Performance

### Current Baseline Information

- **Date: 2026-04-11 10:49:34 PDT**
- **Git commit: 136e3aab378ac2a7d6aa2a08f5a5d876cd233a83**
- **Hardware: Apple M4 Max (16 cores)**

### 2D Triangulation Performance

| Points | Time (mean) | Throughput (mean) | Scaling |
|--------|-------------|-------------------|----------|
| 10 | 128.42 µs | 77.869 Kelem/s | 1.0x |
| 25 | 852.99 µs | 29.309 Kelem/s | 6.6x |
| 50 | 2.979 ms | 16.784 Kelem/s | 23.2x |

### 3D Triangulation Performance

| Points | Time (mean) | Throughput (mean) | Scaling |
|--------|-------------|-------------------|----------|
| 10 | 879.16 µs | 11.375 Kelem/s | 1.0x |
| 25 | 18.530 ms | 1.349 Kelem/s | 21.1x |
| 50 | 97.600 ms | 0.512 Kelem/s | 111.0x |

### 4D Triangulation Performance

| Points | Time (mean) | Throughput (mean) | Scaling |
|--------|-------------|-------------------|----------|
| 10 | 10.251 ms | 0.975 Kelem/s | 1.0x |
| 25 | 1162.064 ms | 0.022 Kelem/s | 113.4x |
| 50 | 480.595 ms | 0.104 Kelem/s | 46.9x |

### 5D Triangulation Performance

| Points | Time (mean) | Throughput (mean) | Scaling |
|--------|-------------|-------------------|----------|
| 10 | 27.463 ms | 0.364 Kelem/s | 1.0x |
| 25 | 5956.682 ms | 0.004 Kelem/s | 216.9x |

## Key Findings

### Performance Ranking

1. **insphere_distance** - (best in 4D, 5D) - Best average performance
2. **insphere_lifted** - (best in 2D, 3D) - ~33.6x average vs fastest
3. **insphere** - ~70.4x slower than fastest on average

### Numerical Accuracy Analysis

Based on random test cases:

- **insphere vs insphere_distance**: 100.0% agreement
- **insphere vs insphere_lifted**: 100.0% agreement (different algorithms)
- **insphere_distance vs insphere_lifted**: 100.0% agreement
- **All three methods agree**: 100.0% (expected due to different numerical approaches)

## Recommendations

### Method Selection Guide

**All three methods are mathematically correct** (they produce valid insphere test results).
Choose based on your specific requirements:

#### Performance Optimization by Dimension

- **`insphere_distance`**: (best in 4D, 5D) - Best average performance
- **`insphere_lifted`**: (best in 2D, 3D) - ~33.6x average vs fastest

#### General Recommendations

**For maximum performance**: Choose the method that performs best in your target dimension (see above)

**For general-purpose use**: `insphere` provides consistent performance across all dimensions
and uses the standard determinant-based approach with well-understood numerical properties

**For algorithm transparency**: `insphere_distance` explicitly calculates the circumcenter,
making it excellent for educational purposes, debugging, and algorithm validation

#### Performance Comparison

Average performance across all non-boundary test cases:

- `insphere_distance`: 46 ns (best in 4D, 5D)
- `insphere_lifted`: 1.5 µs (best in 2D, 3D)
- `insphere`: 3.2 µs (third fastest)

## Conclusion

All three methods are mathematically correct and produce valid results. Performance characteristics vary by dimension:

- `insphere_distance` (best in 4D, 5D) - Best average performance
- `insphere_lifted` (best in 2D, 3D) - ~33.6x average vs fastest

For general-purpose applications, choose based on your primary use case:

- **Performance-critical**: Use the method that performs best in your target dimension
- **Numerical stability**: Use `insphere` for its proven mathematical properties
- **Educational/debugging**: Use `insphere_distance` for its transparent algorithm

## Historical Version Comparison

*Based on archived performance measurements from previous releases:*

### v0.3.0 → v0.3.1 Performance Improvements

| Test Case | Method | v0.3.0 | v0.3.1 | Improvement |
|-----------|--------|--------|--------|-------------|
| Basic 3D | insphere | 808 ns | 805 ns | +0.4% |
| Basic 3D | insphere_distance | 1,505 ns | 1,463 ns | +2.8% |
| Basic 3D | insphere_lifted | 646 ns | 637 ns | +1.4% |
| Random 1000 queries | insphere | 822 µs | 811 µs | +1.3% |
| Random 1000 queries | insphere_distance | 1,535 µs | 1,494 µs | +2.7% |
| Random 1000 queries | insphere_lifted | 661 µs | 650 µs | +1.7% |
| 2D | insphere_lifted | 442 ns | 440 ns | +0.5% |
| 4D | insphere_lifted | 962 ns | 955 ns | +0.7% |

**Key Improvements**: Version 0.3.1 showed consistent performance gains across all methods,
with `insphere_distance` seeing the largest improvement (+2.8%). The changes implemented
improved numerical stability using `hypot` and `squared_norm` functions while providing
measurable performance gains.

## Implementation Notes

### Performance Advantages of `insphere_lifted`

1. More efficient matrix formulation using relative coordinates
2. Avoids redundant circumcenter calculations
3. Optimized determinant computation

### Method Disagreements

The disagreements between methods are expected due to:

1. Different numerical approaches and tolerances
2. Floating-point precision differences in multi-step calculations
3. Varying sensitivity to degenerate cases

## Benchmark Structure

The `circumsphere_containment.rs` benchmark includes:

- **Random queries**: Batch processing performance with 1000 random test points
- **Dimensional tests**: Performance across 2D, 3D, 4D, and 5D simplices
- **Edge cases**: Boundary vertices and far-away points
- **Numerical consistency**: Agreement analysis between all methods

## Performance Data Updates

This file is automatically generated from benchmark results. To update:

```bash
# Generate performance summary with current data
uv run benchmark-utils generate-summary

# Run fresh perf-profile benchmarks and generate summary (includes numerical accuracy)
uv run benchmark-utils generate-summary --run-benchmarks --profile perf

# Generate baseline results for regression testing
uv run benchmark-utils generate-baseline
```

### Customization

For manual updates or custom analysis, modify the `PerformanceSummaryGenerator`
class in `scripts/benchmark_utils.py`. This provides enhanced control over
dynamic vs static content organization and supports parsing numerical accuracy
data from live benchmark runs.
