| time_pipe | R Documentation |
Records the runtime of a pipeline (|>) from its start to the point where time_pipe() is called.
Prints results to the console and/or logs them in .pipetime_env.
Defaults can be set via options(pipetime.*).
time_pipe(
.data,
label = NULL,
log = getOption("pipetime.log", NULL),
console = getOption("pipetime.console", TRUE),
unit = getOption("pipetime.unit", "secs")
)
.data |
Input object passed through the pipeline. |
label |
Character string. Operation name. Defaults to the expression if |
log |
Character string or |
console |
Logical. Print timing to console? Default: |
unit |
Character string. Time unit for |
time_pipe() measures elapsed time from pipeline start to the call.
If log is set, results are appended to a data frame in .pipetime_env with columns:
timestamp: Pipeline start time (POSIXct)
label: Operation label
duration: Elapsed time since pipeline start (numeric)
unit: Time unit used
Stored logs can be retrieved with get_log().
.data, unchanged. Timing information is printed and/or stored separately.
library(dplyr)
data.frame(x = 1:3) |>
mutate(y = {Sys.sleep(0.5); x*2 }) |>
time_pipe("calc 1") |>
mutate(z = {Sys.sleep(0.5); x/2 }) |>
time_pipe("total pipeline")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.