-
Notifications
You must be signed in to change notification settings - Fork 25
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
signal_state()
is quite slow
#167
Comments
See also r-lib/rlang#1609 for |
I think I've looked at bench::mark(isatty(stdout()))
#> # A tibble: 1 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 isatty(stdout()) 246ns 328ns 2223575. 0B 0 Created on 2023-07-12 with reprex v2.0.2 |
Oh but the > bench::mark(cli:::rstudio$.internal$get_data())
# A tibble: 1 × 13
expression min median `itr/sec` mem_alloc `gc/sec` n_itr n_gc total_time result
<bch:expr> <bch> <bch:> <dbl> <bch:byt> <dbl> <int> <dbl> <bch:tm> <list>
1 cli:::rstudio$.in… 787µs 809µs 1161. 41.1KB 17.3 538 8 463ms <named list>
# ℹ 3 more variables: memory <list>, time <list>, gc <list> 800us * 100 = 800ms which roughly aligns with my profvis result It looks like most of the time is in the rstudioapi function calls > bench::mark(asNamespace("rstudioapi")$isAvailable())
# A tibble: 1 × 13
expression min median `itr/sec` mem_alloc `gc/sec` n_itr n_gc total_time result memory
<bch:expr> <bch:> <bch:> <dbl> <bch:byt> <dbl> <int> <dbl> <bch:tm> <list> <list>
1 "asNamespac… 1.11µs 1.31µs 700181. 0B 70.0 9999 1 14.3ms <lgl> <Rprofmem>
# ℹ 2 more variables: time <list>, gc <list>
> bench::mark(asNamespace("rstudioapi")$getVersion())
# A tibble: 1 × 13
expression min median `itr/sec` mem_alloc `gc/sec` n_itr n_gc total_time result
<bch:expr> <bch> <bch:> <dbl> <bch:byt> <dbl> <int> <dbl> <bch:tm> <list>
1 "asNamespace(\"rstu… 384µs 403µs 2414. 20.6KB 17.2 1125 8 466ms <pckg_vrs>
# ℹ 3 more variables: memory <list>, time <list>, gc <list>
> bench::mark(asNamespace("rstudioapi")$versionInfo()$mode)
# A tibble: 1 × 13
expression min median `itr/sec` mem_alloc `gc/sec` n_itr n_gc total_time result memory
<bch:expr> <bch> <bch:> <dbl> <bch:byt> <dbl> <int> <dbl> <bch:tm> <list> <list>
1 "asNamespace… 382µs 396µs 2460. 20.6KB 17.2 1147 8 466ms <chr> <Rprofmem>
# ℹ 2 more variables: time <list>, gc <list> CC @gaborcsardi |
Another option is to make |
It looks like rstudioapi's xx <- profvis::profvis(for (i in 1:1000) asNamespace("rstudioapi")$callFun("versionInfo"))
print(xx, aggregate = TRUE) > asNamespace("rstudioapi")$versionInfo()
$citation
To cite RStudio in publications use:
Posit team (2023). RStudio: Integrated Development Environment for R. Posit Software,
PBC, Boston, MA. URL http://www.posit.co/.
A BibTeX entry for LaTeX users is
@Manual{,
title = {RStudio: Integrated Development Environment for R},
author = {{Posit team}},
organization = {Posit Software, PBC},
address = {Boston, MA},
year = {2023},
url = {http://www.posit.co/},
}
$mode
[1] "desktop"
$version
[1] ‘2023.6.0.421’
$long_version
[1] "2023.06.0+421"
$release_name
[1] "Mountain Hydrangea" This is used by cli when getting the version number and the mode One step cli could take is to just make one call to But I think a much better solution would be:
Then have cli switch to using |
I've broken this down to 4 individual fixes
|
@DavisVaughan Why not cache the number of colors, so |
Yea I quickly mentioned that here #167 (comment). I do think that would be a good quick solution It won't be dynamic to any options like |
I an not sure what you mean. |
i.e. here is what happens today without caching, which would no longer be true with caching > rlang:::has_ansi()
[1] TRUE
> options(crayon.enabled = F)
> rlang:::has_ansi()
[1] FALSE I just don't know how important that is for the places |
You would cache in the function that make a lot of calls downstream. E.g. if one function calls cli many times then there. If another function calls the first function many times, then there. If there is such a function, and this is not about speeding up a single call... |
I think we can get a big improvement here from switching from |
As it is used for superseded functions this isn't very nice.
E.g. this made
dplyr::recode()
so much slower than before.The text was updated successfully, but these errors were encountered: