with_timer: With Timer

View source: R/with-timer.R

with_timerR Documentation

With Timer

Description

With Timer

Usage

with_timer(code, ..., title = FALSE, srcref = FALSE)

Arguments

code

A line or block of R code.

...

These dots are for future extensions and must be empty.

title

A flag specifying whether to add a title based on code.

srcref

A flag specifying whether to print the source reference.

Value

The result of executing the code.

See Also

local_timer()

Examples

fun <- function() {
  Sys.sleep(0.1)
  10
}
with_timer(fun())

with_timer({
  for (i in 1:2) {
    Sys.sleep(0.1)
  }
  20
})

poissonconsulting/hmstimer documentation built on Nov. 20, 2024, 10:02 p.m.