首页 > 其他 > 详细

R的并行运算

时间:2018-07-16 13:21:45      阅读:163      评论:0      收藏:0      [点我收藏+]

 

rm(list=ls())
time1 <- Sys.time()
library(parallel)
#打开四核,具体核数根据机器的核数决定
cl <- makeCluster(getOption(‘cl.cores‘, 1))
#---------------
sumtest <- function(x){
result = x + 1
}
per <- parSapply(cl,c(0:100000),sumtest)

time2 <- Sys.time()
(time.run <- time2 - time1)

注意: 根据计算类型定,不一定开的核数越多运行速度越快,简单的一般是转化为sapply或者是lapply的形式

R的并行运算

原文:https://www.cnblogs.com/lmj-sky/p/9317013.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!