I have to find and work out some useful examples of parallel computing in R. What I've actually done, is installing the package and trying out some basic function using 2 or 4 cores of my CPU. I wasn't surprised that e.g. computing sqrt on 5-elements list will not be done faster using parallel, but I thought that things like sorting or just repeating the foreach loop 1000000 times will be the case when parallel can help... But this is what I get:
using 1 core (default)
> c<-sample(1:1000000)
> system.time(sort(c))
user system elapsed
0.21 0.00 0.20
using doParallel package, 1 core (should be the same?!)
> cl<-makeCluster(1)
> registerDoParallel(cl)
> system.time(clusterCall(cl, sort, c))
user system elapsed
0.01 0.06 0.39
using 2 cores
> cl<-makeCluster(2)
> registerDoParallel(cl)
> system.time(clusterCall(cl, sort, c))
user system elapsed
0.03 0.11 0.45
Using 4 cores is even worse. What am I doing wrong? I've searched through internet and it says it should be better, especially because the default sort algorithm is quicksort, which take advantage of parallel computing. Any help?