Benchmarks
ComposableTuringIDModels tracks the performance of representative modelling operations over time. The suite is a prototype: it covers a small set of representative models rather than exhaustively measuring every component, and the numbers are indicative rather than a guarantee.
Benchmarking reuses the shared tooling in EpiAwarePackageTools.Benchmarks rather than re-implementing a runner or a comparison report. The package owns the suite definition (benchmark/benchmarks.jl); the kit owns running it and turning results into a legible pull-request comment.
What is measured
The suite is a BenchmarkTools.BenchmarkGroup named SUITE, defined in benchmark/benchmarks.jl, with three groups.
Model evaluation — building and evaluating representative models. For each model the suite times a prior draw (
rand, which samples every random variable) and the forward pass (model(), which returns the generated quantities). The models are two latent processes (AR,RandomWalk) and two composedIDModels (DirectInfectionswithPoissonError, andRenewalwithNegativeBinomialError), each turned into a Turing model viaas_turing_model.Sampling — a short NUTS run (50 draws) on a composed
DirectInfections+PoissonErrormodel conditioned on data simulated from its own prior.AD gradients — the gradient of a representative log-density across automatic-differentiation backends (
ForwardDiff,ReverseDiff,Mooncake, andEnzymewhere supported). Results are keyed by scenario and backend so the comparison report folds them into a per-(scenario × backend) matrix.
Running the suite locally
The benchmark/ directory is its own Julia environment. Run the whole suite and save the results with the managed runner, which calls EpiAwarePackageTools.Benchmarks.run_suite:
julia --project=benchmark benchmark/run.jl results.jsonrun_suite uses a short per-benchmark time budget so a full run stays affordable while the minimum-time estimator used in the comparison stays stable. To compare two result files and write a Markdown report, use the managed comparison script, which calls EpiAwarePackageTools.Benchmarks.compare_comment:
julia --project=benchmark benchmark/compare.jl pr.json base.json comment.mdContinuous integration
Two workflows drive benchmarking in CI, both building on the shared kit.
benchmark.yamlruns on pull requests. It benchmarks the pull-request head and the base branch in separate jobs, then posts (and updates) a single comparison comment: a bucketed summary plus collapsed per-benchmark tables split into evaluation and AD-gradient groups.benchmark-history.yamlruns on pushes tomainand on tags. It benchmarks the recent tagged releases plus the current commit with AirspeedVelocity and publishes a timeline to the repository'sbenchmarksbranch. The kit'sasv_comment/flatten_asvhelpers read the same AirspeedVelocity result format when a report is needed.
Performance history
The summary tracks each benchmark suite's headline timing across recent revisions.
Benchmark summary (overall)
| Suite | Median ratio | Trend | Status |
|---|---|---|---|
| AD gradients | 0.98 | ↘ | ok |
| Model evaluation | 0.96 | ↘ | ok |
| Sampling | 1.0 | → | ok |
| time_to_load | 1.01 | → | ok |
Ratio: latest vs oldest shown revision (1.00 = no change, higher = slower/larger). ⚠ reg = at/above the regression threshold.

