looptimer: Loop timer

View source: R/looptimer.R

looptimerR Documentation

Loop timer

Description

For timing loops

Usage

looptimer(
  tim,
  n,
  i,
  when_ready = TRUE,
  memory = 50,
  prefix = "",
  endline = "\n",
  printevery = 1,
  fg = NULL,
  bg = NULL,
  use_msg = TRUE
)

Arguments

tim

Previous instance of timer to be updated

n

total count in the loop

i

iteration that was just finished

when_ready

if true add ETA to message.

memory

How many iteration back remember when computing the average time

prefix

prefix for print message

endline

If print called, which endline character to use? Default '\n'. Usual alternative is something like ' \r'

printevery

Print every nth iteration only. Affects print-method.

fg

Use ANSI color for the print text? Integer from 1 to 256.

bg

Use ANSI color for the print background? Integer from 1 to 256.

use_msg

Use message for printing? Default is TRUE. If not, use cat

Details

Approximative iteration speed, time left, and ETA.

Examples



N <- 100
t0 <- looptimer(n = N, fg = 2, prefix = "[testing]", printevery = 10)
for(i in 1:N){
 # do something
 Sys.sleep(runif(1))
 print(  t0 <- looptimer(t0) )
}



antiphon/looptimer documentation built on Oct. 28, 2023, 9:27 a.m.