tests/testthat/helper-parallel.R

with_parallel <- function(code) {
  cores <- as.numeric(Sys.getenv("TEST_CORES"))
  if (is.na(cores)) cores <- 1
  if (require("doParallel", quietly = TRUE) && cores > 1) {
    doParallel::registerDoParallel(cores = cores)
    on.exit(doParallel::stopImplicitCluster())
  }

  code
}

Try the MachineShop package in your browser

Any scripts or data that you put into this service are public.

MachineShop documentation built on Sept. 11, 2024, 6:28 p.m.