]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.nativemem/src/org/simantics/nativemem/internal/CMemoryInfo.java
Allow tab-separated columnized logging of memory use
[simantics/platform.git] / bundles / org.simantics.nativemem / src / org / simantics / nativemem / internal / CMemoryInfo.java
index aca7fa9e559a655554326665d22ddd90fda0c365..7412a73ffc6b2cb1c1be89567cb27dc9e82aaef4 100644 (file)
@@ -28,12 +28,29 @@ public class CMemoryInfo implements ProcessMemoryInfo {
                 + peakRSS + "]";
     }
 
+    @Override
     public String toHumanReadableString() {
         StringBuilder sb = new StringBuilder();
-        sb.append("Memory Use [Current RSS = ").append(currentRSS)
-        .append(" MB, Peak RSS = ").append(Util.toMb(peakRSS))
-        .append(" MB]");
+        sb.append("RSS ").append(Util.toMb(currentRSS))
+        .append("M / ").append(Util.toMb(peakRSS))
+        .append("M");
         return sb.toString();
     }
 
+    @Override
+    public String headerRow() {
+        return "RSS [MB]\tPeak RSS [MB]";
+    }
+
+    @Override
+    public String dataRow() {
+        return Util.toMb(currentRSS) + "\t" + Util.toMb(peakRSS);
+    }
+
+    public static void main(String[] args) {
+        System.out.println(new CMemoryInfo().toHumanReadableString());
+        System.out.println(new CMemoryInfo().headerRow());
+        System.out.println(new CMemoryInfo().dataRow());
+    }
+
 }
\ No newline at end of file