### testpara2.R ## 20141120 Hidetoshi Shimodaira ## R CMD BATCH testpara2.R ## starting up t1=Sys.time() date() (v0=tolower(chartr(".","-",paste(Sys.info()[c("user","nodename")],collapse="-")))) (v1=paste(version$version.string,R.version$platform)) mytimedif = function(tstart,tend) sprintf("%.2f",difftime(tend,tstart,units="secs")) ## loading libraries library(parallel) library(pvclust) # if error, please install.packages("pvclust") data(lung) dim(lung) ## setting up workers (v2=detectCores()) cl <- makeCluster(detectCores()) ## check if pvclust works on the master node lung.pv <- pvclust(lung, nb=10) # quick check, but too small nb ## parallel computing date() t2=Sys.time() lung.pv <- parPvclust(cl, lung, nb=1000) # OK, but nb=10,000 would be better t3=Sys.time() ## plot a figure date() pdf("testpara2.pdf") plot(lung.pv) pvrect(lung.pv) dev.off() ## closing stopCluster(cl) t4=Sys.time() a = paste("# total",mytimedif(t1,t4),"sec, parallel",mytimedif(t2,t3),"sec,",v2,"cores,",v0,date(),"@",v1) cat(a,"\n") cat(a,file=paste("testpara2-",v0,".txt",sep=""),"\n") # quit(save="no")