No fit records how long it took to compile, so a benchmark times a
compile of its own. force = TRUE is what makes the number a compile
rather than a cache hit: under cmdstanr a second call to the same code
reuses the executable in 0.02 s against 4.7 s for a compile (measured
2026-10-05), while rstan recompiles every time (23.3 s).
Arguments
- code
Stan code, as
bmm::stancode()orbrms::make_stancode()returns it.- backend
"cmdstanr"or"rstan".- force
Recompile even when an executable is cached. Leaving it
TRUEis the point;FALSEmeasures a reuse.- ...
Passed to the backend's compiler.
- .compiler
The compiling function, the backend's by default. Tests inject a stand-in so that nothing is compiled.
Examples
if (FALSE) { # \dontrun{
code <- bmm::stancode(formula, data, model, backend = "cmdstanr")
benchmark_compile(code, backend = "cmdstanr")
} # }
