R/format_microbenchmark_return.R

Defines functions format_microbenchmark_return

Documented in format_microbenchmark_return

#' Function to format a \strong{microbenchmark} return into a tidy tibble. 
#' 
#' @author Stuart K. Grange
#' 
#' @param x A \strong{microbenchmark} object.
#' 
#' @return Tibble. 
#' 
#' @export
format_microbenchmark_return <- function(x) {
  
  # Class check
  stopifnot(inherits(x, "microbenchmark"))
  
  tibble::tibble(
    test = as.character(x$expr),
    seconds = x$time / 1e9
  ) %>% 
    tibble::rowid_to_column("run")
  
}
skgrange/systemr documentation built on April 18, 2024, 2:23 a.m.