Created
April 15, 2025 07:15
-
-
Save wviechtb/ab8fdc2a277155e8824e0127226e702f to your computer and use it in GitHub Desktop.
Test load balancing with mirai cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(parallel) | |
library(mirai) | |
cl <- makeCluster(2, "MIRAI") | |
myfun <- function(id) { | |
if (id == 1) | |
Sys.sleep(10) | |
if (id != 1) | |
Sys.sleep(2) | |
list(id = id, id = Sys.getpid()) | |
} | |
print(system.time(res <- parLapply(cl, 1:4, myfun))) | |
unlist(res) | |
print(system.time(res <- parLapplyLB(cl, 1:4, myfun))) | |
unlist(res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment