Performance against hand-written loops and gradients
This page compares the run time of the package with hand-written code for the same models, and gives the cost of a gradient relative to a forward run. Every figure is drawn by benchmark/figures.jl from recorded timings when the docs are built, and each states the machine and revision of its timings. Performance over time follows the tracked suite from commit to commit, and the AD comparison times each backend on every scenario of the AD tests.
What is timed
An example is the model of one tutorial or one kernel of a patch model ported from hand-written loops, at the largest size timed for it. The kernels are the examples named "backend", and Porting a patch model from hand-written loops describes three of them. The example "three towns" is the model of Three towns, step by step. Each example is timed by up to four methods:
the package, as a user calls it;
a hand-written loop, a preallocated loop of the same model that the same backend differentiates;
plain AD, the package with its rules turned off by
NoAdjoint, so that the backend differentiates the loop of the operator;hand-written rules, the hand-written loop with reverse rules written for Mooncake, for the examples that have them.
Each method is timed on the forward run and on the gradient by ForwardDiff, Mooncake reverse and Enzyme reverse. The statistic is the minimum time, and each figure gives the time of the package over the time of the other method, so a ratio below 1 means the package is faster.
Timed at revision bbbd9265 on Julia 1.13.4, each process on one thread; processor: Intel(R) Xeon(R) Processor @ 2.30GHz.
Against hand-written loops

Forward run: the package takes 0.79 times the time of the hand-written loop as a geometric mean over 23 examples, from 0.31 to 4.4, and is slower on 4.
ForwardDiff: the package takes 0.81 times the time of the hand-written loop as a geometric mean over 23 examples, from 0.15 to 13, and is slower on 8.
Mooncake reverse: the package takes 0.29 times the time of the hand-written loop as a geometric mean over 23 examples, from 0.081 to 2, and is slower on 1.
Enzyme reverse: the package takes 0.46 times the time of the hand-written loop as a geometric mean over 22 examples, from 0.058 to 6, and is slower on 5.
The forward run and ForwardDiff call no rule, so their ratios compare the loop of the operator with the hand-written loop. On Mooncake reverse and Enzyme reverse the package runs its rules, and the hand-written loop is differentiated by the backend.
Against plain AD
The rules are reverse passes, so only the two reverse backends have a time without them. 
Mooncake reverse: the package takes 0.27 times the time of plain AD as a geometric mean over 23 examples, from 0.098 to 0.7, and is slower on 0.
Enzyme reverse: the package takes 0.39 times the time of plain AD as a geometric mean over 21 examples, from 0.13 to 0.95, and is slower on 0.
Against hand-written rules

Mooncake reverse: the package takes 0.87 times the time of the loop with hand-written rules as a geometric mean over 22 examples, from 0.45 to 3.2, and is slower on 4.
Gradient cost on the tracked suite
The benchmark history workflow times a fixed set of cases on every commit to main: the forward run of each, and its gradient on each backend. The figure gives each gradient time over the time of the forward run of the same case. 
Timed at revision e1f15189 by the benchmark history workflow, on a GitHub-hosted ubuntu-latest runner.
Enzyme reverse: from 2.2 to 6.3 times the forward run, over 14 cases.
ForwardDiff: from 40 to 1000 times the forward run, over 14 cases.
Mooncake reverse: from 3.2 to 19 times the forward run, over 14 cases.
ForwardDiff takes one pass per parameter, and each of these cases has at least one parameter per step.
Reproducing the timings
Each example is a case in test/ADFixtures/src/matrix_cases.jl. task -t benchmark/Taskfile.yml matrix-docs checks every hand-written loop against the package, times the examples and rewrites benchmark/results/docs.csv. julia --project=benchmark benchmark/run.jl runs the tracked suite. benchmark/README.md describes the other tools, among them the interleaved comparison of two revisions with a noise band.