HenrikBengtsson / doFuture

:rocket: R package: doFuture - Use Foreach to Parallelize via Future Framework
https://doFuture.futureverse.org
84 stars 6 forks source link

PERFORMANCE: Disabling RNG validation #64

Closed HenrikBengtsson closed 3 years ago

HenrikBengtsson commented 3 years ago

Instead of:

https://github.com/HenrikBengtsson/doFuture/blob/e701db73afae56496b02c63b1a0cf3bd222bde46/R/doFuture.R#L233-L239

we could use:

  ## Are there RNG-check settings specific for doFuture?
  onMisuse <- getOption("doFuture.rng.onMisuse", NULL)
  if (!is.null(onMisuse)) {
    if (onMisuse == "ignore") {
      seed <- NULL
    } else {
      oldOnMisuse <- getOption("future.rng.onMisuse")
      options(future.rng.onMisuse = onMisuse)
      on.exit(options(future.rng.onMisuse = oldOnMisuse), add = TRUE)
    }
  }

That should be a bit more efficient.