Report the run time in seconds. For MCMC additional information is provided about the run times of individual chains and the warmup and sampling phases.

time()

Value

A list with elements

  • total: (scalar) The total run time. For MCMC this may be different than the sum of the chain run times if parallelization was used.

  • chains: (data frame) For MCMC only, timing info for the individual chains. The data frame has columns "chain_id", "warmup", "sampling", and "total".

See also

Examples

# \dontrun{ fit_mcmc <- cmdstanr_example("logistic", method = "sample") fit_mcmc$time()
#> $total #> [1] 0.8284969 #> #> $chains #> chain_id warmup sampling total #> 1 1 0.030 0.099 0.129 #> 2 2 0.023 0.082 0.105 #> 3 3 0.024 0.091 0.115 #> 4 4 0.054 0.165 0.219 #>
fit_mle <- cmdstanr_example("logistic", method = "optimize") fit_mle$time()
#> $total #> [1] 0.125402 #>
fit_vb <- cmdstanr_example("logistic", method = "variational") fit_vb$time()
#> $total #> [1] 0.128371 #>
# }