timechecker: An R package to visualize processing time with standard output

Installation

devtools::install_github('YT100100/timechecker')

Usage

This package consists of two functions. set_loop_timechecker function returns a function, which visualizes the progress of iteration process.

iters <- 1:1000
ans <- NULL
tc <- set_loop_timechecker(length(iters))
for (i in iters) {
  ans <- c(ans, i)
  Sys.sleep(0.002)
  tc()
}
Demo movie of set_loop_timechecker function.

set_step_timechecker function also returns a function, which visualizes elapsed time in each processing step. This function is intended to be placed in a function.

f <- function() {

  tc <- set_step_timechecker()

  tc('Simulation')
  df <- data.frame(x = 1:10, y = 1:10 + rnorm(10))
  Sys.sleep(2)

  tc('Data augumentation')
  df$x2 <- df$x ^ 2
  df$x3 <- df$x ^ 3
  Sys.sleep(3)

  tc('Regression')
  lmres <- lm(y ~ ., df)
  Sys.sleep(4)

  tc()
  coef(lmres)

}
ans <- f()
Demo movie of set_step_timechecker function.