1 11 package org.eclipse.test.internal.performance; 12 13 import java.util.Map ; 14 15 import org.eclipse.test.internal.performance.data.Dim; 16 import org.eclipse.test.internal.performance.data.Scalar; 17 18 19 class PerformanceMonitor { 20 21 private static PerformanceMonitor fgPerformanceMonitor; 22 23 public static PerformanceMonitor getPerformanceMonitor() { 24 if (fgPerformanceMonitor == null) { 25 String os= System.getProperty("os.name"); if (os.startsWith("Windows")) fgPerformanceMonitor= new PerformanceMonitorWindows(); 28 else if (os.startsWith("Mac OS X")) fgPerformanceMonitor= new PerformanceMonitorMac(); 30 else 31 fgPerformanceMonitor= new PerformanceMonitorLinux(); 32 } 33 return fgPerformanceMonitor; 34 } 35 36 protected void collectOperatingSystemCounters(Map scalars) { 37 if (PerformanceTestPlugin.isOldDB()) { 38 addScalar(scalars, InternalDimensions.SYSTEM_TIME, System.currentTimeMillis()); 39 } else { 40 Runtime runtime= Runtime.getRuntime(); 41 addScalar(scalars, InternalDimensions.USED_JAVA_HEAP, runtime.totalMemory() - runtime.freeMemory()); 43 } 44 } 45 46 protected void collectGlobalPerformanceInfo(Map scalars) { 47 } 49 50 void addScalar(Map scalars, Dim dimension, long value) { 51 scalars.put(dimension, new Scalar(dimension, value)); 52 } 53 } 54 | Popular Tags |