1 11 12 package org.eclipse.test.internal.performance; 13 14 import java.util.HashSet ; 15 import java.util.Set ; 16 17 import org.eclipse.test.performance.Performance; 18 import org.eclipse.test.performance.PerformanceMeter; 19 20 import junit.framework.TestCase; 21 22 public abstract class PerformanceMeterFactory { 23 24 private static Set fScenarios= new HashSet (); 25 26 public PerformanceMeter createPerformanceMeter(String scenario) { 27 assertUniqueScenario(scenario); 28 return doCreatePerformanceMeter(scenario); 29 } 30 31 public PerformanceMeter createPerformanceMeter(TestCase testCase, String monitorId) { 32 return createPerformanceMeter(Performance.getDefault().getDefaultScenarioId(testCase, monitorId)); 33 } 34 35 public PerformanceMeter createPerformanceMeter(TestCase testCase) { 36 return createPerformanceMeter(Performance.getDefault().getDefaultScenarioId(testCase)); 37 } 38 39 protected abstract PerformanceMeter doCreatePerformanceMeter(String scenario); 40 41 private static void assertUniqueScenario(String scenario) { 42 if (fScenarios.contains(scenario)) 43 throw new IllegalArgumentException (); 44 fScenarios.add(scenario); 45 } 46 } 47 | Popular Tags |