| with_timer | R Documentation |
Wraps a function with CLI-based timing and prints its runtime in seconds. Useful for benchmarking or logging time-consuming tasks.
with_timer(fn, name = "Task")
fn |
A function to be wrapped. |
name |
A short descriptive name of the task (used in log output). |
Requires the tictoc package (CLI messages are emitted via cli).
A function that executes fn(...) and prints timing information (returns invisibly).
slow_fn <- function(n) { Sys.sleep(0.01); n^2 }
timed_fn <- with_timer(slow_fn, name = "Square Task")
timed_fn(5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.