Given a package name, attempts to time how long it takes to load the package
via library, and then the time for each of the imported packages (see get_imports
).
This should provide some estimate of which package might be making your package take
a while to load.
imported_timings(package, imports = TRUE, suggests = FALSE, n_rep = 5, progress = TRUE)
package | which package to investigate |
---|---|
imports | should the imports be timed too (default = TRUE) |
suggests | should the packages in suggests be added (default = FALSE) |
n_rep | how many times to do it |
progress | should the package be displayed as it's done |
data.frame
For each of the package and it's imported and dependent packages, the
time required to load the package via library()
is recorded in a sub-process
(set using future::plan()
), for the defined number of replicates. Two timings
are recorded, the time to load the package or dependency directly, and then
the time to load the package
after loading the dependency. These are
pkg and after in the returned data.frame.
You can also run library timings for lists of packages directly, which may be more useful to quickly narrow down issues with imported timings. This can be via a character list of packages, or reading from a DESCRIPTION type file.
Note: To time a single package, imports = FALSE
must be used. For timing
multiple packages, imports
will automatically be set to FALSE
.
# NOT RUN { library(importedPackageTimings) library(furrr) plan(multiprocess) # normal running for an installed package devtools_time = imported_timings("devtools") # run the suggested packages too devtools_suggests = imported_timings("devtools", suggests = TRUE) # time particular packages only_devtools = imported_timings("devtools", imports = FALSE) particular_packages = imported_timings(c("cli", "rlang")) # from a dcf file (i.e. package DESCRIPTION file) dcf_timings = imported_timings("path2file") # }