Learn R Programming

R.AlphA.Home (version 2.0.2)

Rtimer: Timer Class for Performance Measurement

Description

Timer Class for Performance Measurement

Timer Class for Performance Measurement

Arguments

Public Methods

new()

Initialize a new Timer instance.

add(...)

Add a timing checkpoint with optional labels.

get(fill = TRUE)

Generate timing results as data.table.

Methods


Method new()

Create a new Timer instance

Usage

Rtimer$new()

Returns

A Rtimer object


Method add()

Add a timestamp

Usage

Rtimer$add(...)

Arguments

...

Optional named labels attached to the timestamp.

Returns

The object itself (invisible) for chaining


Method get()

Return the collected timings as a data.table

Usage

Rtimer$get(fill = TRUE)

Arguments

fill

Logical; if TRUE, fill missing columns when combining entries

Returns

A data.table containing timestamps and time differences

Details

An R6 class for measuring and tracking execution time of code segments. Provides functionality to add timing checkpoints, calculate time differences, and generate summary reports of performance metrics.

Examples

Run this code
if (FALSE) {
tmr <- Rtimer$new()
tmr$add("start")
# some code
tmr$add("end")
result <- tmr$get()
print(result)
}

Run the code above in your browser using DataLab