<details> <summary>Per-suite detail</summary>
Ratio summary
Most recent 3 revisions, columns labelled by commit date.
AD gradients
Time
| Benchmark | v0.1.1 | v0.1.0 | 25e392d4948329... |
|---|---|---|---|
| AR latent logjoint/ForwardDiff | 12.4 ± 17 μs | 12 ± 3.5 μs | 26.8 ± 16 μs |
| AR latent logjoint/Mooncake reverse | 7.29 ± 0.99 μs | 7.19 ± 0.96 μs | 7.17 ± 1 μs |
| AR latent logjoint/ReverseDiff (tape) | 0.04 ± 0.0014 ms | 0.0405 ± 0.0083 ms | 0.0399 ± 0.0013 ms |
| DirectInfections+Poisson posterior/Enzyme reverse | 0.0542 ± 0.00068 ms | 0.0553 ± 0.00075 ms | 0.0541 ± 0.00067 ms |
| DirectInfections+Poisson posterior/ForwardDiff | 0.165 ± 0.018 ms | 0.169 ± 0.011 ms | 0.172 ± 0.02 ms |
| DirectInfections+Poisson posterior/Mooncake reverse | 0.061 ± 0.00099 ms | 0.0631 ± 0.0011 ms | 0.0608 ± 0.00098 ms |
| DirectInfections+Poisson posterior/ReverseDiff (tape) | 0.137 ± 0.018 ms | 0.14 ± 0.02 ms | 0.134 ± 0.016 ms |
Memory
| Benchmark | v0.1.1 | v0.1.0 | 25e392d4948329... |
|---|---|---|---|
| AR latent logjoint/ForwardDiff | 0.056 k allocs: 0.0508 MB | 0.056 k allocs: 0.0508 MB | 0.056 k allocs: 0.0508 MB |
| AR latent logjoint/Mooncake reverse | 0.04 k allocs: 4.98 kB | 0.04 k allocs: 4.98 kB | 0.04 k allocs: 4.98 kB |
| AR latent logjoint/ReverseDiff (tape) | 0.775 k allocs: 0.0319 MB | 0.775 k allocs: 0.0319 MB | 0.775 k allocs: 0.0319 MB |
| DirectInfections+Poisson posterior/Enzyme reverse | 0.242 k allocs: 12.3 kB | 0.242 k allocs: 12.3 kB | 0.242 k allocs: 12.3 kB |
| DirectInfections+Poisson posterior/ForwardDiff | 0.68 k allocs: 0.0835 MB | 0.68 k allocs: 0.0835 MB | 0.68 k allocs: 0.0835 MB |
| DirectInfections+Poisson posterior/Mooncake reverse | 0.32 k allocs: 15.5 kB | 0.32 k allocs: 15.5 kB | 0.32 k allocs: 15.5 kB |
| DirectInfections+Poisson posterior/ReverseDiff (tape) | 1.65 k allocs: 0.0654 MB | 1.65 k allocs: 0.0654 MB | 1.65 k allocs: 0.0654 MB |
Model evaluation
Time
| Benchmark | v0.1.1 | v0.1.0 | 25e392d4948329... |
|---|---|---|---|
| AR latent/forward | 0.529 ± 0.076 μs | 0.517 ± 0.058 μs | 0.508 ± 0.13 μs |
| AR latent/rand | 0.655 ± 0.98 μs | 0.662 ± 1 μs | 0.674 ± 0.97 μs |
| DirectInfections+Poisson/forward | 0.0519 ± 0.00084 ms | 0.0528 ± 0.00079 ms | 0.0517 ± 0.00084 ms |
| DirectInfections+Poisson/rand | 0.0511 ± 0.00079 ms | 0.0521 ± 0.00079 ms | 0.0509 ± 0.00085 ms |
| RandomWalk latent/forward | 1.02 ± 0.061 μs | 1.02 ± 0.57 μs | 0.999 ± 0.057 μs |
| RandomWalk latent/rand | 1.14 ± 0.74 μs | 1.15 ± 0.76 μs | 1.17 ± 0.73 μs |
| Renewal+NegativeBinomial/forward | 0.0559 ± 0.00097 ms | 0.0572 ± 0.00098 ms | 0.0557 ± 0.0009 ms |
| Renewal+NegativeBinomial/rand | 0.0537 ± 0.0011 ms | 0.0548 ± 0.0011 ms | 0.0538 ± 0.0011 ms |
Memory
| Benchmark | v0.1.1 | v0.1.0 | 25e392d4948329... |
|---|---|---|---|
| AR latent/forward | 20 allocs: 2.41 kB | 20 allocs: 2.41 kB | 20 allocs: 2.41 kB |
| AR latent/rand | 22 allocs: 2.83 kB | 22 allocs: 2.83 kB | 22 allocs: 2.83 kB |
| DirectInfections+Poisson/forward | 0.35 k allocs: 15.8 kB | 0.35 k allocs: 15.8 kB | 0.35 k allocs: 15.8 kB |
| DirectInfections+Poisson/rand | 0.349 k allocs: 15.1 kB | 0.349 k allocs: 15.1 kB | 0.349 k allocs: 15.1 kB |
| RandomWalk latent/forward | 16 allocs: 1.83 kB | 16 allocs: 1.83 kB | 16 allocs: 1.83 kB |
| RandomWalk latent/rand | 15 allocs: 2.05 kB | 15 allocs: 2.05 kB | 15 allocs: 2.05 kB |
| Renewal+NegativeBinomial/forward | 0.57 k allocs: 23.7 kB | 0.57 k allocs: 23.7 kB | 0.57 k allocs: 23.7 kB |
| Renewal+NegativeBinomial/rand | 0.567 k allocs: 23 kB | 0.567 k allocs: 23 kB | 0.567 k allocs: 23 kB |
Sampling
Time
| Benchmark | v0.1.1 | v0.1.0 | 25e392d4948329... |
|---|---|---|---|
| NUTS (DirectInfections+Poisson, 50 draws) | 0.748 ± 0.023 s | 0.758 ± 0.028 s | 0.75 ± 0.014 s |
Memory
| Benchmark | v0.1.1 | v0.1.0 | 25e392d4948329... |
|---|---|---|---|
| NUTS (DirectInfections+Poisson, 50 draws) | 2.99 M allocs: 0.371 GB | 2.99 M allocs: 0.371 GB | 2.99 M allocs: 0.371 GB |
time_to_load
Time
| Benchmark | v0.1.1 | v0.1.0 | 25e392d4948329... |
|---|---|---|---|
| time_to_load | 3.62 ± 0.0065 s | 3.63 ± 0.013 s | 3.66 ± 0.026 s |
Memory
| Benchmark | v0.1.1 | v0.1.0 | 25e392d4948329... |
|---|---|---|---|
| time_to_load | 0.149 k allocs: 11.2 kB | 0.149 k allocs: 11.2 kB | 0.149 k allocs: 11.2 kB |
Per-benchmark timelines
<details> <summary>Show 1 plot</summary>

</details>
</details>