From 42600b052088cd46aeab87643702402366c75156 Mon Sep 17 00:00:00 2001 From: Datsuk Date: Tue, 13 Aug 2024 10:57:41 +0200 Subject: [PATCH] Added cross-platform compatibility for logger --- .../libs.tech/klayout/tech/lvs/sg13g2_full.lylvs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ihp-sg13g2/libs.tech/klayout/tech/lvs/sg13g2_full.lylvs b/ihp-sg13g2/libs.tech/klayout/tech/lvs/sg13g2_full.lylvs index 60f67aeb..86c89550 100644 --- a/ihp-sg13g2/libs.tech/klayout/tech/lvs/sg13g2_full.lylvs +++ b/ihp-sg13g2/libs.tech/klayout/tech/lvs/sg13g2_full.lylvs @@ -55,9 +55,17 @@ exec_start_time = Time.now logger = Logger.new($stdout) +# Cross-platform memory usage retrieval +def get_memory_usage + if Gem.win_platform? + `tasklist /FI "PID eq #{Process.pid}" /FO LIST`.lines.find { |line| line.include?("Mem Usage") }.strip + else + `ps -o rss= -p #{Process.pid}`.strip + " KB" + end +end + logger.formatter = proc do |_severity, datetime, _progname, msg| - "#{datetime}: Memory Usage (" + `pmap #{Process.pid} | tail -1`[10, 40].strip + ") : #{msg} -" + "#{datetime}: Memory Usage (" + get_memory_usage + ") : #{msg}\n" end #================================================