[R] Comparing execution times

From: Alaios <alaios_at_yahoo.com>
Date: Mon, 11 Apr 2011 03:29:56 -0700 (PDT)


Dear all,
In my 'simple' computer I was running some experiments to help me understand how faster a multicore lapply will be. I thought it might be interesting for some people to look at the results.

Even though are not accurate, still might be a good indicator how much improvement there can be.

A.Case. The classic: for 1:100
for (i in c(1:dimz)){

    print(sprintf('Creating the %d map',i));     Shadowlist[,,i]<- GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha))   

}

   user system elapsed
1825.699 303.100 1063.352


B.Case. Same as above but with lapply instead of for Shadowlist<-lapply(1:dimz, function(i) {

			      print(sprintf('Creating the %d map',i));
			      GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha))
			    }

) )

user system elapsed
1816.784 296.745 1062.142


C.Case. Foreach is considered to be easier to be applied to manycores.

foreach (i=1:dimz) %do% {

    print(sprintf('Creating the %d map',i));     Shadowlist[,,i]<-f <- GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha))     

}

 user system elapsed
1027.058 13.243 1031.849



D. Case. The really multicore lapply. Great difference

system.time(Shadowlist<-mclapply(1:dimz, function(i) {

+ 			      #print(sprintf('Creating the %d map',i));
+ 			      GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha))
+ 			    }
+ 	    ) 
+ )

   user system elapsed
263.134 99.639 549.366


My computer is a normal four core pc.
Great improvement with mlcapply.



R-help_at_r-project.org mailing list
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. Received on Mon 11 Apr 2011 - 10:34:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 11 Apr 2011 - 17:50:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive