This utility wraps a function with CLI-based timing and displays its runtime in seconds. It is especially useful for benchmarking or logging time-consuming tasks.
Examples
slow_fn <- function(n) { Sys.sleep(0.2); n^2 }
timed_fn <- with_timer(slow_fn, name = "Square Task")
timed_fn(5)
#>
#> ── Square Task started at 2025-04-24 11:22:24.291581 ───────────────────────────
#> ✔ Square Task completed in "0.210" seconds