From b0e39cfab969b755b0ffca8bc8d755a6adebf789 Mon Sep 17 00:00:00 2001 From: Chun-Hui Gao Date: Mon, 3 Jun 2024 14:17:27 +0800 Subject: [PATCH 1/3] Update Optimize_params.R --- R/Optimize_params.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/Optimize_params.R b/R/Optimize_params.R index 2834669..43b58b7 100644 --- a/R/Optimize_params.R +++ b/R/Optimize_params.R @@ -746,7 +746,7 @@ ExperimentsCluster_doe <-function(object, object_mslevel,params, if (.Platform$OS.type == "unix") { memtotal <- ceiling(as.numeric( - system("awk '/MemTotal/ {print $2}' /proc/meminfo", intern = TRUE) + system("sysctl -a | awk '/memsize:/ {print $2}'", intern = TRUE) ) / 1024 / 1024) } if (.Platform$OS.type == "windows") { From f47ef93be49668d3faf62951e67bcedc535cc8ec Mon Sep 17 00:00:00 2001 From: Chun-Hui Gao Date: Tue, 4 Jun 2024 10:08:54 +0800 Subject: [PATCH 2/3] get memsize in macOS --- R/Optimize_params.R | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/R/Optimize_params.R b/R/Optimize_params.R index 43b58b7..e86d973 100644 --- a/R/Optimize_params.R +++ b/R/Optimize_params.R @@ -743,13 +743,23 @@ ExperimentsCluster_doe <-function(object, object_mslevel,params, data.size <- round(as.numeric(object.size(object) / 1024 / 1024), 1) - if (.Platform$OS.type == "unix") { + # detect platform + sysname = Sys.info()[['sysname']] + if (sysname == "Linux") { memtotal <- ceiling(as.numeric( - system("sysctl -a | awk '/memsize:/ {print $2}'", intern = TRUE) + system("cat /proc/meminfo | awk '/MemTotal:/ {print $2}'", intern = TRUE) ) / 1024 / 1024) } - if (.Platform$OS.type == "windows") { + + if (sysname == "Darwin"){ + memtotal <- + ceiling(as.numeric( + system("sysctl hw.memsize | awk '{print $2}'", intern = TRUE) + ) / 1024 / 1024 / 1024) + } + + if (sysname == "Windows") { memtotal <- ceiling(as.numeric(gsub( "\r", "", gsub( From f018c1220e034c46042e2c5dfa6943753ad73833 Mon Sep 17 00:00:00 2001 From: Chun-Hui Gao Date: Tue, 4 Jun 2024 10:14:09 +0800 Subject: [PATCH 3/3] restore original Optimize_params.R --- R/Optimize_params.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/Optimize_params.R b/R/Optimize_params.R index e86d973..a68355b 100644 --- a/R/Optimize_params.R +++ b/R/Optimize_params.R @@ -748,7 +748,7 @@ ExperimentsCluster_doe <-function(object, object_mslevel,params, if (sysname == "Linux") { memtotal <- ceiling(as.numeric( - system("cat /proc/meminfo | awk '/MemTotal:/ {print $2}'", intern = TRUE) + system("awk '/MemTotal/ {print $2}' /proc/meminfo", intern = TRUE) ) / 1024 / 1024) }