GeomSolver Docs

Benchmarks

Criterion.rs benchmarks, algorithm comparisons, and scaling analysis.

Benchmarks

The solver uses Criterion.rs v0.5 for statistically rigorous benchmarking with HTML reports.

Running Benchmarks

# Full benchmark suite
cargo bench

# Specific benchmark
cargo bench -- chain_solve

HTML reports are generated in target/criterion/<benchmark>/report/index.html.

Macro-Benchmarks

BenchmarkDescriptionParameters
chain_solveSerial distance constraints5 / 20 links
grid_solve2D grid with horizontal + vertical4×4 grid
tangent_garden_solveMultiple tangent circles6 circles
mixed_solveMix of all constraint types30 constraints
overconstrained_solveRedundant constraints2× overdetermined

Algorithm Comparison

The headline comparison on the chain-20 benchmark:

AlgorithmTimeRelativeIterations
DogLeg2.41 ms1.0×12
BFGS3.30 ms1.4×15
L-BFGS3.15 ms1.3×16
Sparse CG5.20 ms2.2×22
LM54.8 ms22.7×48

DogLeg dominates on chain problems because the Gauss-Newton step is nearly exact, and the trust-region framework avoids LM's conservative damping.

Chain-5 (smaller problem)

AlgorithmTime
DogLeg85.9 µs
BFGS102 µs
LM1.95 ms

Micro-Benchmarks

Isolated measurement of individual operations:

BenchmarkWhat It Measures
compute_residualsResidual vector evaluation
compute_jacobianAnalytical Jacobian computation
finaliseSolution extraction and verification

These help identify bottlenecks independently of the solver algorithm.

Scaling Benchmarks

Chain problems at increasing sizes:

ProblemParametersDogLegLM
chain-501006.2 ms142 ms
chain-10020014.8 ms410 ms
chain-20040038.5 ms1200 ms

DogLeg scales roughly linearly with problem size for chain problems, while LM scales superlinearly due to the dense linear system solves.

Cross-Validation Benchmark

Runs all algorithms on the same problem and compares results:

cargo bench -- cross_validation

Measures the overhead of running multiple algorithms in sequence. Typical overhead is 2–3× compared to a single algorithm.

Intelligent Multi-Start Benchmark

ProblemSingle StartMulti-Start (20)Best-of
chain-202.41 ms28.5 ms2.38 ms
tangent_garden5.10 ms62.3 ms3.90 ms

Multi-start finds better solutions on problems with multiple local minima, at the cost of 10–15× runtime.

L-BFGS vs BFGS

ProblemnBFGSL-BFGS (m=10)
chain-20403.30 ms3.15 ms
chain-10020018.2 ms12.1 ms
chain-20040052.8 ms24.3 ms

L-BFGS becomes significantly faster for n ≥ 100 due to O(mn) vs O(n²) per-iteration cost.

Stagnation Detection On/Off

ProblemStagnation ONStagnation OFF
chain-202.41 ms2.41 ms
overconstrained1.80 ms4.20 ms

Stagnation detection has negligible overhead on well-conditioned problems but dramatically speeds up pathological cases by terminating early.

Performance Metrics Overhead

Enabling tracing and diagnostics adds ~5% overhead:

Modechain-20
No tracing2.41 ms
With tracing2.53 ms
Full diagnostics2.58 ms

Baseline Report

A baseline benchmark report is maintained at:

benchmarks/BASELINE.md

CI runs benchmarks and compares against the baseline. Regressions larger than 10% trigger a warning.