Closed joethorley closed 3 years ago
Added and much faster than chkr()
but still relative slow
library(chk)
ptm <- proc.time()
for(i in seq_len(1000)) {
chkor(chk_flag(1), chk_flag(TRUE))
}
proc.time() - ptm
#> user system elapsed
#> 7.893 0.237 8.163
ptm <- proc.time()
for(i in seq_len(1000)) {
chk_null_or(TRUE, chk_flag)
}
proc.time() - ptm
#> user system elapsed
#> 0.033 0.000 0.034
ptm <- proc.time()
for(i in seq_len(1000)) {
chk_null_or(TRUE, vld = vld_flag)
}
proc.time() - ptm
#> user system elapsed
#> 0.004 0.000 0.004
ptm <- proc.time()
for(i in seq_len(1000)) {
chkor_vld(vld_flag(1), vld_flag(TRUE))
}
proc.time() - ptm
#> user system elapsed
#> 0.044 0.001 0.045
ptm <- proc.time()
for(i in seq_len(1000)) {
chk_number(1)
chk_flag(TRUE)
}
proc.time() - ptm
#> user system elapsed
#> 0.005 0.000 0.006
Created on 2021-09-02 by the reprex package (v2.0.1)
Documented as follows
#' `chkor_vld()` is relatively slow.
#' If at all possible use [chk_null_or()] or first test using the individual
#' `vld_` functions and then call `chkor_vld()` to generate an informative
#' error message.
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.
chkor_vld(...)
could take series ofvld_
functions and if all false then generateschk_
produce informative error message.Much like
chk_null_or()