[R] Set number of threads in demos and tests. (#9591)
- Restrict the number of threads in IO. - Specify the number of threads in demos and tests. - Add helper scripts for checks.
This commit is contained in:
25
R-package/tests/helper_scripts/run-examples.R
Normal file
25
R-package/tests/helper_scripts/run-examples.R
Normal file
@@ -0,0 +1,25 @@
|
||||
## Helper script for running individual examples.
|
||||
library(pkgload)
|
||||
library(xgboost)
|
||||
|
||||
files <- list.files("./man")
|
||||
|
||||
|
||||
run_example_timeit <- function(f) {
|
||||
path <- paste("./man/", f, sep = "")
|
||||
print(paste("Test", f))
|
||||
flush.console()
|
||||
t0 <- proc.time()
|
||||
run_example(path)
|
||||
t1 <- proc.time()
|
||||
list(file = f, time = t1 - t0)
|
||||
}
|
||||
|
||||
timings <- lapply(files, run_example_timeit)
|
||||
|
||||
for (t in timings) {
|
||||
ratio <- t$time[1] / t$time[3]
|
||||
if (!is.na(ratio) && !is.infinite(ratio) && ratio >= 2.5) {
|
||||
print(paste("Offending example:", t$file, ratio))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user