From a583b83ac27e8fdfa7f9b9ddfad7b8df5f5fe6f7 Mon Sep 17 00:00:00 2001 From: Jamie Lentin Date: Mon, 27 Jul 2026 09:13:26 +0000 Subject: [PATCH] g3_optim: Add wallclock_s to summary Time how long optimisations take, include it in a summary row. --- R/g3_optim.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/g3_optim.R b/R/g3_optim.R index 966c404..f37776d 100644 --- a/R/g3_optim.R +++ b/R/g3_optim.R @@ -99,6 +99,7 @@ g3_optim <- function(model, ## Run optimiser if (print_status) echo_message('## Running optimisation', print_id) + t_start <- proc.time() fit_opt <- try({ optim(par = obj_fun$par, fn = obj_fun$fn, gr = obj_fun$gr, @@ -107,6 +108,7 @@ g3_optim <- function(model, control = control) }, silent = FALSE) + wallclock_s <- (proc.time() - t_start)[["elapsed"]] ## Check whether the optimisation crashed if (inherits(fit_opt, 'try-error')){ @@ -166,6 +168,7 @@ g3_optim <- function(model, convergence = ifelse(model.opt.fail, NA, ifelse(fit_opt$convergence == 0, TRUE, FALSE)), score = fit_opt$value, + wallclock_s = wallclock_s, return_complete = '', comment = '' )