Skip to content

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). The batched rows use the vector methods that share quadrature nodes across evaluation points; their gap to the scalar logpdf broadcast row over the same 100 points is the headline number for the numeric backend.

  • Difference: the Z = X - Y dual 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 numeric Convolved delay.

  • Quantile: the Optimization-extension inverse CDF (Nelder-Mead over cdf); the numeric variants pay one quadrature CDF per optimiser iteration and are the slowest rows in the suite.

  • AD gradients: DifferentiationInterface.gradient of every test/ADFixtures scenario 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 forward0.112 ± 0.00057 ms
AD gradients/Convolved Gamma+LogNormal numerical/Enzyme reverse0.151 ± 0.00083 ms
AD gradients/Convolved Gamma+LogNormal numerical/ForwardDiff0.115 ± 0.00026 ms
AD gradients/Convolved Gamma+LogNormal numerical/Mooncake forward0.476 ± 0.0093 ms
AD gradients/Convolved Gamma+LogNormal numerical/Mooncake reverse0.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 forward7.47 ± 0.11 μs
AD gradients/Convolved Gamma+Normal mean+var moments/Enzyme reverse0.0488 ± 0.0083 μs
AD gradients/Convolved Gamma+Normal mean+var moments/ForwardDiff0.62 ± 0.046 μs
AD gradients/Convolved Gamma+Normal mean+var moments/Mooncake forward5.54 ± 0.66 μs
AD gradients/Convolved Gamma+Normal mean+var moments/Mooncake reverse15.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 forward0.113 ± 0.00048 ms
AD gradients/Convolved LogNormal+Gamma numerical/Enzyme reverse0.159 ± 0.001 ms
AD gradients/Convolved LogNormal+Gamma numerical/ForwardDiff0.112 ± 0.00023 ms
AD gradients/Convolved LogNormal+Gamma numerical/Mooncake forward0.504 ± 0.0092 ms
AD gradients/Convolved LogNormal+Gamma numerical/Mooncake reverse0.754 ± 0.019 ms
AD gradients/Convolved LogNormal+Gamma numerical/ReverseDiff (tape)4.21 ± 0.52 ms
AD gradients/Convolved Normal+Normal analytical/Enzyme forward8.17 ± 0.097 μs
AD gradients/Convolved Normal+Normal analytical/Enzyme reverse3.34 ± 0.059 μs
AD gradients/Convolved Normal+Normal analytical/ForwardDiff0.619 ± 0.088 μs
AD gradients/Convolved Normal+Normal analytical/Mooncake forward5.86 ± 0.56 μs
AD gradients/Convolved Normal+Normal analytical/Mooncake reverse30.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 forward0.114 ± 0.001 ms
AD gradients/Difference Gamma-LogNormal numerical wrt X/Enzyme reverse0.153 ± 0.00076 ms
AD gradients/Difference Gamma-LogNormal numerical wrt X/ForwardDiff0.115 ± 0.00023 ms
AD gradients/Difference Gamma-LogNormal numerical wrt X/Mooncake forward0.478 ± 0.0094 ms
AD gradients/Difference Gamma-LogNormal numerical wrt X/Mooncake reverse0.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 forward7.81 ± 0.2 μs
AD gradients/Difference Gamma-Normal mean+var moments/Enzyme reverse0.0484 ± 0.0075 μs
AD gradients/Difference Gamma-Normal mean+var moments/ForwardDiff0.549 ± 0.044 μs
AD gradients/Difference Gamma-Normal mean+var moments/Mooncake forward5.2 ± 0.63 μs
AD gradients/Difference Gamma-Normal mean+var moments/Mooncake reverse5.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 forward0.116 ± 0.00092 ms
AD gradients/Difference LogNormal-Gamma numerical wrt Y/Enzyme reverse0.159 ± 0.0016 ms
AD gradients/Difference LogNormal-Gamma numerical wrt Y/ForwardDiff0.115 ± 0.00029 ms
AD gradients/Difference LogNormal-Gamma numerical wrt Y/Mooncake forward0.521 ± 0.0092 ms
AD gradients/Difference LogNormal-Gamma numerical wrt Y/Mooncake reverse0.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 forward8.11 ± 0.11 μs
AD gradients/Difference Normal-Normal analytical/Enzyme reverse3.22 ± 0.08 μs
AD gradients/Difference Normal-Normal analytical/ForwardDiff0.574 ± 0.089 μs
AD gradients/Difference Normal-Normal analytical/Mooncake forward5.96 ± 0.54 μs
AD gradients/Difference Normal-Normal analytical/Mooncake reverse30.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 forward0.981 ± 0.0016 ms
AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Enzyme reverse1.04 ± 0.0033 ms
AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/ForwardDiff0.783 ± 0.0017 ms
AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Mooncake forward3.76 ± 0.0066 ms
AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Mooncake reverse2.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 forward10.7 ± 0.12 μs
AD gradients/Timeseries convolve Gamma delay/Enzyme reverse14.3 ± 0.17 μs
AD gradients/Timeseries convolve Gamma delay/ForwardDiff3.23 ± 0.04 μs
AD gradients/Timeseries convolve Gamma delay/Mooncake forward12.6 ± 0.45 μs
AD gradients/Timeseries convolve Gamma delay/Mooncake reverse22.6 ± 2.7 μs
AD gradients/Timeseries convolve Gamma delay/ReverseDiff (tape)0.0362 ± 0.0008 ms
Baseline/Gamma/cdf3.56 ± 0.21 μs
Baseline/Gamma/logpdf2.9 ± 0.34 μs
Baseline/Normal/cdf1.5 ± 0.36 μs
Baseline/Normal/logpdf1.05 ± 0.026 μs
Convolved/analytic/cdf batched2.66 ± 0.34 μs
Convolved/analytic/cdf scalar29.2 ± 0.14 ns
Convolved/analytic/construction3.1 ± 0.01 ns
Convolved/analytic/logpdf batched1.08 ± 0.028 μs
Convolved/analytic/logpdf broadcast2.57 ± 0.33 μs
Convolved/analytic/logpdf scalar28.7 ± 0.069 ns
Convolved/analytic/mean3.1 ± 0.01 ns
Convolved/analytic/pdf batched1.12 ± 0.034 μs
Convolved/analytic/pdf scalar31.1 ± 0.18 ns
Convolved/analytic/rand1.13 ± 0.039 μs
Convolved/numeric/cdf batched0.552 ± 0.0091 ms
Convolved/numeric/cdf scalar21.3 ± 0.07 μs
Convolved/numeric/construction3.1 ± 0.01 ns
Convolved/numeric/logpdf batched0.771 ± 0.0026 ms
Convolved/numeric/logpdf broadcast1.63 ± 0.0085 ms
Convolved/numeric/logpdf scalar16.1 ± 0.059 μs
Convolved/numeric/mean6.66 ± 0.011 ns
Convolved/numeric/pdf batched0.771 ± 0.0028 ms
Convolved/numeric/pdf scalar16.1 ± 0.05 μs
Convolved/numeric/rand2.79 ± 0.35 μs
Difference/analytic/cdf broadcast3.38 ± 0.37 μs
Difference/analytic/cdf scalar10.8 ± 0.02 ns
Difference/analytic/construction3.11 ± 0.01 ns
Difference/analytic/logpdf broadcast1.52 ± 0.3 μs
Difference/analytic/logpdf scalar17.1 ± 0.081 ns
Difference/analytic/mean2.79 ± 0.01 ns
Difference/analytic/rand1.13 ± 0.041 μs
Difference/numeric/cdf broadcast1.22 ± 0.0068 ms
Difference/numeric/cdf scalar14.5 ± 0.09 μs
Difference/numeric/construction3.41 ± 0.01 ns
Difference/numeric/logpdf broadcast1.62 ± 0.0087 ms
Difference/numeric/logpdf scalar16.2 ± 0.16 μs
Difference/numeric/mean6.59 ± 0.04 ns
Difference/numeric/rand2.8 ± 0.35 μs
Quantile/Convolved analytic/grid0.567 ± 0.1 ms
Quantile/Convolved analytic/median21.6 ± 0.97 μs
Quantile/Convolved numeric/median0.379 ± 0.01 ms
Quantile/Difference numeric/median0.217 ± 0.0048 ms
Timeseries/Convolved delay0.981 ± 0.0016 ms
Timeseries/Gamma delay1.88 ± 0.032 μs
time_to_load0.848 ± 0.0023 s
a969b15e5a2dd2...
AD gradients/Convolved Gamma+LogNormal numerical/Enzyme forward0.036 k allocs: 1.11 kB
AD gradients/Convolved Gamma+LogNormal numerical/Enzyme reverse14 allocs: 1.86 kB
AD gradients/Convolved Gamma+LogNormal numerical/ForwardDiff7 allocs: 0.266 kB
AD gradients/Convolved Gamma+LogNormal numerical/Mooncake forward0.058 k allocs: 2.91 kB
AD gradients/Convolved Gamma+LogNormal numerical/Mooncake reverse0.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 forward0.032 k allocs: 1.3 kB
AD gradients/Convolved Gamma+Normal mean+var moments/Enzyme reverse2 allocs: 0.0938 kB
AD gradients/Convolved Gamma+Normal mean+var moments/ForwardDiff7 allocs: 0.484 kB
AD gradients/Convolved Gamma+Normal mean+var moments/Mooncake forward0.07 k allocs: 3.33 kB
AD gradients/Convolved Gamma+Normal mean+var moments/Mooncake reverse0.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 forward0.036 k allocs: 1.11 kB
AD gradients/Convolved LogNormal+Gamma numerical/Enzyme reverse14 allocs: 1.86 kB
AD gradients/Convolved LogNormal+Gamma numerical/ForwardDiff7 allocs: 0.266 kB
AD gradients/Convolved LogNormal+Gamma numerical/Mooncake forward0.058 k allocs: 2.91 kB
AD gradients/Convolved LogNormal+Gamma numerical/Mooncake reverse0.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 forward0.036 k allocs: 1.11 kB
AD gradients/Convolved Normal+Normal analytical/Enzyme reverse24 allocs: 1.03 kB
AD gradients/Convolved Normal+Normal analytical/ForwardDiff7 allocs: 0.266 kB
AD gradients/Convolved Normal+Normal analytical/Mooncake forward0.058 k allocs: 2.91 kB
AD gradients/Convolved Normal+Normal analytical/Mooncake reverse0.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 forward0.036 k allocs: 1.11 kB
AD gradients/Difference Gamma-LogNormal numerical wrt X/Enzyme reverse14 allocs: 1.7 kB
AD gradients/Difference Gamma-LogNormal numerical wrt X/ForwardDiff7 allocs: 0.266 kB
AD gradients/Difference Gamma-LogNormal numerical wrt X/Mooncake forward0.058 k allocs: 2.91 kB
AD gradients/Difference Gamma-LogNormal numerical wrt X/Mooncake reverse0.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 forward0.032 k allocs: 1.3 kB
AD gradients/Difference Gamma-Normal mean+var moments/Enzyme reverse2 allocs: 0.0938 kB
AD gradients/Difference Gamma-Normal mean+var moments/ForwardDiff7 allocs: 0.484 kB
AD gradients/Difference Gamma-Normal mean+var moments/Mooncake forward0.07 k allocs: 3.33 kB
AD gradients/Difference Gamma-Normal mean+var moments/Mooncake reverse0.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 forward0.036 k allocs: 1.11 kB
AD gradients/Difference LogNormal-Gamma numerical wrt Y/Enzyme reverse14 allocs: 1.89 kB
AD gradients/Difference LogNormal-Gamma numerical wrt Y/ForwardDiff7 allocs: 0.266 kB
AD gradients/Difference LogNormal-Gamma numerical wrt Y/Mooncake forward0.058 k allocs: 2.91 kB
AD gradients/Difference LogNormal-Gamma numerical wrt Y/Mooncake reverse0.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 forward0.036 k allocs: 1.11 kB
AD gradients/Difference Normal-Normal analytical/Enzyme reverse24 allocs: 1.02 kB
AD gradients/Difference Normal-Normal analytical/ForwardDiff7 allocs: 0.266 kB
AD gradients/Difference Normal-Normal analytical/Mooncake forward0.058 k allocs: 2.91 kB
AD gradients/Difference Normal-Normal analytical/Mooncake reverse0.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 forward0.052 k allocs: 2.39 kB
AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Enzyme reverse0.034 k allocs: 1.72 kB
AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/ForwardDiff0.046 k allocs: 3.08 kB
AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Mooncake forward0.11 k allocs: 5.53 kB
AD gradients/Timeseries convolve Convolved Gamma+LogNormal delay/Mooncake reverse0.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 forward0.04 k allocs: 1.62 kB
AD gradients/Timeseries convolve Gamma delay/Enzyme reverse0.034 k allocs: 1.7 kB
AD gradients/Timeseries convolve Gamma delay/ForwardDiff11 allocs: 0.703 kB
AD gradients/Timeseries convolve Gamma delay/Mooncake forward0.082 k allocs: 4.23 kB
AD gradients/Timeseries convolve Gamma delay/Mooncake reverse0.176 k allocs: 16.6 kB
AD gradients/Timeseries convolve Gamma delay/ReverseDiff (tape)0.449 k allocs: 18 kB
Baseline/Gamma/cdf2 allocs: 0.906 kB
Baseline/Gamma/logpdf2 allocs: 0.906 kB
Baseline/Normal/cdf2 allocs: 0.906 kB
Baseline/Normal/logpdf2 allocs: 0.906 kB
Convolved/analytic/cdf batched2 allocs: 0.906 kB
Convolved/analytic/cdf scalar0 allocs: 0 B
Convolved/analytic/construction0 allocs: 0 B
Convolved/analytic/logpdf batched2 allocs: 0.906 kB
Convolved/analytic/logpdf broadcast2 allocs: 0.906 kB
Convolved/analytic/logpdf scalar0 allocs: 0 B
Convolved/analytic/mean0 allocs: 0 B
Convolved/analytic/pdf batched2 allocs: 0.906 kB
Convolved/analytic/pdf scalar0 allocs: 0 B
Convolved/analytic/rand2 allocs: 0.906 kB
Convolved/numeric/cdf batched6 allocs: 2.72 kB
Convolved/numeric/cdf scalar0 allocs: 0 B
Convolved/numeric/construction0 allocs: 0 B
Convolved/numeric/logpdf batched8 allocs: 3.62 kB
Convolved/numeric/logpdf broadcast2 allocs: 0.906 kB
Convolved/numeric/logpdf scalar0 allocs: 0 B
Convolved/numeric/mean0 allocs: 0 B
Convolved/numeric/pdf batched6 allocs: 2.72 kB
Convolved/numeric/pdf scalar0 allocs: 0 B
Convolved/numeric/rand2 allocs: 0.906 kB
Difference/analytic/cdf broadcast2 allocs: 0.906 kB
Difference/analytic/cdf scalar0 allocs: 0 B
Difference/analytic/construction0 allocs: 0 B
Difference/analytic/logpdf broadcast2 allocs: 0.906 kB
Difference/analytic/logpdf scalar0 allocs: 0 B
Difference/analytic/mean0 allocs: 0 B
Difference/analytic/rand2 allocs: 0.906 kB
Difference/numeric/cdf broadcast2 allocs: 0.906 kB
Difference/numeric/cdf scalar0 allocs: 0 B
Difference/numeric/construction0 allocs: 0 B
Difference/numeric/logpdf broadcast2 allocs: 0.906 kB
Difference/numeric/logpdf scalar0 allocs: 0 B
Difference/numeric/mean0 allocs: 0 B
Difference/numeric/rand2 allocs: 0.906 kB
Quantile/Convolved analytic/grid5.38 k allocs: 0.311 MB
Quantile/Convolved analytic/median0.247 k allocs: 14.8 kB
Quantile/Convolved numeric/median0.264 k allocs: 15.6 kB
Quantile/Difference numeric/median0.227 k allocs: 14 kB
Timeseries/Convolved delay4 allocs: 0.594 kB
Timeseries/Gamma delay4 allocs: 0.594 kB
time_to_load0.149 k allocs: 11.2 kB

Per-benchmark timelines

plot_ConvolvedDistributions_1.pngplot_ConvolvedDistributions_2.pngplot_ConvolvedDistributions_3.pngplot_ConvolvedDistributions_4.pngplot_ConvolvedDistributions_5.pngplot_ConvolvedDistributions_6.png