R 并行编程
Nabeel Imam
Data Scientist
在上一层之上建新楼层:串行
在完工结构上装窗户:并行


计算一百万个数的平方根
numbers <- 1:1000000start <- Sys.time() sq_roots <- lapply(numbers, sqrt) end <- Sys.time()end - start
Time difference of 1.044573 secs



并行计算一百万个数的平方根
library(parallel)my_cluster <- makeCluster(3)start <- Sys.time() sq_roots <- parLapply(my_cluster, numbers, sqrt) end <- Sys.time()stopCluster(my_cluster)end - start
Time difference of 0.8416824 secs





对于足够复杂的任务,考虑:
优点
缺点
R 并行编程