From 6f9746b8aa52038e99a1ebb6f692b7b3f409a952 Mon Sep 17 00:00:00 2001
From: Christian Wulf <chw@informatik.uni-kiel.de>
Date: Sun, 28 Dec 2014 08:08:10 +0100
Subject: [PATCH] added HostName enum

---
 .../PerformanceCheckProfileRepository.java    | 20 +++++++++++++++-
 .../ChwHomeComparisonMethodcallWithPorts.java | 20 +---------------
 .../ComparisonMethodcallWithPorts.java        |  2 +-
 .../java/teetime/examples/HostName.java       | 23 +++++++++++++++++++
 .../experiment01/ChwHomePerformanceCheck.java |  5 ++--
 .../experiment09/ChwHomePerformanceCheck.java |  7 ++++--
 .../experiment10/ChwHomePerformanceCheck.java |  7 ++++--
 .../experiment11/ChwHomePerformanceCheck.java |  5 ++--
 .../experiment14/ChwHomePerformanceCheck.java |  7 ++++--
 .../experiment16/ChwHomePerformanceCheck.java | 18 +++++++++------
 src/test/resources/logback-test.xml           |  4 ++--
 11 files changed, 78 insertions(+), 40 deletions(-)
 create mode 100644 src/performancetest/java/teetime/examples/HostName.java

diff --git a/src/main/java/util/test/PerformanceCheckProfileRepository.java b/src/main/java/util/test/PerformanceCheckProfileRepository.java
index 60358758..3ff5d8ca 100644
--- a/src/main/java/util/test/PerformanceCheckProfileRepository.java
+++ b/src/main/java/util/test/PerformanceCheckProfileRepository.java
@@ -1,5 +1,7 @@
 package util.test;
 
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -16,10 +18,26 @@ public class PerformanceCheckProfileRepository {
 	private String currentProfile;
 
 	public PerformanceCheckProfileRepository() {
-		this.currentProfile = System.getProperty("TestProfile", "ChwWork");
+		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;
 	}
diff --git a/src/performancetest/java/teetime/examples/ChwHomeComparisonMethodcallWithPorts.java b/src/performancetest/java/teetime/examples/ChwHomeComparisonMethodcallWithPorts.java
index 42c17326..77d7dbaa 100644
--- a/src/performancetest/java/teetime/examples/ChwHomeComparisonMethodcallWithPorts.java
+++ b/src/performancetest/java/teetime/examples/ChwHomeComparisonMethodcallWithPorts.java
@@ -13,7 +13,7 @@ public class ChwHomeComparisonMethodcallWithPorts extends AbstractProfiledPerfor
 
 	@Override
 	public String getCorrespondingPerformanceProfile() {
-		return "ChwHome";
+		return HostName.CHW_HOME.toString();
 	}
 
 	@Override
@@ -27,12 +27,6 @@ public class ChwHomeComparisonMethodcallWithPorts extends AbstractProfiledPerfor
 				.get("testWithManyObjects(teetime.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test)");
 		PerformanceResult test15 = performanceResults
 				.get("testWithManyObjects(teetime.examples.experiment15.MethodCallThoughputTimestampAnalysis15Test)");
-		PerformanceResult test16a = performanceResults
-				.get("testWithManyObjectsAnd1Thread(teetime.examples.experiment16.MethodCallThoughputTimestampAnalysis16Test)");
-		PerformanceResult test16b = performanceResults
-				.get("testWithManyObjectsAnd2Threads(teetime.examples.experiment16.MethodCallThoughputTimestampAnalysis16Test)");
-		PerformanceResult test16c = performanceResults
-				.get("testWithManyObjectsAnd4Threads(teetime.examples.experiment16.MethodCallThoughputTimestampAnalysis16Test)");
 		PerformanceResult test19a = performanceResults
 				.get("testWithManyObjectsAnd1Thread(teetime.examples.experiment19.MethodCallThoughputTimestampAnalysis19Test)");
 		PerformanceResult test19b = performanceResults
@@ -72,19 +66,7 @@ public class ChwHomeComparisonMethodcallWithPorts extends AbstractProfiledPerfor
 		assertEquals(40, value15, 4.1); // -28
 		// assertEquals(43, value17, 4.1); // -35
 
-		// below results vary too much, possibly due to the OS' scheduler
-		// assertEquals(RESULT_TESTS_16, (double) test16a.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
-		// assertEquals(RESULT_TESTS_16, (double) test16b.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
-		// assertEquals(RESULT_TESTS_16, (double) test16c.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
-		//
-		// assertEquals(RESULT_TESTS_19, (double) test19a.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
-		// assertEquals(RESULT_TESTS_19, (double) test19b.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
-		// assertEquals(RESULT_TESTS_19, (double) test19c.quantiles.get(0.5) / test1.quantiles.get(0.5), 5.1);
-
 		// check speedup
-		assertEquals(2, (double) test16a.overallDurationInNs / test16b.overallDurationInNs, 0.3);
-		assertEquals(2.5, (double) test16a.overallDurationInNs / test16c.overallDurationInNs, 0.2);
-
 		assertEquals(2, (double) test19a.overallDurationInNs / test19b.overallDurationInNs, 0.3);
 		assertEquals(2.5, (double) test19a.overallDurationInNs / test19c.overallDurationInNs, 0.3);
 	}
