`getVersion()` is very slow due to `versionInfo()`
Opened this issue · 0 comments
DavisVaughan commented
Investigation of r-lib/lifecycle#167 reveals that getVersion()
is much slower than it needs to be, due to going through versionInfo()
.
The versionInfo()
helper is massively weighed down by having to call readCitationFile()
to fill out the $citation
slot, but you don't need this at all when getting the version in getVersion()
.
It would be much faster to have getVersion()
just call the C++ function that returns the version number.
library(rstudioapi)
bench::mark(
package_version(.Call("rs_rstudioVersion", PACKAGE = "(embedding)")),
getVersion()
)
# A tibble: 2 × 13
expression min median `itr/sec` mem_alloc `gc/sec` n_itr n_gc total_time result
<bch:expr> <bch:t> <bch:t> <dbl> <bch:byt> <dbl> <int> <dbl> <bch:tm> <list>
1 "package_version… 14.5µs 15.3µs 59209. 0B 11.8 9998 2 169ms <pckg_vrs>
2 "getVersion()" 376.5µs 391.1µs 2520. 20.6KB 8.30 1215 4 482ms <pckg_vrs>
# ℹ 3 more variables: memory <list>, time <list>, gc <list>