Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getVersion() is very slow due to versionInfo() #279

Closed
DavisVaughan opened this issue Jul 12, 2023 · 1 comment
Closed

getVersion() is very slow due to versionInfo() #279

DavisVaughan opened this issue Jul 12, 2023 · 1 comment

Comments

@DavisVaughan
Copy link

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>
@kevinushey
Copy link
Contributor

Done now; on the way to CRAN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants