From b278f8335127e4a2afe2575eefb09a79ba147d0c Mon Sep 17 00:00:00 2001 From: Christian Wulf <chw@informatik.uni-kiel.de> Date: Wed, 27 Aug 2014 16:30:41 +0200 Subject: [PATCH] moved logger properties file to the corresponding maven folder; replaced kieker by logback logger in PerformanceTest; added performance check for test 01 --- .classpath | 2 ++ conf/logging.properties | 14 ----------- src/main/java/util/PerformanceTest.java | 10 +++++--- {conf => src/main/resources}/logback.groovy | 0 .../experiment01/ChwHomePerformanceCheck.java | 22 ++++++++++++++++ .../experiment01/ChwWorkPerformanceCheck.java | 22 ++++++++++++++++ ...odCallThoughputTimestampAnalysis1Test.java | 25 +++++++++++++------ .../experiment16/ChwHomePerformanceCheck.java | 10 ++++---- src/test/resources/logback-test.groovy | 22 ++++++++++++++++ 9 files changed, 97 insertions(+), 30 deletions(-) delete mode 100644 conf/logging.properties rename {conf => src/main/resources}/logback.groovy (100%) create mode 100644 src/test/java/teetime/variant/methodcall/examples/experiment01/ChwHomePerformanceCheck.java create mode 100644 src/test/java/teetime/variant/methodcall/examples/experiment01/ChwWorkPerformanceCheck.java create mode 100644 src/test/resources/logback-test.groovy diff --git a/.classpath b/.classpath index 21206d20..eab1b08c 100644 --- a/.classpath +++ b/.classpath @@ -13,6 +13,8 @@ </attributes> </classpathentry> <classpathentry kind="src" path="conf"/> + <classpathentry kind="src" path="src/test/resources"/> + <classpathentry kind="src" path="src/main/resources"/> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <attributes> <attribute name="maven.pomderived" value="true"/> diff --git a/conf/logging.properties b/conf/logging.properties deleted file mode 100644 index 0c3fdb94..00000000 --- a/conf/logging.properties +++ /dev/null @@ -1,14 +0,0 @@ -.handlers = java.util.logging.ConsoleHandler -.level = WARNING - -java.util.logging.ConsoleHandler.level = ALL -#java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter -java.util.logging.SimpleFormatter.format=[%1$tF %1$tr] %4$s: %5$s (%2$s) %6$s %n - -#teetime.level = ALL - -#teetime.variant.methodcallWithPorts.framework.level = ALL -#teetime.variant.methodcallWithPorts.framework.core.level = FINE -teetime.variant.methodcallWithPorts.stage.level = INFO -#teetime.variant.methodcallWithPorts.examples.traceReconstructionWithThreads.level = FINE -teetime.variant.methodcallWithPorts.examples.kiekerdays.level = FINE diff --git a/src/main/java/util/PerformanceTest.java b/src/main/java/util/PerformanceTest.java index b85aacc4..0887ae91 100644 --- a/src/main/java/util/PerformanceTest.java +++ b/src/main/java/util/PerformanceTest.java @@ -6,6 +6,7 @@ import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.rules.TestRule; import org.junit.rules.TestWatcher; @@ -14,8 +15,6 @@ import org.junit.runner.Description; import teetime.util.StopWatch; import teetime.variant.explicitScheduling.examples.throughput.TimestampObject; -import kieker.common.logging.LogFactory; - public abstract class PerformanceTest { protected static final int NUM_OBJECTS_TO_CREATE = 100000; @@ -28,6 +27,11 @@ public abstract class PerformanceTest { protected StopWatch stopWatch; protected List<TimestampObject> timestampObjects; + @BeforeClass + public static void beforeClass() { + System.setProperty("logback.configurationFile", "src/test/resources/logback-test.groovy"); + } + @Rule public final TestRule watcher = new TestWatcher() { @Override @@ -39,7 +43,6 @@ public abstract class PerformanceTest { @Before public void before() { - System.setProperty(LogFactory.CUSTOM_LOGGER_JVM, "NONE"); this.stopWatch = new StopWatch(); this.timestampObjects = new ArrayList<TimestampObject>(NUM_OBJECTS_TO_CREATE); } @@ -56,4 +59,5 @@ public abstract class PerformanceTest { System.out.println("[" + TimeUnit.NANOSECONDS.toMicros(performanceResult.avgDurInNs - performanceResult.confidenceWidthInNs) + " µs, " + TimeUnit.NANOSECONDS.toMicros(performanceResult.avgDurInNs + performanceResult.confidenceWidthInNs) + " µs]"); } + } diff --git a/conf/logback.groovy b/src/main/resources/logback.groovy similarity index 100% rename from conf/logback.groovy rename to src/main/resources/logback.groovy diff --git a/src/test/java/teetime/variant/methodcall/examples/experiment01/ChwHomePerformanceCheck.java b/src/test/java/teetime/variant/methodcall/examples/experiment01/ChwHomePerformanceCheck.java new file mode 100644 index 00000000..aeab2733 --- /dev/null +++ b/src/test/java/teetime/variant/methodcall/examples/experiment01/ChwHomePerformanceCheck.java @@ -0,0 +1,22 @@ +package teetime.variant.methodcall.examples.experiment01; + +import static org.junit.Assert.assertEquals; +import util.PerformanceCheckProfile; +import util.PerformanceResult; +import util.PerformanceTest; + +public class ChwHomePerformanceCheck implements PerformanceCheckProfile { + + @Override + public String getCorrespondingPerformanceProfile() { + return "ChwHome"; + } + + @Override + public void check() { + PerformanceResult test01 = PerformanceTest.measurementRepository.performanceResults + .get("testWithManyObjects(teetime.variant.methodcall.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test)"); + + assertEquals(292, test01.quantiles.get(0.5), 1); + } +} diff --git a/src/test/java/teetime/variant/methodcall/examples/experiment01/ChwWorkPerformanceCheck.java b/src/test/java/teetime/variant/methodcall/examples/experiment01/ChwWorkPerformanceCheck.java new file mode 100644 index 00000000..44fa5ff7 --- /dev/null +++ b/src/test/java/teetime/variant/methodcall/examples/experiment01/ChwWorkPerformanceCheck.java @@ -0,0 +1,22 @@ +package teetime.variant.methodcall.examples.experiment01; + +import static org.junit.Assert.assertEquals; +import util.PerformanceCheckProfile; +import util.PerformanceResult; +import util.PerformanceTest; + +public class ChwWorkPerformanceCheck implements PerformanceCheckProfile { + + @Override + public String getCorrespondingPerformanceProfile() { + return "ChwWork"; + } + + @Override + public void check() { + PerformanceResult test01 = PerformanceTest.measurementRepository.performanceResults + .get("testWithManyObjects(teetime.variant.methodcall.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test)"); + + assertEquals(410, test01.quantiles.get(0.5), 1); + } +} diff --git a/src/test/java/teetime/variant/methodcall/examples/experiment01/MethodCallThoughputTimestampAnalysis1Test.java b/src/test/java/teetime/variant/methodcall/examples/experiment01/MethodCallThoughputTimestampAnalysis1Test.java index 45a41b5c..e40923d0 100644 --- a/src/test/java/teetime/variant/methodcall/examples/experiment01/MethodCallThoughputTimestampAnalysis1Test.java +++ b/src/test/java/teetime/variant/methodcall/examples/experiment01/MethodCallThoughputTimestampAnalysis1Test.java @@ -15,23 +15,35 @@ ***************************************************************************/ package teetime.variant.methodcall.examples.experiment01; -import static org.junit.Assert.assertEquals; - +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; import teetime.util.ConstructorClosure; import teetime.variant.explicitScheduling.examples.throughput.TimestampObject; -import util.PerformanceResult; +import util.PerformanceCheckProfile; +import util.PerformanceCheckProfileRepository; import util.PerformanceTest; -import util.StatisticsUtil; /** * @author Christian Wulf - * + * * @since 1.10 */ public class MethodCallThoughputTimestampAnalysis1Test extends PerformanceTest { + @BeforeClass + public static void beforeClass() { + PerformanceCheckProfileRepository.INSTANCE.register(MethodCallThoughputTimestampAnalysis1Test.class, new ChwWorkPerformanceCheck()); + PerformanceCheckProfileRepository.INSTANCE.register(MethodCallThoughputTimestampAnalysis1Test.class, new ChwHomePerformanceCheck()); + }; + + @AfterClass + public static void afterClass() { + PerformanceCheckProfile performanceCheckProfile = PerformanceCheckProfileRepository.INSTANCE.get(MethodCallThoughputTimestampAnalysis1Test.class); + performanceCheckProfile.check(); + }; + // TODO check why the optimal, but inflexible impl is 500 times faster than our new framework @Test @@ -56,9 +68,6 @@ public class MethodCallThoughputTimestampAnalysis1Test extends PerformanceTest { } finally { this.stopWatch.end(); } - - PerformanceResult performanceResult = StatisticsUtil.computeStatistics(this.stopWatch.getDurationInNs(), this.timestampObjects); - assertEquals(292, performanceResult.quantiles.get(0.5), 1); // chw home } } diff --git a/src/test/java/teetime/variant/methodcallWithPorts/examples/experiment16/ChwHomePerformanceCheck.java b/src/test/java/teetime/variant/methodcallWithPorts/examples/experiment16/ChwHomePerformanceCheck.java index a924a70d..bf966214 100644 --- a/src/test/java/teetime/variant/methodcallWithPorts/examples/experiment16/ChwHomePerformanceCheck.java +++ b/src/test/java/teetime/variant/methodcallWithPorts/examples/experiment16/ChwHomePerformanceCheck.java @@ -7,6 +7,11 @@ import util.PerformanceTest; public class ChwHomePerformanceCheck implements PerformanceCheckProfile { + @Override + public String getCorrespondingPerformanceProfile() { + return "ChwHome"; + } + @Override public void check() { PerformanceResult test16a = PerformanceTest.measurementRepository.performanceResults @@ -25,9 +30,4 @@ public class ChwHomePerformanceCheck implements PerformanceCheckProfile { assertEquals(2, speedupB, 0.3); assertEquals(3, speedupC, 0.3); } - - @Override - public String getCorrespondingPerformanceProfile() { - return "ChwHome"; - } } diff --git a/src/test/resources/logback-test.groovy b/src/test/resources/logback-test.groovy new file mode 100644 index 00000000..a9a3608d --- /dev/null +++ b/src/test/resources/logback-test.groovy @@ -0,0 +1,22 @@ +import ch.qos.logback.classic.filter.ThresholdFilter + +statusListener(OnConsoleStatusListener) + +appender("FILE", FileAppender) { + file = "src/test/data/load-logs/timings-results.txt" + append = false + filter(ThresholdFilter) { + level = INFO + } + encoder(PatternLayoutEncoder) { + pattern = "%msg%n" + } +} + +appender("CONSOLE", ConsoleAppender) { + encoder(PatternLayoutEncoder) { + pattern = "%d{HH:mm:ss.SSS} %level %logger - %msg%n" + } +} + +root ERROR, ["CONSOLE"] -- GitLab