mb <- function(..., times=25) {
  if(require(microbenchmark, quietly=TRUE)) {
    mb.c <- match.call()
    mb.c[[1]] <- quote(microbenchmark::microbenchmark)
    res <- eval(mb.c, parent.frame())
    res.sum <- summary(res)
    cat(attr(res.sum, "unit"), "\n")
    print(res.sum[1:5])
  } else {
    warning("Package microbenchmark not available.")
  }
}


brodieG/vetr documentation built on Aug. 19, 2018, 12:35 a.m.