mclapply用户时间大于经过时间 [英] mclapply user time larger than elapsed time
问题描述
我正在尝试使用R
中parallel
软件包的mclapply
功能.该函数通过计算对数似然距离将值分配给序列矩阵,这是CPU密集型操作.
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.
产生的system.time
值令人困惑:
> system.time(mclapply(worksample,function(x){p_seqi_modj(x,worksample[[1]],c(1:17))}))
user system elapsed
29.339 1.242 18.581
我认为elapsed
表示合计时间(user
+ system
).在这种情况下,以上结果意味着什么?我应该在什么时候定向自己?我无与伦比的版本在user
中花费的时间更少,而在elapsed
中花费的时间更多.
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
.
推荐答案
帮助页面?system.time
表示该函数返回的值是proc_time类的对象,我们应该参考?proc.time
.在那里,我们了解到用户时间是
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
因此您的任务在每个内核上花费了大约15秒(mclapply
默认使用2个内核,请参见mc.cores
参数).
so your task has spent about 15s on each core (mclapply
defaults to using 2 cores, see the mc.cores
argument).
实际上,我们早先在帮助页面中看到proc.time()
返回五个将流程时间和子时间分开的元素,并且打印中使用的summary方法将用户时间和系统时间折叠为流程时间+子时间.还有更多可用信息.
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.
这篇关于mclapply用户时间大于经过时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!