Please check this code :

library(parallel)
workerFunc <- function(n) { return(n^2) }
a <- function(){
  CurrentTime <- Sys.time()
  res <- lapply(values, workerFunc)
  TimeTaken <- Sys.time() - CurrentTime
  print(TimeTaken)
}
b <- function(){
  CurrentTime <- Sys.time()
  numWorkers <- detectCores()
  res <- mclapply(values, workerFunc, mc.cores = numWorkers-2)
  TimeTaken <- Sys.time() - CurrentTime
  print(TimeTaken)
}
c <- function(n){
  values <<- 1:n
  print("Evaluating a : ")
  a()
  print("Evaluating b : ")
  b()
}

For large values of n, the code calculates a() but the hangs indefinitely
on reaching b(). How do I correct it ?
I am using Ubuntu 14.04 and core i7 Processor

-- 
*AROONALOK PYNE*

BE Graduate
Department Of Computer Science And Engineering
Jadavpur University, Kolkata-32
India

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to