Benchmarks
ModifiedDistributions benchmarks each modifier's hot paths so wrapper overhead is visible and regressions are caught on every pull request.
The suite (benchmark/benchmarks.jl) evaluates construction, logpdf, pdf, cdf/ccdf, quantile and rand for every modifier around the same base LogNormal, with the bare base as the shared baseline floor:
Baseline: the bare base LogNormal.Affine: the change-of-variables paths throughY = scale * X + shift.Weighted: thelogpdfweight paths, scalar and the vectorisedProduct{Weighted}form.Transformed:thinandcumulative, whose forward ops are transparent to every distribution method, so these rows should sit on the baseline.Modified: the hazard modification on both analytic links; the identity-linkquantileandrandexercise the monotone-bisection cdf inversion, the one non-closed-form path.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
The summary tracks each benchmark suite's headline timing across recent revisions.
Benchmark summary (overall)
Not enough comparable revisions to compute ratios yet — the summary populates once a second revision is benchmarked.
<details> <summary>Per-suite detail</summary>
Ratio summary
Most recent 1 revision, columns labelled by commit date.
AD gradients
Time
| Benchmark | b105916a72bb9c... |
|---|---|
| Affine LogNormal scale+shift logpdf/Enzyme forward | 8.52 ± 0.11 μs |
| Affine LogNormal scale+shift logpdf/Enzyme reverse | 3.06 ± 0.1 μs |
| Affine LogNormal scale+shift logpdf/ForwardDiff | 0.752 ± 0.094 μs |
| Affine LogNormal scale+shift logpdf/Mooncake forward | 6.84 ± 0.37 μs |
| Affine LogNormal scale+shift logpdf/Mooncake reverse | 18.5 ± 0.91 μs |
| Affine LogNormal scale+shift logpdf/ReverseDiff (tape) | 16.6 ± 0.49 μs |
| Modified LogNormal identity-link logpdf/Enzyme forward | 8.79 ± 0.11 μs |
| Modified LogNormal identity-link logpdf/Enzyme reverse | 5.98 ± 1.1 μs |
| Modified LogNormal identity-link logpdf/ForwardDiff | 0.984 ± 0.023 μs |
| Modified LogNormal identity-link logpdf/Mooncake forward | 8.39 ± 0.19 μs |
| Modified LogNormal identity-link logpdf/Mooncake reverse | 0.0452 ± 0.0057 ms |
| Modified LogNormal identity-link logpdf/ReverseDiff (tape) | 0.0323 ± 0.00063 ms |
| Modified LogNormal log-link logpdf/Enzyme forward | 8.54 ± 0.11 μs |
| Modified LogNormal log-link logpdf/Enzyme reverse | 3.57 ± 0.076 μs |
| Modified LogNormal log-link logpdf/ForwardDiff | 0.907 ± 0.1 μs |
| Modified LogNormal log-link logpdf/Mooncake forward | 7.59 ± 0.19 μs |
| Modified LogNormal log-link logpdf/Mooncake reverse | 0.0416 ± 0.0046 ms |
| Modified LogNormal log-link logpdf/ReverseDiff (tape) | 26.6 ± 0.57 μs |
| Product{Weighted} LogNormal vector logpdf/Enzyme forward | 8.37 ± 0.23 μs |
| Product{Weighted} LogNormal vector logpdf/Enzyme reverse | 1.03 ± 0.28 μs |
| Product{Weighted} LogNormal vector logpdf/ForwardDiff | 0.883 ± 0.062 μs |
| Product{Weighted} LogNormal vector logpdf/Mooncake forward | 7.08 ± 1.1 μs |
| Product{Weighted} LogNormal vector logpdf/Mooncake reverse | 28.1 ± 2.6 μs |
| Product{Weighted} LogNormal vector logpdf/ReverseDiff (tape) | 16.7 ± 0.48 μs |
| Thinned convolved series sum/Enzyme forward | 10.7 ± 0.15 μs |
| Thinned convolved series sum/Enzyme reverse | 14.1 ± 0.21 μs |
| Thinned convolved series sum/ForwardDiff | 3.26 ± 0.046 μs |
| Thinned convolved series sum/Mooncake forward | 12.6 ± 0.49 μs |
| Thinned convolved series sum/Mooncake reverse | 29.9 ± 5.1 μs |
| Thinned convolved series sum/ReverseDiff (tape) | 0.0364 ± 0.00062 ms |
| Transformed cumulative LogNormal logpdf/Enzyme forward | 8.07 ± 0.097 μs |
| Transformed cumulative LogNormal logpdf/Enzyme reverse | 1.98 ± 0.068 μs |
| Transformed cumulative LogNormal logpdf/ForwardDiff | 0.522 ± 0.077 μs |
| Transformed cumulative LogNormal logpdf/Mooncake forward | 5.57 ± 0.47 μs |
| Transformed cumulative LogNormal logpdf/Mooncake reverse | 24.4 ± 6.8 μs |
| Transformed cumulative LogNormal logpdf/ReverseDiff (tape) | 15 ± 0.49 μs |
| Transformed thin LogNormal logpdf/Enzyme forward | 8.11 ± 0.087 μs |
| Transformed thin LogNormal logpdf/Enzyme reverse | 1.99 ± 0.048 μs |
| Transformed thin LogNormal logpdf/ForwardDiff | 0.519 ± 0.078 μs |
| Transformed thin LogNormal logpdf/Mooncake forward | 5.58 ± 0.36 μs |
| Transformed thin LogNormal logpdf/Mooncake reverse | 24.8 ± 7.1 μs |
| Transformed thin LogNormal logpdf/ReverseDiff (tape) | 14.8 ± 0.45 μs |
| Weighted Affine LogNormal nested logpdf/Enzyme forward | 8.3 ± 0.12 μs |
| Weighted Affine LogNormal nested logpdf/Enzyme reverse | 0.96 ± 0.076 μs |
| Weighted Affine LogNormal nested logpdf/ForwardDiff | 0.771 ± 0.09 μs |
| Weighted Affine LogNormal nested logpdf/Mooncake forward | 7.27 ± 0.17 μs |
| Weighted Affine LogNormal nested logpdf/Mooncake reverse | 19.7 ± 1.9 μs |
| Weighted Affine LogNormal nested logpdf/ReverseDiff (tape) | 18.3 ± 0.48 μs |
| Weighted LogNormal observation-time weight logpdf/Enzyme forward | 8.02 ± 0.075 μs |
| Weighted LogNormal observation-time weight logpdf/Enzyme reverse | 1.28 ± 0.32 μs |
| Weighted LogNormal observation-time weight logpdf/ForwardDiff | 0.555 ± 0.074 μs |
| Weighted LogNormal observation-time weight logpdf/Mooncake forward | 6.08 ± 1 μs |
| Weighted LogNormal observation-time weight logpdf/Mooncake reverse | 29.9 ± 3.2 μs |
| Weighted LogNormal observation-time weight logpdf/ReverseDiff (tape) | 17.3 ± 0.52 μs |
| Weighted LogNormal scalar logpdf/Enzyme forward | 8.05 ± 0.075 μs |
| Weighted LogNormal scalar logpdf/Enzyme reverse | 1.28 ± 0.34 μs |
| Weighted LogNormal scalar logpdf/ForwardDiff | 0.547 ± 0.074 μs |
| Weighted LogNormal scalar logpdf/Mooncake forward | 6.04 ± 0.89 μs |
| Weighted LogNormal scalar logpdf/Mooncake reverse | 0.037 ± 0.0034 ms |
| Weighted LogNormal scalar logpdf/ReverseDiff (tape) | 17.3 ± 0.47 μs |
| Weighted Sequential observed-total logpdf/Enzyme forward | 0.115 ± 0.003 ms |
| Weighted Sequential observed-total logpdf/Enzyme reverse | 0.358 ± 0.029 ms |
| Weighted Sequential observed-total logpdf/ForwardDiff | 0.0839 ± 0.001 ms |
| Weighted Sequential observed-total logpdf/Mooncake forward | 0.414 ± 0.024 ms |
| Weighted Sequential observed-total logpdf/Mooncake reverse | 1.34 ± 0.1 ms |
| Weighted Sequential observed-total logpdf/ReverseDiff (tape) | 2.4 ± 0.32 ms |
Memory
| Benchmark | b105916a72bb9c... |
|---|---|
| Affine LogNormal scale+shift logpdf/Enzyme forward | 0.044 k allocs: 1.52 kB |
| Affine LogNormal scale+shift logpdf/Enzyme reverse | 24 allocs: 0.969 kB |
| Affine LogNormal scale+shift logpdf/ForwardDiff | 7 allocs: 0.484 kB |
| Affine LogNormal scale+shift logpdf/Mooncake forward | 0.07 k allocs: 3.33 kB |
| Affine LogNormal scale+shift logpdf/Mooncake reverse | 0.292 k allocs: 13.5 kB |
| Affine LogNormal scale+shift logpdf/ReverseDiff (tape) | 0.248 k allocs: 10.6 kB |
| Modified LogNormal identity-link logpdf/Enzyme forward | 0.04 k allocs: 1.25 kB |
| Modified LogNormal identity-link logpdf/Enzyme reverse | 28 allocs: 3.41 kB |
| Modified LogNormal identity-link logpdf/ForwardDiff | 7 allocs: 0.359 kB |
| Modified LogNormal identity-link logpdf/Mooncake forward | 0.064 k allocs: 3.06 kB |
| Modified LogNormal identity-link logpdf/Mooncake reverse | 0.485 k allocs: 0.0416 MB |
| Modified LogNormal identity-link logpdf/ReverseDiff (tape) | 0.465 k allocs: 17.8 kB |
| Modified LogNormal log-link logpdf/Enzyme forward | 0.04 k allocs: 1.25 kB |
| Modified LogNormal log-link logpdf/Enzyme reverse | 24 allocs: 0.969 kB |
| Modified LogNormal log-link logpdf/ForwardDiff | 7 allocs: 0.359 kB |
| Modified LogNormal log-link logpdf/Mooncake forward | 0.064 k allocs: 3.06 kB |
| Modified LogNormal log-link logpdf/Mooncake reverse | 0.439 k allocs: 0.039 MB |
| Modified LogNormal log-link logpdf/ReverseDiff (tape) | 0.377 k allocs: 14.9 kB |
| Product{Weighted} LogNormal vector logpdf/Enzyme forward | 0.053 k allocs: 2.31 kB |
| Product{Weighted} LogNormal vector logpdf/Enzyme reverse | 16 allocs: 0.922 kB |
| Product{Weighted} LogNormal vector logpdf/ForwardDiff | 15 allocs: 1.06 kB |
| Product{Weighted} LogNormal vector logpdf/Mooncake forward | 0.116 k allocs: 6.31 kB |
| Product{Weighted} LogNormal vector logpdf/Mooncake reverse | 0.372 k allocs: 23.5 kB |
| Product{Weighted} LogNormal vector logpdf/ReverseDiff (tape) | 0.239 k allocs: 10 kB |
| Thinned convolved series sum/Enzyme forward | 0.043 k allocs: 1.86 kB |
| Thinned convolved series sum/Enzyme reverse | 0.036 k allocs: 1.86 kB |
| Thinned convolved series sum/ForwardDiff | 13 allocs: 0.922 kB |
| Thinned convolved series sum/Mooncake forward | 0.094 k allocs: 4.89 kB |
| Thinned convolved series sum/Mooncake reverse | 0.263 k allocs: 21.5 kB |
| Thinned convolved series sum/ReverseDiff (tape) | 0.486 k allocs: 19.4 kB |
| Transformed cumulative LogNormal logpdf/Enzyme forward | 0.036 k allocs: 1.11 kB |
| Transformed cumulative LogNormal logpdf/Enzyme reverse | 14 allocs: 0.609 kB |
| Transformed cumulative LogNormal logpdf/ForwardDiff | 7 allocs: 0.266 kB |
| Transformed cumulative LogNormal logpdf/Mooncake forward | 0.058 k allocs: 2.91 kB |
| Transformed cumulative LogNormal logpdf/Mooncake reverse | 0.274 k allocs: 25.6 kB |
| Transformed cumulative LogNormal logpdf/ReverseDiff (tape) | 0.213 k allocs: 9.06 kB |
| Transformed thin LogNormal logpdf/Enzyme forward | 0.036 k allocs: 1.11 kB |
| Transformed thin LogNormal logpdf/Enzyme reverse | 14 allocs: 0.609 kB |
| Transformed thin LogNormal logpdf/ForwardDiff | 7 allocs: 0.266 kB |
| Transformed thin LogNormal logpdf/Mooncake forward | 0.058 k allocs: 2.91 kB |
| Transformed thin LogNormal logpdf/Mooncake reverse | 0.274 k allocs: 25.6 kB |
| Transformed thin LogNormal logpdf/ReverseDiff (tape) | 0.213 k allocs: 9.06 kB |
| Weighted Affine LogNormal nested logpdf/Enzyme forward | 0.036 k allocs: 1.38 kB |
| Weighted Affine LogNormal nested logpdf/Enzyme reverse | 6 allocs: 0.484 kB |
| Weighted Affine LogNormal nested logpdf/ForwardDiff | 7 allocs: 0.516 kB |
| Weighted Affine LogNormal nested logpdf/Mooncake forward | 0.08 k allocs: 4.02 kB |
| Weighted Affine LogNormal nested logpdf/Mooncake reverse | 0.329 k allocs: 15.6 kB |
| Weighted Affine LogNormal nested logpdf/ReverseDiff (tape) | 0.269 k allocs: 11.3 kB |
| Weighted LogNormal observation-time weight logpdf/Enzyme forward | 0.032 k allocs: 1.05 kB |
| Weighted LogNormal observation-time weight logpdf/Enzyme reverse | 10 allocs: 1.14 kB |
| Weighted LogNormal observation-time weight logpdf/ForwardDiff | 7 allocs: 0.297 kB |
| Weighted LogNormal observation-time weight logpdf/Mooncake forward | 0.068 k allocs: 3.59 kB |
| Weighted LogNormal observation-time weight logpdf/Mooncake reverse | 0.32 k allocs: 0.0353 MB |
| Weighted LogNormal observation-time weight logpdf/ReverseDiff (tape) | 0.239 k allocs: 9.97 kB |
| Weighted LogNormal scalar logpdf/Enzyme forward | 0.032 k allocs: 1.05 kB |
| Weighted LogNormal scalar logpdf/Enzyme reverse | 10 allocs: 1.14 kB |
| Weighted LogNormal scalar logpdf/ForwardDiff | 7 allocs: 0.297 kB |
| Weighted LogNormal scalar logpdf/Mooncake forward | 0.068 k allocs: 3.59 kB |
| Weighted LogNormal scalar logpdf/Mooncake reverse | 0.348 k allocs: 0.0453 MB |
| Weighted LogNormal scalar logpdf/ReverseDiff (tape) | 0.239 k allocs: 9.97 kB |
| Weighted Sequential observed-total logpdf/Enzyme forward | 0.668 k allocs: 26 kB |
| Weighted Sequential observed-total logpdf/Enzyme reverse | 2.03 k allocs: 0.0977 MB |
| Weighted Sequential observed-total logpdf/ForwardDiff | 0.198 k allocs: 10.1 kB |
| Weighted Sequential observed-total logpdf/Mooncake forward | 1.65 k allocs: 0.0702 MB |
| Weighted Sequential observed-total logpdf/Mooncake reverse | 8.5 k allocs: 0.854 MB |
| Weighted Sequential observed-total logpdf/ReverseDiff (tape) | 31.3 k allocs: 1.29 MB |
Affine
Time
| Benchmark | b105916a72bb9c... |
|---|---|
| LogNormal/ccdf | 3.3 ± 0.39 μs |
| LogNormal/cdf | 3.4 ± 0.35 μs |
| LogNormal/construction | 3.1 ± 0.01 ns |
| LogNormal/logpdf | 2.63 ± 0.35 μs |
| LogNormal/pdf | 3.82 ± 0.37 μs |
| LogNormal/quantile | 0.49 ± 0.019 μs |
| LogNormal/rand | 1.28 ± 0.078 μs |
Memory
| Benchmark | b105916a72bb9c... |
|---|---|
| LogNormal/ccdf | 2 allocs: 0.906 kB |
| LogNormal/cdf | 2 allocs: 0.906 kB |
| LogNormal/construction | 0 allocs: 0 B |
| LogNormal/logpdf | 2 allocs: 0.906 kB |
| LogNormal/pdf | 2 allocs: 0.906 kB |
| LogNormal/quantile | 2 allocs: 0.219 kB |
| LogNormal/rand | 2 allocs: 0.906 kB |
Baseline
Time
| Benchmark | b105916a72bb9c... |
|---|---|
| LogNormal/ccdf | 2.69 ± 0.32 μs |
| LogNormal/cdf | 2.67 ± 0.33 μs |
| LogNormal/construction | 1.55 ± 0.009 ns |
| LogNormal/logpdf | 1.67 ± 0.32 μs |
| LogNormal/pdf | 2.96 ± 0.33 μs |
| LogNormal/quantile | 0.465 ± 0.018 μs |
| LogNormal/rand | 1.04 ± 0.034 μs |
Memory
| Benchmark | b105916a72bb9c... |
|---|---|
| LogNormal/ccdf | 2 allocs: 0.906 kB |
| LogNormal/cdf | 2 allocs: 0.906 kB |
| LogNormal/construction | 0 allocs: 0 B |
| LogNormal/logpdf | 2 allocs: 0.906 kB |
| LogNormal/pdf | 2 allocs: 0.906 kB |
| LogNormal/quantile | 2 allocs: 0.219 kB |
| LogNormal/rand | 2 allocs: 0.906 kB |
Modified
Time
| Benchmark | b105916a72bb9c... |
|---|---|
| IdentityLink/ccdf | 7.53 ± 0.028 μs |
| IdentityLink/cdf | 7.2 ± 0.028 μs |
| IdentityLink/construction | 3.1 ± 0.01 ns |
| IdentityLink/logpdf | 10.5 ± 0.06 μs |
| IdentityLink/pdf | 12.7 ± 0.06 μs |
| IdentityLink/quantile | 0.111 ± 0.0002 ms |
| IdentityLink/rand | 0.58 ± 0.015 ms |
| LogLink/ccdf | 5.8 ± 0.06 μs |
| LogLink/cdf | 6.17 ± 0.048 μs |
| LogLink/construction | 3.1 ± 0.01 ns |
| LogLink/logpdf | 8.02 ± 0.033 μs |
| LogLink/pdf | 9.35 ± 0.05 μs |
| LogLink/quantile | 0.929 ± 0.073 μs |
| LogLink/rand | 5.13 ± 0.14 μs |
Memory
| Benchmark | b105916a72bb9c... |
|---|---|
| IdentityLink/ccdf | 2 allocs: 0.906 kB |
| IdentityLink/cdf | 2 allocs: 0.906 kB |
| IdentityLink/construction | 0 allocs: 0 B |
| IdentityLink/logpdf | 2 allocs: 0.906 kB |
| IdentityLink/pdf | 2 allocs: 0.906 kB |
| IdentityLink/quantile | 2 allocs: 0.219 kB |
| IdentityLink/rand | 2 allocs: 0.906 kB |
| LogLink/ccdf | 2 allocs: 0.906 kB |
| LogLink/cdf | 2 allocs: 0.906 kB |
| LogLink/construction | 0 allocs: 0 B |
| LogLink/logpdf | 2 allocs: 0.906 kB |
| LogLink/pdf | 2 allocs: 0.906 kB |
| LogLink/quantile | 2 allocs: 0.219 kB |
| LogLink/rand | 2 allocs: 0.906 kB |
Transformed
Time
| Benchmark | b105916a72bb9c... |
|---|---|
| cumulative/cdf | 2.66 ± 0.33 μs |
| cumulative/construction | 2.79 ± 0.01 ns |
| cumulative/logpdf | 1.67 ± 0.28 μs |
| cumulative/rand | 1.03 ± 0.033 μs |
| thin/cdf | 2.66 ± 0.35 μs |
| thin/construction | 2.79 ± 0.01 ns |
| thin/logpdf | 1.69 ± 0.3 μs |
| thin/rand | 1.03 ± 0.034 μs |
Memory
| Benchmark | b105916a72bb9c... |
|---|---|
| cumulative/cdf | 2 allocs: 0.906 kB |
| cumulative/construction | 0 allocs: 0 B |
| cumulative/logpdf | 2 allocs: 0.906 kB |
| cumulative/rand | 2 allocs: 0.906 kB |
| thin/cdf | 2 allocs: 0.906 kB |
| thin/construction | 0 allocs: 0 B |
| thin/logpdf | 2 allocs: 0.906 kB |
| thin/rand | 2 allocs: 0.906 kB |
Weighted
Time
| Benchmark | b105916a72bb9c... |
|---|---|
| Product/construction | 0.309 ± 0.23 μs |
| Product/logpdf | 2.99 ± 0.24 μs |
| scalar/construction | 2.79 ± 0.009 ns |
| scalar/logpdf | 1.72 ± 0.31 μs |
Memory
| Benchmark | b105916a72bb9c... |
|---|---|
| Product/construction | 3 allocs: 2.45 kB |
| Product/logpdf | 6 allocs: 2.72 kB |
| scalar/construction | 0 allocs: 0 B |
| scalar/logpdf | 2 allocs: 0.906 kB |
time_to_load
Time
| Benchmark | b105916a72bb9c... |
|---|---|
| time_to_load | 0.766 ± 0.013 s |
Memory
| Benchmark | b105916a72bb9c... |
|---|---|
| time_to_load | 0.149 k allocs: 11.2 kB |
Per-benchmark timelines
<details> <summary>Show 6 plots</summary>






</details>
</details>