我正在不同的机器上运行一个R代码集,并希望打印CPU的数量和可用的内存,因为我报告运行程序所需的时间。我希望它能在各种操作系统上运行,我计划根据这些统计数据对代码进行相应的优化(例如,使用doSNOW )。谢谢你的帮忙!
发布于 2014-04-15 16:24:40
library(parallel)
detectCores()
#[1] 24
# for memory in MB's on Windows
memory.limit()
#[1] 98293
# on linux maybe process this info (not sure if there is an R function)
system('cat /proc/meminfo')发布于 2014-04-15 16:47:10
对于核心的数量,您可以在包detectCores()中使用parallel,如前所述。为了避免操作系统问题,您可以使用这样的方法进行欺骗:
if (Sys.info()[1] == "Windows"){
command for windows
} else {
command for linux (or other OS)
}https://stackoverflow.com/questions/23089124
复制相似问题