]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.nativemem/src/org/simantics/nativemem/internal/win/ProcessMemoryCounters.java
Allow tab-separated columnized logging of memory use
[simantics/platform.git] / bundles / org.simantics.nativemem / src / org / simantics / nativemem / internal / win / ProcessMemoryCounters.java
index 9c68a54483a437616562823c89d9b8d88757ebf8..9f9129aabd671be3418884b2f61316f81f6d1552 100644 (file)
@@ -45,20 +45,40 @@ public class ProcessMemoryCounters implements ProcessMemoryInfo {
                 + PeakPagefileUsage + ", PrivateUsage=" + PrivateUsage + "]";
     }
 
+    @Override
     public String toHumanReadableString() {
         StringBuilder sb = new StringBuilder();
-        sb.append("ProcessMemoryCounters [\n\tPageFaultCount             = ").append(PageFaultCount)
-        .append(",\n\tPeakWorkingSetSize         = ").append(Util.toMb(PeakWorkingSetSize))
-        .append(" MB,\n\tWorkingSetSize             = ").append(Util.toMb(WorkingSetSize))
-        .append(" MB,\n\tQuotaPeakPagedPoolUsage    = ").append(Util.toMb(QuotaPeakPagedPoolUsage))
-        .append(" MB,\n\tQuotaPagedPoolUsage        = ").append(Util.toMb(QuotaPagedPoolUsage))
-        .append(" MB,\n\tQuotaPeakNonPagedPoolUsage = ").append(Util.toMb(QuotaPeakNonPagedPoolUsage))
-        .append(" MB,\n\tQuotaNonPagedPoolUsage     = ").append(Util.toMb(QuotaNonPagedPoolUsage))
-        .append(" MB,\n\tPagefileUsage              = ").append(Util.toMb(PagefileUsage))
-        .append(" MB,\n\tPeakPagefileUsage          = ").append(Util.toMb(PeakPagefileUsage))
-        .append(" MB,\n\tPrivateUsage               = ").append(Util.toMb(PrivateUsage))
-        .append(" MB]");
+        sb.append("RSS                 ").append(Util.toMb(WorkingSetSize))
+        .append("M / ").append(Util.toMb(PeakWorkingSetSize))
+        .append("M").append(Util.NL)
+        .append("Paged/Nonpaged Pool ").append(Util.toKb(QuotaPagedPoolUsage)).append("K / ")
+        .append(Util.toKb(QuotaPeakPagedPoolUsage)).append("K  /  ")
+        .append(Util.toKb(QuotaNonPagedPoolUsage)).append("K / ")
+        .append(Util.toKb(QuotaPeakNonPagedPoolUsage)).append("K").append(Util.NL)
+        .append("Page File           ").append(Util.toMb(PagefileUsage))
+        .append("M / ").append(Util.toMb(PeakPagefileUsage))
+        .append("M (").append(PageFaultCount).append(" faults)");
         return sb.toString();
     }
 
+    @Override
+    public String headerRow() {
+        return "RSS [MB]\tPeak RSS [MB]\tPaged Pool Usage [kB]\tPeak Paged Pool Usage [kB]\tNonpaged Pool Usage [kB]\tPeak Nonpaged Pool Usage [kB]\tPage File Usage [MB]\tPeak Page File Usage [MB]\tPage Faults";
+    }
+
+    @Override
+    public String dataRow() {
+        return Util.toMb(WorkingSetSize) + "\t" + Util.toMb(PeakWorkingSetSize)
+        + "\t" + Util.toKb(QuotaPagedPoolUsage) + "\t" + Util.toKb(QuotaPeakPagedPoolUsage)
+        + "\t" + Util.toKb(QuotaNonPagedPoolUsage) + "\t" + Util.toKb(QuotaPeakNonPagedPoolUsage)
+        + "\t" + Util.toMb(PagefileUsage) + "\t" + Util.toMb(PeakPagefileUsage)
+        + "\t" + PageFaultCount;
+    }
+
+    public static void main(String[] args) {
+        System.out.println(new ProcessMemoryCounters().toHumanReadableString());
+        System.out.println(new ProcessMemoryCounters().headerRow());
+        System.out.println(new ProcessMemoryCounters().dataRow());
+    }
+
 }
\ No newline at end of file