Performance & benchmarks
Performance notes
A few rules of thumb when scattering calculations get expensive:
- Cost grows with the size parameter. The truncation order needed for convergence scales roughly with $x = 2\pi r/\lambda$, and the dense linear algebra is super-linear in that order. Large particles are intrinsically costly.
- Reach for
stablebefore raising precision on high-aspect spheroids. For an elongated spheroid inFloat64,Iterative(EBCM; stable = true)is both more accurate and faster than bumping the element type toDouble64without it; see Usage → High-aspect-ratio spheroids. - Extended precision is several times slower.
Double64/Arbbuy headroom against round-off and larger size parameters, but at a real runtime cost. Use them when accuracy demands it, not by default. - Reuse a preparation for parameter sweeps. When you need one shape at many wavelengths or refractive indices,
prepare_sh/ShMatrixamortise the geometry quadrature across all points. - Multithreading. Several kernels use threads; start Julia with
julia --threads=auto(or setJULIA_NUM_THREADS) to use them.
The benchmark suite
The repository ships a benchmark suite built on BenchmarkTools.jl, in benchmark/. It follows the standard Julia convention — benchmark/benchmarks.jl defines a single global const SUITE::BenchmarkGroup — so it works unchanged with both PkgBenchmark.jl and AirspeedVelocity.jl.
Benchmark groups:
special_functions— Riccati–Bessel and Wigner-d recursions (inner kernels).ebcm— EBCM blocks, fixed-order solves, and end-to-end auto-convergence.iitm— invariant-imbedding T-matrix (axisymmetric and N-fold).postprocessing— far-field observables from a precomputed T-matrix.linearization— the analytical EBCM Jacobian.precision—Float64vsDouble64on the same EBCM block.
Running
The simplest path uses the repository's justfile:
just bench # instantiate the env and run the whole suiteOr directly, in the isolated benchmark/ environment:
julia --project=benchmark -e 'using Pkg; Pkg.develop(path="."); Pkg.instantiate()'
julia --project=benchmark benchmark/runbenchmarks.jl results-baseline.jsonAbsolute timings are machine-specific, so no numbers are reproduced here; the suite is meant for tracking relative changes (regressions and speed-ups) between revisions. See benchmark/README.md for the full layout.