diff --git a/src/performancetest/java/teetime/examples/ComparisonMethodcallWithPorts.java b/src/performancetest/java/teetime/examples/ComparisonMethodcallWithPorts.java
index bdfea3be..62694832 100644
--- a/src/performancetest/java/teetime/examples/ComparisonMethodcallWithPorts.java
+++ b/src/performancetest/java/teetime/examples/ComparisonMethodcallWithPorts.java
@@ -32,7 +32,7 @@ public class ComparisonMethodcallWithPorts {
 
 	@BeforeClass
 	public static void beforeClass() {
-		System.setProperty("logback.configurationFile", "src/test/resources/logback.groovy");
+		// System.setProperty("logback.configurationFile", "src/test/resources/logback.groovy");
 		PerformanceCheckProfileRepository.INSTANCE.register(ComparisonMethodcallWithPorts.class, new ChwWorkComparisonMethodcallWithPorts());
 		PerformanceCheckProfileRepository.INSTANCE.register(ComparisonMethodcallWithPorts.class, new ChwHomeComparisonMethodcallWithPorts());
 		PerformanceCheckProfileRepository.INSTANCE.register(ComparisonMethodcallWithPorts.class, new NieWorkComparisonMethodcallWithPorts());
diff --git a/src/performancetest/java/teetime/examples/HostName.java b/src/performancetest/java/teetime/examples/HostName.java
new file mode 100644
index 00000000..b93ae4ec
--- /dev/null
+++ b/src/performancetest/java/teetime/examples/HostName.java
@@ -0,0 +1,23 @@
+package teetime.examples;
+
+public enum HostName {
+
+	CHW_HOME("Nogge-PC"),
+	CHW_WORK("chw-PC"),
+	NIE_WORK("nie-PC");
+
+	private final String hostName;
+
+	HostName(final String hostName) {
+		this.hostName = hostName;
+	}
+
+	public String getHostName() {
+		return hostName;
+	}
+
+	@Override
+	public String toString() {
+		return getHostName();
+	}
+}
diff --git a/src/performancetest/java/teetime/examples/experiment01/ChwHomePerformanceCheck.java b/src/performancetest/java/teetime/examples/experiment01/ChwHomePerformanceCheck.java
index 4d336fd2..d5624898 100644
--- a/src/performancetest/java/teetime/examples/experiment01/ChwHomePerformanceCheck.java
+++ b/src/performancetest/java/teetime/examples/experiment01/ChwHomePerformanceCheck.java
@@ -1,15 +1,16 @@
 package teetime.examples.experiment01;
 
 import static org.junit.Assert.assertEquals;
+import teetime.examples.HostName;
+import util.test.AbstractProfiledPerformanceAssertion;
 import util.test.PerformanceResult;
 import util.test.PerformanceTest;
-import util.test.AbstractProfiledPerformanceAssertion;
 
 class ChwHomePerformanceCheck extends AbstractProfiledPerformanceAssertion {
 
 	@Override
 	public String getCorrespondingPerformanceProfile() {
-		return "ChwHome";
+		return HostName.CHW_HOME.toString();
 	}
 
 	@Override
diff --git a/src/performancetest/java/teetime/examples/experiment09/ChwHomePerformanceCheck.java b/src/performancetest/java/teetime/examples/experiment09/ChwHomePerformanceCheck.java
index a1f37f2c..5c941340 100644
--- a/src/performancetest/java/teetime/examples/experiment09/ChwHomePerformanceCheck.java
+++ b/src/performancetest/java/teetime/examples/experiment09/ChwHomePerformanceCheck.java
@@ -1,12 +1,13 @@
 package teetime.examples.experiment09;
 
 import static org.junit.Assert.assertEquals;
+import teetime.examples.HostName;
 
 class ChwHomePerformanceCheck extends AbstractPerformanceCheck {
 
 	@Override
 	public String getCorrespondingPerformanceProfile() {
-		return "ChwHome";
+		return HostName.CHW_HOME.toString();
 	}
 
 	@Override
@@ -30,6 +31,8 @@ class ChwHomePerformanceCheck extends AbstractPerformanceCheck {
 		// since 04.11.2014 (incl.)
 		// assertEquals(71, medianSpeedup, 2.1); // +33
 		// since 05.12.2014 (incl.)
-		assertEquals(45, medianSpeedup, 2.1); // -26
+		// assertEquals(45, medianSpeedup, 2.1); // -26
+		// since 28.12.2014 (incl.)
+		assertEquals(56, medianSpeedup, 2.1); // +11
 	}
 }
diff --git a/src/performancetest/java/teetime/examples/experiment10/ChwHomePerformanceCheck.java b/src/performancetest/java/teetime/examples/experiment10/ChwHomePerformanceCheck.java
index a2bb94e3..5755e5cf 100644
--- a/src/performancetest/java/teetime/examples/experiment10/ChwHomePerformanceCheck.java
+++ b/src/performancetest/java/teetime/examples/experiment10/ChwHomePerformanceCheck.java
@@ -1,12 +1,13 @@
 package teetime.examples.experiment10;
 
 import static org.junit.Assert.assertEquals;
+import teetime.examples.HostName;
 
 class ChwHomePerformanceCheck extends AbstractPerformanceCheck {
 
 	@Override
 	public String getCorrespondingPerformanceProfile() {
-		return "ChwHome";
+		return HostName.CHW_HOME.toString();
 	}
 
 	@Override
@@ -26,6 +27,8 @@ class ChwHomePerformanceCheck extends AbstractPerformanceCheck {
 		// since 31.08.2014 (incl.)
 		// assertEquals(51, medianSpeedup, 3.2); // +4
 		// since 13.12.2014 (incl.)
-		assertEquals(40, medianSpeedup, 3.2); // -11
+		// assertEquals(40, medianSpeedup, 3.2); // -11
+		// since 28.12.2014 (incl.)
+		assertEquals(24, medianSpeedup, 3.2); // -16
 	}
 }
diff --git a/src/performancetest/java/teetime/examples/experiment11/ChwHomePerformanceCheck.java b/src/performancetest/java/teetime/examples/experiment11/ChwHomePerformanceCheck.java
index 0aa9e619..3cac2161 100644
--- a/src/performancetest/java/teetime/examples/experiment11/ChwHomePerformanceCheck.java
+++ b/src/performancetest/java/teetime/examples/experiment11/ChwHomePerformanceCheck.java
@@ -1,15 +1,16 @@
 package teetime.examples.experiment11;
 
 import static org.junit.Assert.assertEquals;
+import teetime.examples.HostName;
+import util.test.AbstractProfiledPerformanceAssertion;
 import util.test.PerformanceResult;
 import util.test.PerformanceTest;
-import util.test.AbstractProfiledPerformanceAssertion;
 
 class ChwHomePerformanceCheck extends AbstractProfiledPerformanceAssertion {
 
 	@Override
 	public String getCorrespondingPerformanceProfile() {
-		return "ChwHome";
+		return HostName.CHW_HOME.toString();
 	}
 
 	@Override
diff --git a/src/performancetest/java/teetime/examples/experiment14/ChwHomePerformanceCheck.java b/src/performancetest/java/teetime/examples/experiment14/ChwHomePerformanceCheck.java
index bab145f6..4c89ea59 100644
--- a/src/performancetest/java/teetime/examples/experiment14/ChwHomePerformanceCheck.java
+++ b/src/performancetest/java/teetime/examples/experiment14/ChwHomePerformanceCheck.java
@@ -1,12 +1,13 @@
 package teetime.examples.experiment14;
 
 import static org.junit.Assert.assertEquals;
+import teetime.examples.HostName;
 
 class ChwHomePerformanceCheck extends AbstractPerformanceCheck {
 
 	@Override
 	public String getCorrespondingPerformanceProfile() {
-		return "ChwHome";
+		return HostName.CHW_HOME.toString();
 	}
 
 	@Override
@@ -32,6 +33,8 @@ class ChwHomePerformanceCheck extends AbstractPerformanceCheck {
 		// since 05.12.2014 (incl.)
 		// assertEquals(75, medianSpeedup, 2.1); // -9
 		// since 13.12.2014 (incl.)
-		assertEquals(44, medianSpeedup, 2.1); // -31
+		// assertEquals(44, medianSpeedup, 2.1); // -31
+		// since 28.12.2014 (incl.)
+		assertEquals(46, medianSpeedup, 2.1); // +2
 	}
 }
diff --git a/src/performancetest/java/teetime/examples/experiment16/ChwHomePerformanceCheck.java b/src/performancetest/java/teetime/examples/experiment16/ChwHomePerformanceCheck.java
index 11a831ba..57504af5 100644
--- a/src/performancetest/java/teetime/examples/experiment16/ChwHomePerformanceCheck.java
+++ b/src/performancetest/java/teetime/examples/experiment16/ChwHomePerformanceCheck.java
@@ -1,6 +1,7 @@
 package teetime.examples.experiment16;
 
 import static org.junit.Assert.assertEquals;
+import teetime.examples.HostName;
 import util.test.AbstractProfiledPerformanceAssertion;
 import util.test.PerformanceResult;
 import util.test.PerformanceTest;
@@ -9,7 +10,7 @@ class ChwHomePerformanceCheck extends AbstractProfiledPerformanceAssertion {
 
 	@Override
 	public String getCorrespondingPerformanceProfile() {
-		return "ChwHome";
+		return HostName.CHW_HOME.toString();
 	}
 
 	@Override
@@ -21,11 +22,11 @@ class ChwHomePerformanceCheck extends AbstractProfiledPerformanceAssertion {
 		PerformanceResult test16c = PerformanceTest.measurementRepository.performanceResults
 				.get("testWithManyObjectsAnd4Threads(" + MethodCallThoughputTimestampAnalysis16Test.class.getName() + ")");
 		// check speedup
-		double speedupB = (double) test16a.overallDurationInNs / test16b.overallDurationInNs;
-		double speedupC = (double) test16a.overallDurationInNs / test16c.overallDurationInNs;
+		double speedupA2B = (double) test16a.overallDurationInNs / test16b.overallDurationInNs;
+		double speedupB2C = (double) test16b.overallDurationInNs / test16c.overallDurationInNs;
 
-		System.out.println(ChwHomePerformanceCheck.class.getName() + ", speedupB: " + speedupB);
-		System.out.println(ChwHomePerformanceCheck.class.getName() + ", speedupC: " + speedupC);
+		System.out.println(ChwHomePerformanceCheck.class.getName() + ", speedupB: " + speedupA2B);
+		System.out.println(ChwHomePerformanceCheck.class.getName() + ", speedupC: " + speedupB2C);
 
 		// assertEquals(2, speedupB, 0.3);
 		// since 31.08.2014 (incl.)
@@ -33,7 +34,10 @@ class ChwHomePerformanceCheck extends AbstractProfiledPerformanceAssertion {
 		// since 04.11.2014 (incl.)
 		// assertEquals(5, speedupC, 0.4);
 		// since 07.12.2014 (incl.)
-		assertEquals(2, speedupB, 0.4);
-		assertEquals(5, speedupC, 0.4);
+		// assertEquals(2, speedupA2B, 0.4);
+		// assertEquals(5, speedupB2C, 0.4);
+		// since 28.12.2014 (incl.)
+		assertEquals(2, speedupA2B, 0.4);
+		assertEquals(2, speedupB2C, 0.4);
 	}
 }
diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml
index 5f80ba17..8a46d9dc 100644
--- a/src/test/resources/logback-test.xml
+++ b/src/test/resources/logback-test.xml
@@ -20,8 +20,8 @@
 		</encoder>
 	</appender>
 	
-	<logger name="teetime.framework" level="TRACE" />
-	<logger name="teetime.stage" level="TRACE" />
+<!-- 	<logger name="teetime.framework" level="TRACE" /> -->
+<!-- 	<logger name="teetime.stage" level="TRACE" /> -->
 	<logger name="teetime" level="INFO" />
 	<logger name="util" level="INFO" />
 
-- 
GitLab