1 11 package org.eclipse.test.internal.performance.eval; 12 13 import java.util.HashSet ; 14 import junit.framework.Assert; 15 16 import org.eclipse.test.internal.performance.InternalPerformanceMeter; 17 import org.eclipse.test.internal.performance.PerformanceTestPlugin; 18 import org.eclipse.test.internal.performance.data.DataPoint; 19 import org.eclipse.test.internal.performance.data.Dim; 20 import org.eclipse.test.internal.performance.data.Sample; 21 import org.eclipse.test.internal.performance.db.DB; 22 import org.eclipse.test.internal.performance.db.Variations; 23 import org.eclipse.test.performance.PerformanceMeter; 24 25 29 public class Evaluator extends EmptyEvaluator { 30 31 private AssertChecker[] fCheckers; 32 33 34 public void setAssertCheckers(AssertChecker[] asserts) { 35 fCheckers= asserts; 36 } 37 38 41 public void evaluate(PerformanceMeter performanceMeter) throws RuntimeException { 42 43 if (fCheckers == null) 44 return; 46 Variations refKeys= PerformanceTestPlugin.getAssertAgainst(); 48 if (refKeys == null) 49 return; 51 if (!(performanceMeter instanceof InternalPerformanceMeter)) 52 return; 54 InternalPerformanceMeter ipm= (InternalPerformanceMeter) performanceMeter; 55 Sample session= ipm.getSample(); 56 Assert.assertTrue("metering session is null", session != null); String scenarioName= session.getScenarioID(); 58 59 HashSet allDimensions= new HashSet (); 61 for (int i= 0; i < fCheckers.length; i++) { 62 AssertChecker chk= fCheckers[i]; 63 Dim[] dims= chk.getDimensions(); 64 for (int j= 0; j < dims.length; j++) 65 allDimensions.add(dims[j]); 66 } 67 68 DataPoint[] sessionDatapoints; 70 Variations config= PerformanceTestPlugin.getVariations(); 71 if (config != null) 72 sessionDatapoints= DB.queryDataPoints(config, scenarioName, allDimensions); 73 else 74 sessionDatapoints= session.getDataPoints(); 75 if (sessionDatapoints == null || sessionDatapoints.length == 0) { 76 PerformanceTestPlugin.logWarning("no session data named '" + config + "' found"); return; 78 } 79 80 DataPoint[] datapoints= DB.queryDataPoints(refKeys, scenarioName, allDimensions); 82 if (datapoints == null || datapoints.length == 0) { 83 PerformanceTestPlugin.logWarning("no reference data named '" + refKeys + "' found"); return; 85 } 86 87 StatisticsSession referenceStats= new StatisticsSession(datapoints); 89 StatisticsSession measuredStats= new StatisticsSession(sessionDatapoints); 90 91 StringBuffer failMesg= new StringBuffer ("Performance criteria not met when compared to '" + refKeys + "':"); boolean pass= true; 93 for (int i= 0; i < fCheckers.length; i++) { 94 AssertChecker chk= fCheckers[i]; 95 pass &= chk.test(referenceStats, measuredStats, failMesg); 96 } 97 98 if (!pass) { 99 if (config != null) 100 DB.markAsFailed(config, session, failMesg.toString()); 101 } 104 } 105 } 106 | Popular Tags |