I am trying to use mclapply
function of the parallel
package in R
. The function is assigning the values to sequence matrix by calculating log likelihood distance - a CPU-intensive operation.
The resulting system.time
values are confusing:
> system.time(mclapply(worksample,function(x){p_seqi_modj(x,worksample[[1]],c(1:17))}))
user system elapsed
29.339 1.242 18.581
I thought that elapsed
means aggregated time (user
+system
). What does the above result mean in this case and to what time should I orient myself? My unparallelized version takes less in user
time and much more in elapsed
.
The help page ?system.time
says the value returned by the function is an object of class proc_time, and that we should consult ?proc.time
. There we learn that user time is
cumulative sum of user and system times of any child processes
so your task has spent about 15s on each core (mclapply
defaults to using 2 cores, see the mc.cores
argument).
Actually, we see earlier in the help page that proc.time()
returns five elements that separate the process and child times, and that the summary method used in printing collapses the user and system time into process + child times, so there is a bit more information available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With