| Type: | Package |
| Title: | Tools to Time Pipe Operations |
| Version: | 0.0.1 |
| Description: | Enable users to measure and record the execution time of pipe operations (using |>) with optional logging to dataframes and output to the console. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Suggests: | testthat (≥ 3.0.0), crayon, dplyr, ggplot2, stringr, tictoc, knitr, rmarkdown |
| Config/testthat/edition: | 3 |
| RoxygenNote: | 7.3.3 |
| URL: | https://cygei.github.io/pipetime/; https://github.com/CyGei/pipetime |
| BugReports: | https://github.com/CyGei/pipetime/issues |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2025-09-29 19:13:44 UTC; cy |
| Author: | Cyril Geismar |
| Maintainer: | Cyril Geismar <c.geismar21@imperial.ac.uk> |
| Depends: | R (≥ 4.1.0) |
| Repository: | CRAN |
| Date/Publication: | 2025-10-08 19:50:14 UTC |
Retrieve a timing log (or all logs)
Description
Return a stored timing log from .pipetime_env.
If log = NULL, return all logs as a named list.
Usage
get_log(log = NULL)
Arguments
log |
Character string or |
Value
Either:
A data frame with columns:
-
timestamp(POSIXct): Pipeline start time -
label(character): Operation label -
duration(numeric): Elapsed time since pipeline start -
unit(character): Time unit used
-
Or, if
log = NULL, a named list of such data frames.
See Also
Remove a timing log (or all logs)
Description
Delete a timing log from .pipetime_env.
If log = NULL, all logs are removed, but only when force = TRUE.
Usage
rm_log(log = NULL, force = FALSE)
Arguments
log |
Character string or |
force |
Logical. To remove all logs, |
Value
Invisibly, TRUE.
See Also
Measure execution time in a pipeline
Description
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.*).
Usage
time_pipe(
.data,
label = NULL,
log = getOption("pipetime.log", NULL),
console = getOption("pipetime.console", TRUE),
unit = getOption("pipetime.unit", "secs")
)
Arguments
.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 |
Details
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().
Value
.data, unchanged. Timing information is printed and/or stored separately.
Examples
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")