Time operations in a pipeline Measure how long a data operation or function takes within a pipeline (|>). This can be used to check performance of steps in your data workflow.

time_pipe(
  .data,
  label = NULL,
  log_file = NULL,
  console = TRUE,
  time_unit = c("secs", "millisecs", "mins", "hours")
)

Arguments

.data

A data object to pass through the pipeline.

label

Optional. A descriptive name for the operation. If not provided, the expression will be passed.

log_file

Optional. File path to write timing logs. If NULL, messages are only printed to the console.

console

Logical. Whether to print timing messages to the console. Default is TRUE.

time_unit

Character. Unit of time to report. One of "secs", "millisecs", "mins" or "hours".

Value

Returns the result of the pipeline step, unchanged. Timing messages are printed or logged separately.

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
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")
#> [2025-08-15 15:12:27.719] calc 1: 0.5062 secs
#> [2025-08-15 15:12:27.719] total pipeline: 1.0103 secs
#>   x y   z
#> 1 1 2 0.5
#> 2 2 4 1.0
#> 3 3 6 1.5