Stopwatch: Create a StopwatchRefClass object

View source: R/Stopwatch.R

StopwatchR Documentation

Create a StopwatchRefClass object

Description

Create a StopwatchRefClass object

Usage

Stopwatch(name = "", start_watch = FALSE)

Arguments

name

the name to assign to this object

start_watch

logical, if TRUE then start the Stopwatch

Value

a StopwatchRefClass object

See Also

Other Stopwatch Timekeeper: Timekeeper_elapsed, Timekeeper_has_watch, Timekeeper_reset, Timekeeper_start, Timekeeper_stop, Timekeeper

Examples

## Not run: 
   # create stop watch
   X <- Stopwatch(name = 'timex', start = FALSE)
   #start it
   X$start()
   X$elapsed()
   X
   Sys.sleep(5)
   # When stopping you can name the interval for later retreival
   X$stop(name = 'first')
   X
   X$elapsed(name = "first")
   X$start()
   Sys.sleep(2)
   X$stop(name = "second")
   X$elapsed(name = 'second')
   X$elapsed(name = 'first')
   # now accumulate the elapsed times
   X$elapsed(accumulate = TRUE)
## End(Not run)

BigelowLab/rscripting documentation built on Oct. 24, 2022, 5:31 p.m.