The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

pipetime

R-CMD-check CodeFactor

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.

Installation

Install from GitHub and load alongside dplyr for examples:

# devtools::install_github("CyGei/pipetime")
library(pipetime)
library(dplyr)

Example

Place time_pipe() at the end of a pipeline to measure total elapsed time:

slow_op <- function(delay, x) {
  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.

Logging

📝 Use log to save timings to a hidden environment (.pipetime_env):

df <- data.frame(x = 1:5) |> 
  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

Managing logs

Options

You can also set session‑wide defaults:

options(pipetime.log = "timings",
        pipetime.console = TRUE,
        pipetime.unit = "secs")

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.