R Under development (unstable) (2023-12-19 r85710 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > source("incl/start.R") Loading required package: foreach Loading required package: future R Under development (unstable) (2023-12-19 r85710 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows Server 2022 x64 (build 20348) Matrix products: default locale: [1] LC_COLLATE=C LC_CTYPE=German_Germany.utf8 [3] LC_MONETARY=C LC_NUMERIC=C [5] LC_TIME=C time zone: Europe/Berlin tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] doFuture_1.0.1 future_1.33.0 foreach_1.5.2 loaded via a namespace (and not attached): [1] compiler_4.4.0 parallelly_1.36.0 tools_4.4.0 [4] parallel_4.4.0 future.apply_1.11.0 listenv_0.9.0 [7] codetools_0.2-19 iterators_1.0.14 digest_0.6.33 [10] globals_0.16.2 > > strategies <- future:::supportedStrategies() > > message("*** times() ...") *** times() ... > > res0 <- NULL > > for (strategy in strategies) { + message(sprintf("- plan('%s') ...", strategy)) + plan(strategy) + + mu <- 1.0 + sigma <- 2.0 + ## NOTE: Using times() with %dopar% without proper parallel RNG will likely + ## produce unreliable results. Here we don't produce random numbers so it + ## is ok, but it's a toy example because just like base::replicate(), + ## foreach::times() is commonly used for resampling purposes. + res <- times(3L) %dopar% { + dnorm(2L, mean = mu, sd = sigma) + } + print(res) + + if (is.null(res0)) { + res0 <- res + } else { + stopifnot(all.equal(res, res0)) + } + + # Shutdown current plan + plan(sequential) + + message(sprintf("- plan('%s') ... DONE", strategy)) + } ## for (strategy ...) - plan('sequential') ... Warning: executing %dopar% sequentially: no parallel backend registered [1] 0.1760327 0.1760327 0.1760327 - plan('sequential') ... DONE - plan('multisession') ... [1] 0.1760327 0.1760327 0.1760327 - plan('multisession') ... DONE - plan('cluster') ... [1] 0.1760327 0.1760327 0.1760327 - plan('cluster') ... DONE > > message("*** times() ... DONE") *** times() ... DONE > > source("incl/end.R") R Under development (unstable) (2023-12-19 r85710 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows Server 2022 x64 (build 20348) Matrix products: default locale: [1] LC_COLLATE=C LC_CTYPE=German_Germany.utf8 [3] LC_MONETARY=C LC_NUMERIC=C [5] LC_TIME=C time zone: Europe/Berlin tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] doFuture_1.0.1 future_1.33.0 foreach_1.5.2 loaded via a namespace (and not attached): [1] compiler_4.4.0 parallelly_1.36.0 tools_4.4.0 [4] parallel_4.4.0 future.apply_1.11.0 listenv_0.9.0 [7] codetools_0.2-19 iterators_1.0.14 digest_0.6.33 [10] globals_0.16.2 > > proc.time() user system elapsed 0.64 0.15 2.29