Skip to content
Snippets Groups Projects
Select Git revision
  • snapshot
  • master default
  • BottleneckTestViaWordCounter-v1.1.2
  • BottleneckTextViaWordCounter-v2.0
  • mad/dynamicThreads
  • mad/AllMonitoring
  • loop_detection
  • mad/pipeChangeMonitoring
  • workstealing
  • DCParadigm
  • dynamicport
  • reduction-variable
  • fast-outputport-iteration
  • v2.1
  • v2.0
  • v1.1.2
  • v1.1.1
  • v1.1
  • v1.0
  • signal-final
  • multiple-ports-final
  • pipeline-with-method-call-final
22 results

PerformanceCheckProfileRepository.java

Blame
  • Forked from TeeTime / TeeTime
    1469 commits behind the upstream repository.
    user avatar
    Christian Wulf authored
    6f9746b8
    History
    PerformanceCheckProfileRepository.java 1.69 KiB
    package util.test;
    
    import java.net.InetAddress;
    import java.net.UnknownHostException;
    import java.util.HashMap;
    import java.util.Map;
    
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
    public class PerformanceCheckProfileRepository {
    
    	private static final Logger LOGGER = LoggerFactory.getLogger(PerformanceCheckProfileRepository.class);
    
    	public static final PerformanceCheckProfileRepository INSTANCE = new PerformanceCheckProfileRepository();
    
    	private final Map<Class<?>, AbstractProfiledPerformanceAssertion> performanceCheckProfiles = new HashMap<Class<?>, AbstractProfiledPerformanceAssertion>();
    	private String currentProfile;
    
    	public PerformanceCheckProfileRepository() {
    		String hostName = getHostName();
    		// this.currentProfile = System.getProperty("TestProfile", "ChwWork");
    		currentProfile = hostName;
    		LOGGER.info("Using test profile '" + this.currentProfile + "'");
    	}
    
    	private String getHostName() {
    		String hostname = "Unknown";
    
    		try
    		{
    			InetAddress addr = InetAddress.getLocalHost();
    			hostname = addr.getHostName();
    		} catch (UnknownHostException ex) {
    			LOGGER.warn("Hostname can not be resolved");
    		}
    
    		return hostname;
    	}
    
    	public void setCurrentProfile(final String currentProfile) {
    		this.currentProfile = currentProfile;
    	}
    
    	public String getCurrentProfile() {
    		return this.currentProfile;
    	}
    
    	public void register(final Class<?> testClass, final AbstractProfiledPerformanceAssertion profile) {
    		if (profile.getCorrespondingPerformanceProfile().equals(this.currentProfile)) {
    			this.performanceCheckProfiles.put(testClass, profile);
    		}
    	}
    
    	public AbstractProfiledPerformanceAssertion get(final Class<?> clazz) {
    		return this.performanceCheckProfiles.get(clazz);
    	}
    }