]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.nativemem/src/org/simantics/nativemem/internal/win/ProcessMemoryCounters.java
Rudimentary Linux and MacOSX support for org.simantics.nativemem
[simantics/platform.git] / bundles / org.simantics.nativemem / src / org / simantics / nativemem / internal / win / ProcessMemoryCounters.java
similarity index 63%
rename from bundles/org.simantics.nativemem/src/org/simantics/nativemem/ProcessMemoryCounters.java
rename to bundles/org.simantics.nativemem/src/org/simantics/nativemem/internal/win/ProcessMemoryCounters.java
index eb60540f6612ce02f6f87120c2037cc5943421ee..9c68a54483a437616562823c89d9b8d88757ebf8 100644 (file)
@@ -1,4 +1,18 @@
-package org.simantics.nativemem;
+/*******************************************************************************
+ * Copyright (c) 2016, 2017 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.nativemem.internal.win;
+
+import org.simantics.nativemem.ProcessMemoryInfo;
+import org.simantics.nativemem.internal.Util;
 
 /**
  * Architecture-independent version of the Windows PsApi PROCESS_MEMORY_COUNTERS
@@ -6,7 +20,7 @@ package org.simantics.nativemem;
  * 
  * @author Tuukka Lehtonen
  */
-public class ProcessMemoryCounters {
+public class ProcessMemoryCounters implements ProcessMemoryInfo {
     public int PageFaultCount;
     public long PeakWorkingSetSize;
     public long WorkingSetSize;
@@ -34,21 +48,17 @@ public class ProcessMemoryCounters {
     public String toHumanReadableString() {
         StringBuilder sb = new StringBuilder();
         sb.append("ProcessMemoryCounters [\n\tPageFaultCount             = ").append(PageFaultCount)
-        .append(",\n\tPeakWorkingSetSize         = ").append(toMb(PeakWorkingSetSize))
-        .append(" MB,\n\tWorkingSetSize             = ").append(toMb(WorkingSetSize))
-        .append(" MB,\n\tQuotaPeakPagedPoolUsage    = ").append(toMb(QuotaPeakPagedPoolUsage))
-        .append(" MB,\n\tQuotaPagedPoolUsage        = ").append(toMb(QuotaPagedPoolUsage))
-        .append(" MB,\n\tQuotaPeakNonPagedPoolUsage = ").append(toMb(QuotaPeakNonPagedPoolUsage))
-        .append(" MB,\n\tQuotaNonPagedPoolUsage     = ").append(toMb(QuotaNonPagedPoolUsage))
-        .append(" MB,\n\tPagefileUsage              = ").append(toMb(PagefileUsage))
-        .append(" MB,\n\tPeakPagefileUsage          = ").append(toMb(PeakPagefileUsage))
-        .append(" MB,\n\tPrivateUsage               = ").append(toMb(PrivateUsage))
+        .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]");
         return sb.toString();
     }
 
-    private double toMb(long bytes) {
-        return (double) bytes / 1048576.0;
-    }
-
 }
\ No newline at end of file