⏳ pipetime
measures elapsed time in R pipelines.
Insert time_pipe()
anywhere in a pipeline to print or
log the time since the pipeline started. It works with the native R pipe
(|>
) and fits naturally into tidyverse workflows.
Install from GitHub and load alongside dplyr
for
examples:
# devtools::install_github("CyGei/pipetime")
library(pipetime)
library(dplyr)
Place time_pipe()
at the end of a pipeline to measure
total elapsed time:
<- function(delay, x) {
slow_op Sys.sleep(delay) # Simulate a time-consuming operation
rnorm(n = length(x), mean = x, sd = 1)
}
data.frame(x = 1:3) |>
mutate(sleep = slow_op(0.1, x)) |>
summarise(mean_x = mean(x)) |>
time_pipe("total pipeline") # ~+0.1 sec
#> [2025-09-28 22:40:14.332] total pipeline: +0.1061 secs
#> mean_x
#> 1 2
Use multiple time_pipe()
calls to mark steps along a
pipeline:
data.frame(x = 1:5) |>
mutate(y = slow_op(0.5, x)) |>
time_pipe("compute y") |>
mutate(z = slow_op(0.5, y)) |>
time_pipe("compute z") |>
summarise(mean_z = mean(z)) |>
time_pipe("total pipeline")
#> [2025-09-28 22:40:14.444] compute y: +0.5055 secs
#> [2025-09-28 22:40:14.444] compute z: +1.0114 secs
#> [2025-09-28 22:40:14.444] total pipeline: +1.0122 secs
#> mean_z
#> 1 2.710958
⏱️ Each time_pipe()
reports the cumulative time
since the pipeline started.
📝 Use log
to save timings to a hidden environment
(.pipetime_env
):
<- data.frame(x = 1:5) |>
df mutate(y = slow_op(0.5, x)) |>
time_pipe("compute y", log = "timings") |>
mutate(z = slow_op(0.5, y)) |>
time_pipe("compute z", log = "timings")
#> [2025-09-28 22:40:15.460] compute y: +0.5055 secs
#> [2025-09-28 22:40:15.460] compute z: +1.0116 secs
get_log("timings")
#> timestamp label duration unit
#> 1 2025-09-28 22:40:15 compute y 0.5054879 secs
#> 2 2025-09-28 22:40:15 compute z 1.0115728 secs
rm_log("timings") #delete the dataframe in .pipetime_env
get_log("name")
→ return one log
get_log(NULL)
→ return all logs as a named
list
rm_log("name")
→ remove one log
rm_log(NULL, force = TRUE)
→ remove all
logs
You can also set session‑wide defaults:
options(pipetime.log = "timings",
pipetime.console = TRUE,
pipetime.unit = "secs")