Guide 06 Timed on the machine that builds this page

Performance

Time to compute the price and the implied volatility, and their gradients with respect to all the six inputs with the AD backends the package is tested with (DualNumbers, HyperDualNumbers and TaylorDiff aside): forward mode with ForwardDiff, TaylorSeries (order one TaylorN in the six inputs) and Enzyme (batched, the six tangents in one pass), reverse mode with Zygote, ReverseDiff (compiled tape), Mooncake and Enzyme. Caches, tapes and configurations are prepared once, outside the timings, and every gradient is checked against ForwardDiff. The table is generated when this documentation is built, on the machine that builds it.

BenchmarkToolsgradientscomputed at build time
FunctionValueForwardDiffTaylorSeriesEnzyme forwardZygoteReverseDiffMooncakeEnzyme reverse
blsprice52 ns339 ns (6.5×)5.29 μs (102×)121 ns (2.3×)112 ns (2.1×)156 ns (3.0×)176 ns (3.4×)120 ns (2.3×)
blsimpv242 ns601 ns (2.5×)8.54 μs (35×)354 ns (1.5×)329 ns (1.4×)384 ns (1.6×)408 ns (1.7×)308 ns (1.3×)

Julia 1.13.4, AMD EPYC 7763 64-Core Processor, FinancialToolbox 0.8.3; minimum time over the BenchmarkTools samples, in brackets the ratio to the value.

The gradient of the implied volatility in reverse mode costs about as much as the implied volatility itself: the solver is not differentiated, and the derivatives come from the closed form sensitivities at the solution (see Automatic differentiation).

A broader suite, covering blsprice, blsvega and blsimpv in Float64 and Float32, with DualNumbers and with the gradients of Zygote and Mooncake, is in benchmark and runs on CI; locally:

julia benchmark/run.jl