timeR {timeR} | R Documentation |
timeR: A package to make timing codes easier
Description
The timeR package saves your time by timing your code and save recordings to a data frame automatically.So you don't have to do all these steps manually by yourself.
timer is a R6 Class that represent a timer.
Usage
timeR
Format
An object of class R6ClassGenerator
of length 24.
Fields
time
A POSIXct/POSIXlt value of your latest timing.
event
A string of your latest timing.
eventTable
A data frame that stores all timings.
verbose
A printing setting that controls whether to print messages.
Public Methods
initialize(time,event,verbose,eventTable)
Initialize a timer object. You can also use
createTimer()
function to initialize a timer object.start(eventName)
Start timing for a event,
eventName
should be a stringstop(eventName)
Stop timing for a event.
getTimer()
Get a data frame that stores all recordings.You can also use
getTimer()
function to get the data frame.removeEvent(eventName)
Remove an given row in the eventTable.
toggleVerbose()
Toggle between
TRUE
andFALSE
forverbose
getStartTime()
Get start time for a selected event.
getStopTime()
Get stop time for a selected event.
getTimeElapsed()
Get time elapsed for a selected event.
getComment()
Get comment for a selected event.
getEventf()
Get entire row for a selected event.
print()
Custom print method for timer class. However, you don't need to use this function to generate custom printing. Custom printing is triggered by default.
Private Methods
slprint(msg,flag = self$verbose)
A function that controls whether to print extra message.
Examples
timer <- createTimer(precision = "ms")
timer$start("event1")
# put some codes in between
timer$stop("event1")
timer$start("event2")
# put some codes in between
timer$stop("event2",comment = "event 2 completed")
table1 <- getTimer(timer)
timer$toggleVerbose() # set verbose to FALSE as default is TRUE
table1 # print all records in a tibble(data frame)
# get attributes for selected events
timer$getStartTime("event1")
timer$getStopTime("event1")
timer$getTimeElapsed("event1")
timer$getComment("event1")
timer$getEvent("event1")