-
Notifications
You must be signed in to change notification settings - Fork 47
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
Faster alternative to Sys.info() in digest() #137
Comments
Good for the hoops :) I prefer talking before blindly jumping into PR. What you suggest sounds fine. Givem that the platform one runs on rarely changes, we could also check once and only once at load, and the just retrieve a bool from a per-package env. Even cheaper? Worth it? Or not? |
Also, instead of isWindows <- .Platform$OS.type presumably a comparison of that value against a known truth, no? |
Yes. I just fixed the typo. |
I like that idea. The speedup might be small compared to the rest of library(digest)
library(microbenchmark)
env <- new.env(parent = emptyenv())
env$is_windows <- TRUE
microbenchmark(
env = env$is_windows,
cmp = .Platform$OS.type == "windows",
digest = digest(NULL)
)
#> Unit: nanoseconds
#> expr min lq mean median uq max neval
#> env 167 186 335.86 285.0 475.5 1377 100
#> cmp 275 305 578.61 542.0 790.5 4228 100
#> digest 69038 69970 75483.77 70550.5 71198.5 476413 100 Created on 2019-12-03 by the reprex package (v0.3.0) |
Yes. I have been using them for many years too; |
Thanks, Dirk. Since you are willing, I will leave the implementation to you. If you change your mind, please let me know and I will submit a PR. |
I'll put it in a branch and let you review / test. Cool? |
Sounds great. |
cache the 'are we on Windows' test (closes #137)
I develop packages that call
digest()
repeatedly on small data. For use cases like these, the time spent onSys.info()
is often noticeable.Instead of
digest/R/digest.R
Line 41 in fe990a3
would you be open to this?
It looks much faster.
I would have just submitted a PR, but I need to jump through a couple hoops at my company first.
The text was updated successfully, but these errors were encountered: