1 11 12 package org.eclipse.test.internal.performance; 13 14 import java.util.ArrayList ; 15 import java.util.HashMap ; 16 import java.util.List ; 17 import org.eclipse.test.internal.performance.data.DataPoint; 18 import org.eclipse.test.internal.performance.data.Sample; 19 20 21 24 public class OSPerformanceMeter extends InternalPerformanceMeter { 25 26 private PerformanceMonitor fPerformanceMonitor; 27 private long fStartTime; 28 private List fDataPoints= new ArrayList (); 29 30 33 public OSPerformanceMeter(String scenarioId) { 34 super(scenarioId); 35 fPerformanceMonitor= PerformanceMonitor.getPerformanceMonitor(); 36 fStartTime= System.currentTimeMillis(); 37 } 38 39 42 public void dispose() { 43 fPerformanceMonitor= null; 44 fDataPoints= null; 45 super.dispose(); 46 } 47 48 51 public void start() { 52 snapshot(BEFORE); 53 } 54 55 58 public void stop() { 59 snapshot(AFTER); 60 } 61 62 65 public Sample getSample() { 66 if (fDataPoints != null) { 67 HashMap runProperties= new HashMap (); 68 collectRunInfo(runProperties); 69 return new Sample(getScenarioName(), fStartTime, runProperties, (DataPoint[]) fDataPoints.toArray(new DataPoint[fDataPoints.size()])); 70 } 71 return null; 72 } 73 74 76 private void snapshot(int step) { 77 HashMap map= new HashMap (); 78 fPerformanceMonitor.collectOperatingSystemCounters(map); 79 fDataPoints.add(new DataPoint(step, map)); 80 } 81 82 86 private void collectRunInfo(HashMap runProperties) { 87 fPerformanceMonitor.collectGlobalPerformanceInfo(runProperties); 88 } 89 } 90 | Popular Tags |