Benchmarks
ConvolvedDistributions benchmarks its hot paths so the cost of the numeric quadrature backend is visible against the analytic one and regressions are caught on every pull request.
The suite (benchmark/benchmarks.jl) covers:
Baseline: the bare Gamma and Normal components, the floor everything else is read against.Convolved: densities and CDFs on both backends — the analytic Normal+Normal pair (closed form, should sit near the baseline) and the numeric Gamma+LogNormal pair (Gauss-Legendre quadrature). Thebatchedrows use the vector methods that share quadrature nodes across evaluation points; their gap to the scalarlogpdf broadcastrow over the same 100 points is the headline number for the numeric backend.Difference: theZ = X - Ydual on the same analytic/numeric split. Difference has no batched methods, so evaluation rows broadcast the scalar path.Timeseries:convolve_series(delay, series), with the delay PMF discretised from a Gamma and from a numericConvolveddelay.Quantile: the Optimization-extension inverse CDF (Nelder-Mead overcdf); the numeric variants pay one quadrature CDF per optimiser iteration and are the slowest rows in the suite.AD gradients:DifferentiationInterface.gradientof everytest/ADFixturesscenario across the ForwardDiff, ReverseDiff, Mooncake and Enzyme backends, sharing the fixtures that drive the AD test suite.
Run the suite locally with task benchmark, or compare against main with task benchmark-compare (see benchmark/README.md). On pull requests the benchmark workflow benchmarks head and base in separate jobs and posts a single comparison comment. Pushes to main and tags append to the performance history shown below.
Performance history
Ratio summary
| a969b15e5a2dd2... | |
|---|---|
| AD gradients/Convolved Gamma+LogNormal numerical/Enzyme forward | 0.112 ± 0.00057 ms |
| AD gradients/Convolved Gamma+LogNormal numerical/Enzyme reverse | 0.151 ± 0.00083 ms |
| AD gradients/Convolved Gamma+LogNormal numerical/ForwardDiff | 0.115 ± 0.00026 ms |
| AD gradients/Convolved Gamma+LogNormal numerical/Mooncake forward | 0.476 ± 0.0093 ms |
| AD gradients/Convolved Gamma+LogNormal numerical/Mooncake reverse | 0.719 ± 0.022 ms |
| AD gradients/Convolved Gamma+LogNormal numerical/ReverseDiff (tape) | 4.34 ± 0.53 ms |
| AD gradients/Convolved Gamma+Normal mean+var moments/Enzyme forward | 7.47 ± 0.11 μs |
| AD gradients/Convolved Gamma+Normal mean+var moments/Enzyme reverse | 0.0488 ± 0.0083 μs |
| AD gradients/Convolved Gamma+Normal mean+var moments/ForwardDiff | 0.62 ± 0.046 μs |
| AD gradients/Convolved Gamma+Normal mean+var moments/Mooncake forward | 5.54 ± 0.66 μs |
| AD gradients/Convolved Gamma+Normal mean+var moments/Mooncake reverse | 15.1 ± 0.63 μs |
| AD gradients/Convolved Gamma+Normal mean+var moments/ReverseDiff (tape) | 2.66 ± 0.11 μs |
| AD gradients/Convolved LogNormal+Gamma numerical/Enzyme forward | 0.113 ± 0.00048 ms |
| AD gradients/Convolved LogNormal+Gamma numerical/Enzyme reverse | 0.159 ± 0.001 ms |
| AD gradients/Convolved LogNormal+Gamma numerical/ForwardDiff | 0.112 ± 0.00023 ms |
| AD gradients/Convolved LogNormal+Gamma numerical/Mooncake forward | 0.504 ± 0.0092 ms |
| AD gradients/Convolved LogNormal+Gamma numerical/Mooncake reverse | 0.754 ± 0.019 ms |
| AD gradients/Convolved LogNormal+Gamma numerical/ReverseDiff (tape) | 4.21 ± 0.52 ms |
| AD gradients/Convolved Normal+Normal analytical/Enzyme forward | 8.17 ± 0.097 μs |
| AD gradients/Convolved Normal+Normal analytical/Enzyme reverse | 3.34 ± 0.059 μs |
| AD gradients/Convolved Normal+Normal analytical/ForwardDiff | 0.619 ± 0.088 μs |
| AD gradients/Convolved Normal+Normal analytical/Mooncake forward | 5.86 ± 0.56 μs |
| AD gradients/Convolved Normal+Normal analytical/Mooncake reverse | 30.1 ± 3.3 μs |
| AD gradients/Convolved Normal+Normal analytical/ReverseDiff (tape) | 17.4 ± 0.48 μs |
| AD gradients/Difference Gamma-LogNormal numerical wrt X/Enzyme forward | 0.114 ± 0.001 ms |
| AD gradients/Difference Gamma-LogNormal numerical wrt X/Enzyme reverse | 0.153 ± 0.00076 ms |
| AD gradients/Difference Gamma-LogNormal numerical wrt X/ForwardDiff | 0.115 ± 0.00023 ms |
| AD gradients/Difference Gamma-LogNormal numerical wrt X/Mooncake forward | 0.478 ± 0.0094 ms |
| AD gradients/Difference Gamma-LogNormal numerical wrt X/Mooncake reverse | 0.706 ± 0.024 ms |
| AD gradients/Difference Gamma-LogNormal numerical wrt X/ReverseDiff (tape) | 4.34 ± 0.52 ms |
| AD gradients/Difference Gamma-Normal mean+var moments/Enzyme forward | 7.81 ± 0.2 μs |
| AD gradients/Difference Gamma-Normal mean+var moments/Enzyme reverse | 0.0484 ± 0.0075 μs |
| AD gradients/Difference Gamma-Normal mean+var moments/ForwardDiff | 0.549 ± 0.044 μs |
| AD gradients/Difference Gamma-Normal mean+var moments/Mooncake forward | 5.2 ± 0.63 μs |
| AD gradients/Difference Gamma-Normal mean+var moments/Mooncake reverse | 5.18 ± 0.42 μs |
| AD gradients/Difference Gamma-Normal mean+var moments/ReverseDiff (tape) | 2.64 ± 0.073 μs |
| AD gradients/Difference LogNormal-Gamma numerical wrt Y/Enzyme forward | 0.116 ± 0.00092 ms |
| AD gradients/Difference LogNormal-Gamma numerical wrt Y/Enzyme reverse | 0.159 ± 0.0016 ms |
| AD gradients/Difference LogNormal-Gamma numerical wrt Y/ForwardDiff | 0.115 ± 0.00029 ms |
| AD gradients/Difference LogNormal-Gamma numerical wrt Y/Mooncake forward | 0.521 ± 0.0092 ms |
| AD gradients/Difference LogNormal-Gamma numerical wrt Y/Mooncake reverse | 0.748 ± 0.021 ms |
| AD gradients/Difference LogNormal-Gamma numerical wrt Y/ReverseDiff (tape) | 4.22 ± 0.53 ms |
| AD gradients/Difference Normal-Normal analytical/Enzyme forward | 8.11 ± 0.11 μs |
| AD gradients/Difference Normal-Normal analytical/Enzyme reverse | 3.22 ± 0.08 μs |
| AD gradients/Difference Normal-Normal analytical/ForwardDiff | 0.574 ± 0.089 μs |
| AD gradients/Difference Normal-Normal analytical/Mooncake forward | 5.96 ± 0.54 μs |
| AD gradients/Difference Normal-Normal analytical/Mooncake reverse | 30.8 ± 3.4 μs |
| AD gradients/Difference Normal-Normal analytical/ReverseDiff (tape) | 18.8 ± 0.49 μs |
| AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Enzyme forward | 0.981 ± 0.0016 ms |
| AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Enzyme reverse | 1.04 ± 0.0033 ms |
| AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/ForwardDiff | 0.783 ± 0.0017 ms |
| AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Mooncake forward | 3.76 ± 0.0066 ms |
| AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Mooncake reverse | 2.31 ± 0.031 ms |
| AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/ReverseDiff (tape) | 15.8 ± 1.3 ms |
| AD gradients/Timeseries convolve Gamma delay/Enzyme forward | 10.7 ± 0.12 μs |
| AD gradients/Timeseries convolve Gamma delay/Enzyme reverse | 14.3 ± 0.17 μs |
| AD gradients/Timeseries convolve Gamma delay/ForwardDiff | 3.23 ± 0.04 μs |
| AD gradients/Timeseries convolve Gamma delay/Mooncake forward | 12.6 ± 0.45 μs |
| AD gradients/Timeseries convolve Gamma delay/Mooncake reverse | 22.6 ± 2.7 μs |
| AD gradients/Timeseries convolve Gamma delay/ReverseDiff (tape) | 0.0362 ± 0.0008 ms |
| Baseline/Gamma/cdf | 3.56 ± 0.21 μs |
| Baseline/Gamma/logpdf | 2.9 ± 0.34 μs |
| Baseline/Normal/cdf | 1.5 ± 0.36 μs |
| Baseline/Normal/logpdf | 1.05 ± 0.026 μs |
| Convolved/analytic/cdf batched | 2.66 ± 0.34 μs |
| Convolved/analytic/cdf scalar | 29.2 ± 0.14 ns |
| Convolved/analytic/construction | 3.1 ± 0.01 ns |
| Convolved/analytic/logpdf batched | 1.08 ± 0.028 μs |
| Convolved/analytic/logpdf broadcast | 2.57 ± 0.33 μs |
| Convolved/analytic/logpdf scalar | 28.7 ± 0.069 ns |
| Convolved/analytic/mean | 3.1 ± 0.01 ns |
| Convolved/analytic/pdf batched | 1.12 ± 0.034 μs |
| Convolved/analytic/pdf scalar | 31.1 ± 0.18 ns |
| Convolved/analytic/rand | 1.13 ± 0.039 μs |
| Convolved/numeric/cdf batched | 0.552 ± 0.0091 ms |
| Convolved/numeric/cdf scalar | 21.3 ± 0.07 μs |
| Convolved/numeric/construction | 3.1 ± 0.01 ns |
| Convolved/numeric/logpdf batched | 0.771 ± 0.0026 ms |
| Convolved/numeric/logpdf broadcast | 1.63 ± 0.0085 ms |
| Convolved/numeric/logpdf scalar | 16.1 ± 0.059 μs |
| Convolved/numeric/mean | 6.66 ± 0.011 ns |
| Convolved/numeric/pdf batched | 0.771 ± 0.0028 ms |
| Convolved/numeric/pdf scalar | 16.1 ± 0.05 μs |
| Convolved/numeric/rand | 2.79 ± 0.35 μs |
| Difference/analytic/cdf broadcast | 3.38 ± 0.37 μs |
| Difference/analytic/cdf scalar | 10.8 ± 0.02 ns |
| Difference/analytic/construction | 3.11 ± 0.01 ns |
| Difference/analytic/logpdf broadcast | 1.52 ± 0.3 μs |
| Difference/analytic/logpdf scalar | 17.1 ± 0.081 ns |
| Difference/analytic/mean | 2.79 ± 0.01 ns |
| Difference/analytic/rand | 1.13 ± 0.041 μs |
| Difference/numeric/cdf broadcast | 1.22 ± 0.0068 ms |
| Difference/numeric/cdf scalar | 14.5 ± 0.09 μs |
| Difference/numeric/construction | 3.41 ± 0.01 ns |
| Difference/numeric/logpdf broadcast | 1.62 ± 0.0087 ms |
| Difference/numeric/logpdf scalar | 16.2 ± 0.16 μs |
| Difference/numeric/mean | 6.59 ± 0.04 ns |
| Difference/numeric/rand | 2.8 ± 0.35 μs |
| Quantile/Convolved analytic/grid | 0.567 ± 0.1 ms |
| Quantile/Convolved analytic/median | 21.6 ± 0.97 μs |
| Quantile/Convolved numeric/median | 0.379 ± 0.01 ms |
| Quantile/Difference numeric/median | 0.217 ± 0.0048 ms |
| Timeseries/Convolved delay | 0.981 ± 0.0016 ms |
| Timeseries/Gamma delay | 1.88 ± 0.032 μs |
| time_to_load | 0.848 ± 0.0023 s |
| a969b15e5a2dd2... | |
|---|---|
| AD gradients/Convolved Gamma+LogNormal numerical/Enzyme forward | 0.036 k allocs: 1.11 kB |
| AD gradients/Convolved Gamma+LogNormal numerical/Enzyme reverse | 14 allocs: 1.86 kB |
| AD gradients/Convolved Gamma+LogNormal numerical/ForwardDiff | 7 allocs: 0.266 kB |
| AD gradients/Convolved Gamma+LogNormal numerical/Mooncake forward | 0.058 k allocs: 2.91 kB |
| AD gradients/Convolved Gamma+LogNormal numerical/Mooncake reverse | 0.953 k allocs: 1.14 MB |
| AD gradients/Convolved Gamma+LogNormal numerical/ReverseDiff (tape) | 0.0529 M allocs: 2.06 MB |
| AD gradients/Convolved Gamma+Normal mean+var moments/Enzyme forward | 0.032 k allocs: 1.3 kB |
| AD gradients/Convolved Gamma+Normal mean+var moments/Enzyme reverse | 2 allocs: 0.0938 kB |
| AD gradients/Convolved Gamma+Normal mean+var moments/ForwardDiff | 7 allocs: 0.484 kB |
| AD gradients/Convolved Gamma+Normal mean+var moments/Mooncake forward | 0.07 k allocs: 3.33 kB |
| AD gradients/Convolved Gamma+Normal mean+var moments/Mooncake reverse | 0.078 k allocs: 3.71 kB |
| AD gradients/Convolved Gamma+Normal mean+var moments/ReverseDiff (tape) | 0.041 k allocs: 1.7 kB |
| AD gradients/Convolved LogNormal+Gamma numerical/Enzyme forward | 0.036 k allocs: 1.11 kB |
| AD gradients/Convolved LogNormal+Gamma numerical/Enzyme reverse | 14 allocs: 1.86 kB |
| AD gradients/Convolved LogNormal+Gamma numerical/ForwardDiff | 7 allocs: 0.266 kB |
| AD gradients/Convolved LogNormal+Gamma numerical/Mooncake forward | 0.058 k allocs: 2.91 kB |
| AD gradients/Convolved LogNormal+Gamma numerical/Mooncake reverse | 0.953 k allocs: 1.14 MB |
| AD gradients/Convolved LogNormal+Gamma numerical/ReverseDiff (tape) | 0.0529 M allocs: 2.06 MB |
| AD gradients/Convolved Normal+Normal analytical/Enzyme forward | 0.036 k allocs: 1.11 kB |
| AD gradients/Convolved Normal+Normal analytical/Enzyme reverse | 24 allocs: 1.03 kB |
| AD gradients/Convolved Normal+Normal analytical/ForwardDiff | 7 allocs: 0.266 kB |
| AD gradients/Convolved Normal+Normal analytical/Mooncake forward | 0.058 k allocs: 2.91 kB |
| AD gradients/Convolved Normal+Normal analytical/Mooncake reverse | 0.289 k allocs: 0.0329 MB |
| AD gradients/Convolved Normal+Normal analytical/ReverseDiff (tape) | 0.238 k allocs: 9.92 kB |
| AD gradients/Difference Gamma-LogNormal numerical wrt X/Enzyme forward | 0.036 k allocs: 1.11 kB |
| AD gradients/Difference Gamma-LogNormal numerical wrt X/Enzyme reverse | 14 allocs: 1.7 kB |
| AD gradients/Difference Gamma-LogNormal numerical wrt X/ForwardDiff | 7 allocs: 0.266 kB |
| AD gradients/Difference Gamma-LogNormal numerical wrt X/Mooncake forward | 0.058 k allocs: 2.91 kB |
| AD gradients/Difference Gamma-LogNormal numerical wrt X/Mooncake reverse | 0.857 k allocs: 1.11 MB |
| AD gradients/Difference Gamma-LogNormal numerical wrt X/ReverseDiff (tape) | 0.0529 M allocs: 2.06 MB |
| AD gradients/Difference Gamma-Normal mean+var moments/Enzyme forward | 0.032 k allocs: 1.3 kB |
| AD gradients/Difference Gamma-Normal mean+var moments/Enzyme reverse | 2 allocs: 0.0938 kB |
| AD gradients/Difference Gamma-Normal mean+var moments/ForwardDiff | 7 allocs: 0.484 kB |
| AD gradients/Difference Gamma-Normal mean+var moments/Mooncake forward | 0.07 k allocs: 3.33 kB |
| AD gradients/Difference Gamma-Normal mean+var moments/Mooncake reverse | 0.078 k allocs: 3.71 kB |
| AD gradients/Difference Gamma-Normal mean+var moments/ReverseDiff (tape) | 0.041 k allocs: 1.7 kB |
| AD gradients/Difference LogNormal-Gamma numerical wrt Y/Enzyme forward | 0.036 k allocs: 1.11 kB |
| AD gradients/Difference LogNormal-Gamma numerical wrt Y/Enzyme reverse | 14 allocs: 1.89 kB |
| AD gradients/Difference LogNormal-Gamma numerical wrt Y/ForwardDiff | 7 allocs: 0.266 kB |
| AD gradients/Difference LogNormal-Gamma numerical wrt Y/Mooncake forward | 0.058 k allocs: 2.91 kB |
| AD gradients/Difference LogNormal-Gamma numerical wrt Y/Mooncake reverse | 0.857 k allocs: 1.11 MB |
| AD gradients/Difference LogNormal-Gamma numerical wrt Y/ReverseDiff (tape) | 0.0529 M allocs: 2.06 MB |
| AD gradients/Difference Normal-Normal analytical/Enzyme forward | 0.036 k allocs: 1.11 kB |
| AD gradients/Difference Normal-Normal analytical/Enzyme reverse | 24 allocs: 1.02 kB |
| AD gradients/Difference Normal-Normal analytical/ForwardDiff | 7 allocs: 0.266 kB |
| AD gradients/Difference Normal-Normal analytical/Mooncake forward | 0.058 k allocs: 2.91 kB |
| AD gradients/Difference Normal-Normal analytical/Mooncake reverse | 0.289 k allocs: 0.0331 MB |
| AD gradients/Difference Normal-Normal analytical/ReverseDiff (tape) | 0.268 k allocs: 10.9 kB |
| AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Enzyme forward | 0.052 k allocs: 2.39 kB |
| AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Enzyme reverse | 0.034 k allocs: 1.72 kB |
| AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/ForwardDiff | 0.046 k allocs: 3.08 kB |
| AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Mooncake forward | 0.11 k allocs: 5.53 kB |
| AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Mooncake reverse | 0.807 k allocs: 1.34 MB |
| AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/ReverseDiff (tape) | 0.133 M allocs: 5.45 MB |
| AD gradients/Timeseries convolve Gamma delay/Enzyme forward | 0.04 k allocs: 1.62 kB |
| AD gradients/Timeseries convolve Gamma delay/Enzyme reverse | 0.034 k allocs: 1.7 kB |
| AD gradients/Timeseries convolve Gamma delay/ForwardDiff | 11 allocs: 0.703 kB |
| AD gradients/Timeseries convolve Gamma delay/Mooncake forward | 0.082 k allocs: 4.23 kB |
| AD gradients/Timeseries convolve Gamma delay/Mooncake reverse | 0.176 k allocs: 16.6 kB |
| AD gradients/Timeseries convolve Gamma delay/ReverseDiff (tape) | 0.449 k allocs: 18 kB |
| Baseline/Gamma/cdf | 2 allocs: 0.906 kB |
| Baseline/Gamma/logpdf | 2 allocs: 0.906 kB |
| Baseline/Normal/cdf | 2 allocs: 0.906 kB |
| Baseline/Normal/logpdf | 2 allocs: 0.906 kB |
| Convolved/analytic/cdf batched | 2 allocs: 0.906 kB |
| Convolved/analytic/cdf scalar | 0 allocs: 0 B |
| Convolved/analytic/construction | 0 allocs: 0 B |
| Convolved/analytic/logpdf batched | 2 allocs: 0.906 kB |
| Convolved/analytic/logpdf broadcast | 2 allocs: 0.906 kB |
| Convolved/analytic/logpdf scalar | 0 allocs: 0 B |
| Convolved/analytic/mean | 0 allocs: 0 B |
| Convolved/analytic/pdf batched | 2 allocs: 0.906 kB |
| Convolved/analytic/pdf scalar | 0 allocs: 0 B |
| Convolved/analytic/rand | 2 allocs: 0.906 kB |
| Convolved/numeric/cdf batched | 6 allocs: 2.72 kB |
| Convolved/numeric/cdf scalar | 0 allocs: 0 B |
| Convolved/numeric/construction | 0 allocs: 0 B |
| Convolved/numeric/logpdf batched | 8 allocs: 3.62 kB |
| Convolved/numeric/logpdf broadcast | 2 allocs: 0.906 kB |
| Convolved/numeric/logpdf scalar | 0 allocs: 0 B |
| Convolved/numeric/mean | 0 allocs: 0 B |
| Convolved/numeric/pdf batched | 6 allocs: 2.72 kB |
| Convolved/numeric/pdf scalar | 0 allocs: 0 B |
| Convolved/numeric/rand | 2 allocs: 0.906 kB |
| Difference/analytic/cdf broadcast | 2 allocs: 0.906 kB |
| Difference/analytic/cdf scalar | 0 allocs: 0 B |
| Difference/analytic/construction | 0 allocs: 0 B |
| Difference/analytic/logpdf broadcast | 2 allocs: 0.906 kB |
| Difference/analytic/logpdf scalar | 0 allocs: 0 B |
| Difference/analytic/mean | 0 allocs: 0 B |
| Difference/analytic/rand | 2 allocs: 0.906 kB |
| Difference/numeric/cdf broadcast | 2 allocs: 0.906 kB |
| Difference/numeric/cdf scalar | 0 allocs: 0 B |
| Difference/numeric/construction | 0 allocs: 0 B |
| Difference/numeric/logpdf broadcast | 2 allocs: 0.906 kB |
| Difference/numeric/logpdf scalar | 0 allocs: 0 B |
| Difference/numeric/mean | 0 allocs: 0 B |
| Difference/numeric/rand | 2 allocs: 0.906 kB |
| Quantile/Convolved analytic/grid | 5.38 k allocs: 0.311 MB |
| Quantile/Convolved analytic/median | 0.247 k allocs: 14.8 kB |
| Quantile/Convolved numeric/median | 0.264 k allocs: 15.6 kB |
| Quantile/Difference numeric/median | 0.227 k allocs: 14 kB |
| Timeseries/Convolved delay | 4 allocs: 0.594 kB |
| Timeseries/Gamma delay | 4 allocs: 0.594 kB |
| time_to_load | 0.149 k allocs: 11.2 kB |
Per-benchmark timelines





