Skip to content

Instantly share code, notes, and snippets.

@Kumquatum
Created June 18, 2020 15:23
Show Gist options
  • Save Kumquatum/acd6523d082cea05e272640d9ff9d5b4 to your computer and use it in GitHub Desktop.
Save Kumquatum/acd6523d082cea05e272640d9ff9d5b4 to your computer and use it in GitHub Desktop.
# ********************************************************************* #
# Quick script to find which example is the longest to run in a package #
# ********************************************************************* #
library(magrittr)
# Getting function name
functions <- list.files("man") %>%
strsplit(".Rd")
# Timing function exection
times <- lapply(functions, function(func){
time_exe <- suppressWarnings({ # fun
system.time({ example(func, "GWENA",
local = new.env(),
character.only = TRUE,
ask = FALSE,
echo = FALSE)})
})
return(time_exe)
}) %>%
rlist::list.rbind() %>%
set_rownames(unlist(functions)) %>%
as.data.frame() %>%
.[order(.$user.self, decreasing = TRUE),]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment