diff --git a/.checkstyle b/.checkstyle index fd0e0101452b839396eef46417b5c92347fcb5cf..a5f3e7078fdbc5ca16d8cbdb3104bdd9f584f3a4 100644 --- a/.checkstyle +++ b/.checkstyle @@ -4,7 +4,7 @@ <local-check-config name="Kieker Checkstyle" location="conf/cs-conf.xml" type="project" description=""> <additional-data name="protect-config-file" value="false"/> </local-check-config> - <fileset name="all" enabled="true" check-config-name="Sun Checks" local="false"> + <fileset name="all" enabled="true" check-config-name="Kieker Checkstyle" local="true"> <file-match-pattern match-pattern="." include-pattern="true"/> </fileset> <filter name="FilesFromPackage" enabled="true"> diff --git a/conf/cs-conf.xml b/conf/cs-conf.xml index 4d22e9d85aeb83024a2b27d5ee2237fb059de72f..950501a529875cad6f2e94e08c85be34e76d271a 100644 --- a/conf/cs-conf.xml +++ b/conf/cs-conf.xml @@ -2,9 +2,11 @@ <!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> - + <module name="Checker"> +<!-- <property name="checkstyle.ignoreCustomKieker" value=""/> --> + <!-- KIEKER default is warning instead of error --> <property name="severity" value="error"/> diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis10Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis10Test.java index 1329d2357d150be26c65d8de9fa416d21bd958ca..53802779280980c0f325151c195ad3d23c94ad2b 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis10Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis10Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis10; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -53,9 +53,9 @@ public class MethodCallThoughputTimestampAnalysis10Test { final MethodCallThroughputAnalysis10 analysis = new MethodCallThroughputAnalysis10(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis11Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis11Test.java index 6a195b288789846e2307dc22042302101072c689..0191eb46dd7a1d12b2e85ae77a236b3f24710f78 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis11Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis11Test.java @@ -21,7 +21,7 @@ import java.util.List; import org.junit.Before; import org.junit.Test; -import teetime.examples.throughput.methodcall.Closure; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis11; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -53,9 +53,9 @@ public class MethodCallThoughputTimestampAnalysis11Test { final MethodCallThroughputAnalysis11 analysis = new MethodCallThroughputAnalysis11(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Closure<Void, TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject execute(final Void element) { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis12Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis12Test.java index fb060993ce0fe1f58c76b0b8222289d23010fc6c..81b7d6d8f8cdd4f696a4fb0b785fbfaa61858f05 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis12Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis12Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis12; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -53,9 +53,9 @@ public class MethodCallThoughputTimestampAnalysis12Test { final MethodCallThroughputAnalysis12 analysis = new MethodCallThroughputAnalysis12(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis13Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis13Test.java index fe1aaf136cb79ecba79e1be4d616bd6d8fd72319..03f694b4ce1cb70360bc17a44dd3efe6b04cb990 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis13Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis13Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis13; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -53,9 +53,9 @@ public class MethodCallThoughputTimestampAnalysis13Test { final MethodCallThroughputAnalysis13 analysis = new MethodCallThroughputAnalysis13(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis14Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis14Test.java index 67579159ac0abcb03ab1ef32e6ea1b31a69f456e..70dfb915496c3885e3772111321c348896ce7d86 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis14Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis14Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis14; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -53,9 +53,9 @@ public class MethodCallThoughputTimestampAnalysis14Test { final MethodCallThroughputAnalysis14 analysis = new MethodCallThroughputAnalysis14(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis15Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis15Test.java index fec03aa93538cb18de1819ff265a2e199d4512ca..3553ea928fe7f6a147b6b7bae07d93f57ad2e833 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis15Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis15Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis15; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -53,9 +53,9 @@ public class MethodCallThoughputTimestampAnalysis15Test { final MethodCallThroughputAnalysis15 analysis = new MethodCallThroughputAnalysis15(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis16Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis16Test.java index 8332575461b4bb56b32ed8fbd09a5d6bee767c2c..287345461d2c812e5ccf0c2a4c3186c2a8d9e423 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis16Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis16Test.java @@ -20,7 +20,7 @@ import java.util.List; import org.junit.Before; import org.junit.Test; -import teetime.examples.throughput.methodcall.Closure; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis16; import teetime.util.ListUtil; import teetime.util.StatisticsUtil; @@ -51,9 +51,9 @@ public class MethodCallThoughputTimestampAnalysis16Test { final MethodCallThroughputAnalysis16 analysis = new MethodCallThroughputAnalysis16(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Closure<Void, TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject execute(final Void element) { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis17Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis17Test.java index 23964a0550037fa84e69c86e83f68747755f96d9..b5dababf03cb5260b4359662e3aa393d42eb4b8d 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis17Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis17Test.java @@ -20,7 +20,7 @@ import java.util.List; import org.junit.Before; import org.junit.Test; -import teetime.examples.throughput.methodcall.Closure; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis17; import teetime.util.ListUtil; import teetime.util.StatisticsUtil; @@ -51,9 +51,9 @@ public class MethodCallThoughputTimestampAnalysis17Test { final MethodCallThroughputAnalysis17 analysis = new MethodCallThroughputAnalysis17(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Closure<Void, TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject execute(final Void element) { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis1Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis1Test.java index 9ed23342f1aecc29668ae4c066e44047d0016efd..47f9be433d30daba5b2944ff6589e7b1d07a5fe4 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis1Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis1Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis1; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -56,9 +56,9 @@ public class MethodCallThoughputTimestampAnalysis1Test { final MethodCallThroughputAnalysis1 analysis = new MethodCallThroughputAnalysis1(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis2Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis2Test.java index 07086663bc62a4d2fd9792d883e6f2e086df0506..455641154b5154d8560117467d6651bbd55c7202 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis2Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis2Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis2; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -56,9 +56,9 @@ public class MethodCallThoughputTimestampAnalysis2Test { final MethodCallThroughputAnalysis2 analysis = new MethodCallThroughputAnalysis2(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis3Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis3Test.java index 6b4d7993ec2022dc237623bfdabc0def84b58433..ee6947e838fce005f6e24478c3698e68145901b2 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis3Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis3Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis3; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -56,9 +56,9 @@ public class MethodCallThoughputTimestampAnalysis3Test { final MethodCallThroughputAnalysis3 analysis = new MethodCallThroughputAnalysis3(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis4Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis4Test.java index 535ca15327005f4721517a3b151b9cabfc06552d..68f60772c3aa9c944ac0e1bd38fcdad01a345d44 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis4Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis4Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis4; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -56,9 +56,9 @@ public class MethodCallThoughputTimestampAnalysis4Test { final MethodCallThroughputAnalysis4 analysis = new MethodCallThroughputAnalysis4(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis5Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis5Test.java index 5288049d141bb33dd95bb9da9575a713bb2b0cbb..106e5b0b3d9fa2378da66081ef1d6c166afb682a 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis5Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis5Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis5; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -56,9 +56,9 @@ public class MethodCallThoughputTimestampAnalysis5Test { final MethodCallThroughputAnalysis5 analysis = new MethodCallThroughputAnalysis5(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis6Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis6Test.java index 4a7923f3ba9d37fbdad423f7a5d2febc494ee207..72c788c737aa3474f8edb447f7d953615d9284b8 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis6Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis6Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis6; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -56,9 +56,9 @@ public class MethodCallThoughputTimestampAnalysis6Test { final MethodCallThroughputAnalysis6 analysis = new MethodCallThroughputAnalysis6(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis7Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis7Test.java index ef511bb5a1f9a66733ed574e4125b7984082a6e5..bb54421827cc806233db9e2f6e200b014be2f821 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis7Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis7Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis7; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -56,9 +56,9 @@ public class MethodCallThoughputTimestampAnalysis7Test { final MethodCallThroughputAnalysis7 analysis = new MethodCallThroughputAnalysis7(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis8Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis8Test.java index 8a9b34ff0ca39af0f87dd5978b9634c37d489cab..902155fbc3065977162945c8e7f5da5307e855da 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis8Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis8Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis8; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -53,9 +53,9 @@ public class MethodCallThoughputTimestampAnalysis8Test { final MethodCallThroughputAnalysis8 analysis = new MethodCallThroughputAnalysis8(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis9Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis9Test.java index 4c41d19959cc379efb3588628ab0c9fe8862999b..5f781adac61e27583dd22e7499c73ae5da2a6074 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis9Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis9Test.java @@ -17,11 +17,11 @@ package teetime.examples.throughput; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis9; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; @@ -53,9 +53,9 @@ public class MethodCallThoughputTimestampAnalysis9Test { final MethodCallThroughputAnalysis9 analysis = new MethodCallThroughputAnalysis9(); analysis.setNumNoopFilters(NUM_NOOP_FILTERS); analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { + analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() { @Override - public TimestampObject call() throws Exception { + public TimestampObject create() { return new TimestampObject(); } }); diff --git a/src/test/java/teetime/examples/throughput/methodcall/Closure.java b/src/test/java/teetime/examples/throughput/methodcall/Closure.java deleted file mode 100644 index f208c9a1a6e6b698dd150e109256a0616bc41df1..0000000000000000000000000000000000000000 --- a/src/test/java/teetime/examples/throughput/methodcall/Closure.java +++ /dev/null @@ -1,6 +0,0 @@ -package teetime.examples.throughput.methodcall; - -public interface Closure<I, O> { - - public abstract O execute(I element); -} diff --git a/src/test/java/teetime/examples/throughput/methodcall/ConstructorClosure.java b/src/test/java/teetime/examples/throughput/methodcall/ConstructorClosure.java new file mode 100644 index 0000000000000000000000000000000000000000..9577fef609efeeb52f3b61e8683d6b5c0af7abeb --- /dev/null +++ b/src/test/java/teetime/examples/throughput/methodcall/ConstructorClosure.java @@ -0,0 +1,8 @@ +package teetime.examples.throughput.methodcall; + +public interface ConstructorClosure<O> { + + // O create(); + + O create(); +} diff --git a/src/test/java/teetime/examples/throughput/methodcall/InputPort.java b/src/test/java/teetime/examples/throughput/methodcall/InputPort.java index 3da7d22b107005085ebc4caa4c9fa266d2a43f20..02e69fd442244682a602c9a57e61655cfd76b264 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/InputPort.java +++ b/src/test/java/teetime/examples/throughput/methodcall/InputPort.java @@ -2,7 +2,7 @@ package teetime.examples.throughput.methodcall; public class InputPort<T> { - public IPipe<T> pipe; + private IPipe<T> pipe; public T receive() { T element = this.pipe.removeLast(); @@ -14,4 +14,12 @@ public class InputPort<T> { return element; } + public IPipe<T> getPipe() { + return this.pipe; + } + + public void setPipe(final IPipe<T> pipe) { + this.pipe = pipe; + } + } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis1.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis1.java index e99550676199947c63d44d805f8bb0ec56ba911e..b893346293a9ee8b8fd9d316f240b8bac15c83ea 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis1.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis1.java @@ -16,7 +16,6 @@ package teetime.examples.throughput.methodcall; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.CollectorSink; @@ -34,7 +33,7 @@ import teetime.framework.core.Analysis; public class MethodCallThroughputAnalysis1 extends Analysis { private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -87,7 +86,7 @@ public class MethodCallThroughputAnalysis1 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis10.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis10.java index 0ca0b26fcaee872240599c55b24a90bf22a4263d..cd52067068aeda2b5cbd410a7b8fe0548d5a5b31 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis10.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis10.java @@ -16,7 +16,6 @@ package teetime.examples.throughput.methodcall; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.CollectorSink; @@ -35,7 +34,7 @@ import teetime.framework.core.Analysis; public class MethodCallThroughputAnalysis10 extends Analysis { private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -86,7 +85,7 @@ public class MethodCallThroughputAnalysis10 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis11.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis11.java index 9e6e763c212894ef5be17ceeb4bec891691229c7..ca5ab5d2a2e84fce1b3f18af36512bc443924f65 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis11.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis11.java @@ -34,7 +34,7 @@ import teetime.framework.core.Analysis; public class MethodCallThroughputAnalysis11 extends Analysis { private long numInputObjects; - private Closure<Void, TimestampObject> inputObjectCreator; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -50,11 +50,13 @@ public class MethodCallThroughputAnalysis11 extends Analysis { * @param numNoopFilters * @since 1.10 */ - private Pipeline<Void, Object> buildPipeline(final long numInputObjects, final Closure<Void, TimestampObject> inputObjectCreator) { + private Pipeline<Void, Object> buildPipeline(final long numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { @SuppressWarnings("unchecked") final NoopFilter<TimestampObject>[] noopFilters = new NoopFilter[this.numNoopFilters]; // create stages final ObjectProducer<TimestampObject> objectProducer = new ObjectProducer<TimestampObject>(numInputObjects, inputObjectCreator); + // Relay<TimestampObject> relay = new Relay<TimestampObject>(); + // NoopFilter<TimestampObject> relayFake = new NoopFilter<TimestampObject>(); final StartTimestampFilter startTimestampFilter = new StartTimestampFilter(); for (int i = 0; i < noopFilters.length; i++) { noopFilters[i] = new NoopFilter<TimestampObject>(); @@ -62,19 +64,17 @@ public class MethodCallThroughputAnalysis11 extends Analysis { final StopTimestampFilter stopTimestampFilter = new StopTimestampFilter(); final CollectorSink<TimestampObject> collectorSink = new CollectorSink<TimestampObject>(this.timestampObjects); - // Relay<TimestampObject> relay = new Relay<TimestampObject>(); - final Pipeline<Void, Object> pipeline = new Pipeline<Void, Object>(); pipeline.setFirstStage(objectProducer); - // pipeline.addIntermediateStage(relay); + // pipeline.addIntermediateStage(relayFake); pipeline.addIntermediateStage(startTimestampFilter); pipeline.addIntermediateStages(noopFilters); pipeline.addIntermediateStage(stopTimestampFilter); pipeline.setLastStage(collectorSink); UnorderedGrowablePipe.connect(objectProducer.getOutputPort(), startTimestampFilter.getInputPort()); - // UnorderedGrowablePipe.connect(objectProducer.getOutputPort(), relay.getInputPort()); - // UnorderedGrowablePipe.connect(relay.getOutputPort(), startTimestampFilter.getInputPort()); + // UnorderedGrowablePipe.connect(objectProducer.getOutputPort(), relayFake.getInputPort()); + // UnorderedGrowablePipe.connect(relayFake.getOutputPort(), startTimestampFilter.getInputPort()); UnorderedGrowablePipe.connect(startTimestampFilter.getOutputPort(), noopFilters[0].getInputPort()); for (int i = 0; i < noopFilters.length - 1; i++) { @@ -92,7 +92,7 @@ public class MethodCallThroughputAnalysis11 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Closure<Void, TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis12.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis12.java index afa57c29494c448fec7c6b0dc410a4f065d8567b..2bc90dd61217ca7d9825c0d6be875669ba39fd54 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis12.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis12.java @@ -16,7 +16,6 @@ package teetime.examples.throughput.methodcall; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.CollectorSink; @@ -35,7 +34,7 @@ import teetime.framework.core.Analysis; public class MethodCallThroughputAnalysis12 extends Analysis { private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -90,7 +89,7 @@ public class MethodCallThroughputAnalysis12 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis13.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis13.java index dd1e6d566094db587eeda3266a39a99503854655..81f72d7ca318dc045c313e814dc439502f24f45e 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis13.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis13.java @@ -18,7 +18,6 @@ package teetime.examples.throughput.methodcall; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.AbstractStage; @@ -44,7 +43,7 @@ public class MethodCallThroughputAnalysis13 extends Analysis { } private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -115,7 +114,7 @@ public class MethodCallThroughputAnalysis13 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis14.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis14.java index 7dbf56904105e324b03ca87f84b10be49d8dff67..9eb9f521812ac7f0259aae2d5991b6e15130d48d 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis14.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis14.java @@ -16,7 +16,6 @@ package teetime.examples.throughput.methodcall; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.CollectorSink; @@ -35,7 +34,7 @@ import teetime.framework.core.Analysis; public class MethodCallThroughputAnalysis14 extends Analysis { private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -86,7 +85,7 @@ public class MethodCallThroughputAnalysis14 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis15.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis15.java index 9946f542d6d7f39f9e0de4e156922e7c1cdb3baa..c0bf75681eabc112f90de0c8c170a2f079ec9ea1 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis15.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis15.java @@ -16,7 +16,6 @@ package teetime.examples.throughput.methodcall; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.Clock; @@ -37,8 +36,8 @@ import teetime.framework.core.Analysis; */ public class MethodCallThroughputAnalysis15 extends Analysis { - private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private int numInputObjects; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; @@ -104,23 +103,7 @@ public class MethodCallThroughputAnalysis15 extends Analysis { UnorderedGrowablePipe.connect(delay.getOutputPort(), collectorSink.getInputPort()); - pipeline.onStart(); - - // pipeline.getInputPort().pipe = new Pipe<Void>(); - // pipeline.getInputPort().pipe.add(new Object()); - - // pipeline.getOutputPort().pipe = new Pipe<Void>(); - - final Runnable runnable = new Runnable() { - @Override - public void run() { - do { - pipeline.executeWithPorts(); - } while (pipeline.getSchedulingInformation().isActive() && pipeline.isReschedulable()); - } - }; - - return runnable; + return new RunnableStage(pipeline); } @Override @@ -132,7 +115,7 @@ public class MethodCallThroughputAnalysis15 extends Analysis { clockThread.interrupt(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis16.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis16.java index d3a2d10f45206d39d49286740c171ed40d395195..e58e1b93f8bf0cc7778d5715a59adb275156752b 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis16.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis16.java @@ -40,7 +40,7 @@ public class MethodCallThroughputAnalysis16 extends Analysis { private static final int NUM_WORKER_THREADS = Runtime.getRuntime().availableProcessors(); private int numInputObjects; - private Closure<Void, TimestampObject> inputObjectCreator; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private final List<List<TimestampObject>> timestampObjectsList = new LinkedList<List<TimestampObject>>(); @@ -77,7 +77,7 @@ public class MethodCallThroughputAnalysis16 extends Analysis { } } - private Pipeline<Void, TimestampObject> buildProducerPipeline(final int numInputObjects, final Closure<Void, TimestampObject> inputObjectCreator) { + private Pipeline<Void, TimestampObject> buildProducerPipeline(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { final ObjectProducer<TimestampObject> objectProducer = new ObjectProducer<TimestampObject>(numInputObjects, inputObjectCreator); this.distributor = new Distributor<TimestampObject>(); @@ -145,7 +145,7 @@ public class MethodCallThroughputAnalysis16 extends Analysis { } } - public void setInput(final int numInputObjects, final Closure<Void, TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis17.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis17.java index ec9b620c506da4500302e4633f3d219280383a1b..81da2950b41abb270ca39cff89b6388f5c470c4c 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis17.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis17.java @@ -31,6 +31,7 @@ import teetime.examples.throughput.methodcall.stage.Sink; import teetime.examples.throughput.methodcall.stage.StartTimestampFilter; import teetime.examples.throughput.methodcall.stage.StopTimestampFilter; import teetime.framework.core.Analysis; +import teetime.util.StopWatch; /** * @author Christian Wulf @@ -42,7 +43,7 @@ public class MethodCallThroughputAnalysis17 extends Analysis { private static final int NUM_WORKER_THREADS = Runtime.getRuntime().availableProcessors(); private int numInputObjects; - private Closure<Void, TimestampObject> inputObjectCreator; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private final List<List<TimestampObject>> timestampObjectsList = new LinkedList<List<TimestampObject>>(); @@ -53,7 +54,7 @@ public class MethodCallThroughputAnalysis17 extends Analysis { @Override public void init() { final Pipeline<Void, TimestampObject> producerPipeline = this.buildProducerPipeline(this.numInputObjects, this.inputObjectCreator); - // this.producerThread = new Thread(new RunnableStage(producerPipeline)); + this.producerThread = new Thread(new RunnableStage(producerPipeline)); int numWorkerThreads = Math.min(NUM_WORKER_THREADS, 1); // only for testing purpose @@ -87,7 +88,7 @@ public class MethodCallThroughputAnalysis17 extends Analysis { // this.producerThread.start(); // this.producerThread.run(); - // new RunnableStage(producerPipeline).run(); + new RunnableStage(producerPipeline).run(); // Pipeline<Void, TimestampObject> stage = producerPipeline; // stage.onStart(); @@ -112,7 +113,7 @@ public class MethodCallThroughputAnalysis17 extends Analysis { super.init(); } - private Pipeline<Void, TimestampObject> buildProducerPipeline(final int numInputObjects, final Closure<Void, TimestampObject> inputObjectCreator) { + private Pipeline<Void, TimestampObject> buildProducerPipeline(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { final ObjectProducer<TimestampObject> objectProducer = new ObjectProducer<TimestampObject>(numInputObjects, inputObjectCreator); Distributor<TimestampObject> distributor = new Distributor<TimestampObject>(); Sink<TimestampObject> sink = new Sink<TimestampObject>(); @@ -132,7 +133,7 @@ public class MethodCallThroughputAnalysis17 extends Analysis { // objectProducer.getOutputPort().pipe = new UnorderedGrowablePipe<TimestampObject>(); UnorderedGrowablePipe.connect(objectProducer.getOutputPort(), distributor.getInputPort()); - distributor.getOutputPort().pipe = new UnorderedGrowablePipe<TimestampObject>(); + distributor.getOutputPort().setPipe(new UnorderedGrowablePipe<TimestampObject>()); return pipeline; } @@ -143,10 +144,10 @@ public class MethodCallThroughputAnalysis17 extends Analysis { */ private Runnable buildPipeline(final StageWithPort<Void, TimestampObject> previousStage, final List<TimestampObject> timestampObjects) { Relay<TimestampObject> relay = new Relay<TimestampObject>(); - @SuppressWarnings("unchecked") - final NoopFilter<TimestampObject>[] noopFilters = new NoopFilter[this.numNoopFilters]; // create stages final StartTimestampFilter startTimestampFilter = new StartTimestampFilter(); + @SuppressWarnings("unchecked") + final NoopFilter<TimestampObject>[] noopFilters = new NoopFilter[this.numNoopFilters]; for (int i = 0; i < noopFilters.length; i++) { noopFilters[i] = new NoopFilter<TimestampObject>(); } @@ -163,14 +164,14 @@ public class MethodCallThroughputAnalysis17 extends Analysis { IPipe<TimestampObject> startPipe = new SpScPipe<TimestampObject>(); try { for (int i = 0; i < this.numInputObjects; i++) { - startPipe.add(this.inputObjectCreator.execute(null)); + startPipe.add(this.inputObjectCreator.create()); } startPipe.close(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } - relay.getInputPort().pipe = startPipe; + relay.getInputPort().setPipe(startPipe); // previousStage.getOutputPort().pipe = startPipe; UnorderedGrowablePipe.connect(relay.getOutputPort(), startTimestampFilter.getInputPort()); @@ -185,8 +186,11 @@ public class MethodCallThroughputAnalysis17 extends Analysis { return new RunnableStage(pipeline); } + private final StopWatch stopWatch = new StopWatch(); + @Override public void start() { + this.stopWatch.start(); super.start(); for (Thread workerThread : this.workerThreads) { @@ -201,9 +205,11 @@ public class MethodCallThroughputAnalysis17 extends Analysis { // TODO Auto-generated catch block e.printStackTrace(); } + this.stopWatch.end(); + System.out.println("dur: " + this.stopWatch.getDurationInNs() + " ns"); } - public void setInput(final int numInputObjects, final Closure<Void, TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis2.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis2.java index 3ff1ec4d2d1310a3087fad44ed7681bcabd1a4de..55f565cbbee5a720f52c36e0910b8681362c0094 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis2.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis2.java @@ -16,7 +16,6 @@ package teetime.examples.throughput.methodcall; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.CollectorSink; @@ -36,8 +35,8 @@ import teetime.util.list.CommittableResizableArrayQueue; */ public class MethodCallThroughputAnalysis2 extends Analysis { - private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private int numInputObjects; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -99,7 +98,7 @@ public class MethodCallThroughputAnalysis2 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis3.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis3.java index e40e3bb5f6d3e7a0de7cc0fa364480d6674f07b0..e98767862c2d2ae46b9eb21dccfa7e62f3316861 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis3.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis3.java @@ -18,7 +18,6 @@ package teetime.examples.throughput.methodcall; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.CollectorSink; @@ -41,8 +40,8 @@ public class MethodCallThroughputAnalysis3 extends Analysis { } - private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private int numInputObjects; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -122,7 +121,7 @@ public class MethodCallThroughputAnalysis3 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis4.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis4.java index f60c083801573fbf8147402f5b35dbf11ce72339..e543ad2684d371418d044ab89af4ce565b0daa7f 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis4.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis4.java @@ -18,7 +18,6 @@ package teetime.examples.throughput.methodcall; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.CollectorSink; @@ -41,8 +40,8 @@ public class MethodCallThroughputAnalysis4 extends Analysis { } - private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private int numInputObjects; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -113,7 +112,7 @@ public class MethodCallThroughputAnalysis4 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis5.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis5.java index ae54e4b4730fdca736f80af232ab829069ab1606..4c59946b27fddb8bf5e5741bfccbe4c8ac3841fa 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis5.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis5.java @@ -18,7 +18,6 @@ package teetime.examples.throughput.methodcall; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.CollectorSink; @@ -41,8 +40,8 @@ public class MethodCallThroughputAnalysis5 extends Analysis { } - private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private int numInputObjects; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -122,7 +121,7 @@ public class MethodCallThroughputAnalysis5 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis6.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis6.java index ee056d28ea06fc9ce6b2e7f4db5e5454e394620f..4d3a33befd3857d68f9e4c1ea5d0c77a169c453b 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis6.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis6.java @@ -18,7 +18,6 @@ package teetime.examples.throughput.methodcall; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.CollectorSink; @@ -41,8 +40,8 @@ public class MethodCallThroughputAnalysis6 extends Analysis { } - private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private int numInputObjects; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -915,7 +914,7 @@ public class MethodCallThroughputAnalysis6 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis7.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis7.java index ac22b177bf70b028a73b386b8b603877eb2cac1d..8b5ac8a9fc67d0b9f2a2919471fa7f21e290c5c0 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis7.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis7.java @@ -18,7 +18,6 @@ package teetime.examples.throughput.methodcall; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.AbstractStage; @@ -42,8 +41,8 @@ public class MethodCallThroughputAnalysis7 extends Analysis { } - private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private int numInputObjects; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -125,7 +124,7 @@ public class MethodCallThroughputAnalysis7 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis8.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis8.java index 5de987ca64fabbee7da70d30426b5b9980158a16..30ba261b0b0ca7534a5dff364e7ac9e72c13b602 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis8.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis8.java @@ -18,7 +18,6 @@ package teetime.examples.throughput.methodcall; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.AbstractStage; @@ -42,8 +41,8 @@ public class MethodCallThroughputAnalysis8 extends Analysis { } - private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private int numInputObjects; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -128,7 +127,7 @@ public class MethodCallThroughputAnalysis8 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis9.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis9.java index 257e213dcdebeed86c64f6caa91d07e036e36b01..075bb788b941141a3f1b3546259c99321ea34c14 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis9.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis9.java @@ -16,7 +16,6 @@ package teetime.examples.throughput.methodcall; import java.util.List; -import java.util.concurrent.Callable; import teetime.examples.throughput.TimestampObject; import teetime.examples.throughput.methodcall.stage.CollectorSink; @@ -34,8 +33,8 @@ import teetime.framework.core.Analysis; */ public class MethodCallThroughputAnalysis9 extends Analysis { - private long numInputObjects; - private Callable<TimestampObject> inputObjectCreator; + private int numInputObjects; + private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; @@ -86,7 +85,7 @@ public class MethodCallThroughputAnalysis9 extends Analysis { this.runnable.run(); } - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { + public void setInput(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/OrderedGrowableArrayPipe.java b/src/test/java/teetime/examples/throughput/methodcall/OrderedGrowableArrayPipe.java index ad653410600ee0f881fa7dbd572831953e3a0b06..7f5aea2f2f498145791a20794b7b9141d3384f53 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/OrderedGrowableArrayPipe.java +++ b/src/test/java/teetime/examples/throughput/methodcall/OrderedGrowableArrayPipe.java @@ -18,8 +18,8 @@ public class OrderedGrowableArrayPipe<T> extends AbstractPipe<T> { public static <T> void connect(final OutputPort<T> sourcePort, final InputPort<T> targetPort) { IPipe<T> pipe = new OrderedGrowableArrayPipe<T>(); - sourcePort.pipe = pipe; - targetPort.pipe = pipe; + sourcePort.setPipe(pipe); + targetPort.setPipe(pipe); } @Override diff --git a/src/test/java/teetime/examples/throughput/methodcall/OrderedGrowablePipe.java b/src/test/java/teetime/examples/throughput/methodcall/OrderedGrowablePipe.java index 62f7bf9a0b8a696f390742788b7e1b9fc92d4add..645cd00423e8a86ec89805c6852c79ee7e0f281f 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/OrderedGrowablePipe.java +++ b/src/test/java/teetime/examples/throughput/methodcall/OrderedGrowablePipe.java @@ -16,8 +16,8 @@ public class OrderedGrowablePipe<T> extends AbstractPipe<T> { public static <T> void connect(final OutputPort<T> sourcePort, final InputPort<T> targetPort) { IPipe<T> pipe = new OrderedGrowablePipe<T>(); - sourcePort.pipe = pipe; - targetPort.pipe = pipe; + sourcePort.setPipe(pipe); + targetPort.setPipe(pipe); } @Override diff --git a/src/test/java/teetime/examples/throughput/methodcall/OutputPort.java b/src/test/java/teetime/examples/throughput/methodcall/OutputPort.java index 19f2bc5ed2074784780eb84bfb25ac708ce03779..837d67eb9d1b70786c1f0a8f3defc9880c03d91c 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/OutputPort.java +++ b/src/test/java/teetime/examples/throughput/methodcall/OutputPort.java @@ -2,9 +2,17 @@ package teetime.examples.throughput.methodcall; public class OutputPort<T> { - public IPipe<T> pipe; + private IPipe<T> pipe; public void send(final T element) { this.pipe.add(element); } + + public IPipe<T> getPipe() { + return this.pipe; + } + + public void setPipe(final IPipe<T> pipe) { + this.pipe = pipe; + } } diff --git a/src/test/java/teetime/examples/throughput/methodcall/Pipe.java b/src/test/java/teetime/examples/throughput/methodcall/Pipe.java index e6e9c00eeb184da79f476f73631884eb1bc9185f..0e6081b0884b7e062d9e77543ba4b80ca33779fc 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/Pipe.java +++ b/src/test/java/teetime/examples/throughput/methodcall/Pipe.java @@ -8,8 +8,8 @@ public class Pipe<T> extends AbstractPipe<T> { public static <T> void connect(final OutputPort<T> sourcePort, final InputPort<T> targetPort) { IPipe<T> pipe = new Pipe<T>(); - sourcePort.pipe = pipe; - targetPort.pipe = pipe; + sourcePort.setPipe(pipe); + targetPort.setPipe(pipe); } /* diff --git a/src/test/java/teetime/examples/throughput/methodcall/SingleElementPipe.java b/src/test/java/teetime/examples/throughput/methodcall/SingleElementPipe.java index ab6a33de8c381de8664b363e455372989029391d..44409ddb96520da8a6beb346a3a59e2f4e5d7c79 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/SingleElementPipe.java +++ b/src/test/java/teetime/examples/throughput/methodcall/SingleElementPipe.java @@ -7,8 +7,8 @@ public class SingleElementPipe<T> extends AbstractPipe<T> { public static <T> void connect(final OutputPort<T> sourcePort, final InputPort<T> targetPort) { IPipe<T> pipe = new SingleElementPipe<T>(); - sourcePort.pipe = pipe; - targetPort.pipe = pipe; + sourcePort.setPipe(pipe); + targetPort.setPipe(pipe); } @Override diff --git a/src/test/java/teetime/examples/throughput/methodcall/SpScPipe.java b/src/test/java/teetime/examples/throughput/methodcall/SpScPipe.java index 37380ef64d99f61503decc6345b587d6a4caf240..b545cf38afa779e9303694cb5bf2ff1d3dc558cd 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/SpScPipe.java +++ b/src/test/java/teetime/examples/throughput/methodcall/SpScPipe.java @@ -8,8 +8,8 @@ public class SpScPipe<T> extends AbstractPipe<T> { public static <T> void connect(final OutputPort<T> sourcePort, final InputPort<T> targetPort) { IPipe<T> pipe = new SpScPipe<T>(); - sourcePort.pipe = pipe; - targetPort.pipe = pipe; + sourcePort.setPipe(pipe); + targetPort.setPipe(pipe); } @Override diff --git a/src/test/java/teetime/examples/throughput/methodcall/UnorderedGrowablePipe.java b/src/test/java/teetime/examples/throughput/methodcall/UnorderedGrowablePipe.java index 1f9032ce9c5a2327f541d38544423f59b36b9913..87b94df6440a7904f85817eac4ca10adbfb9e429 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/UnorderedGrowablePipe.java +++ b/src/test/java/teetime/examples/throughput/methodcall/UnorderedGrowablePipe.java @@ -41,8 +41,8 @@ public class UnorderedGrowablePipe<T> extends AbstractPipe<T> { public static <T> void connect(final OutputPort<T> sourcePort, final InputPort<T> targetPort) { IPipe<T> pipe = new UnorderedGrowablePipe<T>(); - sourcePort.pipe = pipe; - targetPort.pipe = pipe; + sourcePort.setPipe(pipe); + targetPort.setPipe(pipe); } @Override @@ -57,6 +57,9 @@ public class UnorderedGrowablePipe<T> extends AbstractPipe<T> { @Override public T removeLast() { + // if (this.lastFreeIndex == 0) { + // return null; + // } T element = this.elements[--this.lastFreeIndex]; this.elements[this.lastFreeIndex] = null; // T element = this.elements.get(--this.lastFreeIndex); diff --git a/src/test/java/teetime/examples/throughput/methodcall/stage/AbstractStage.java b/src/test/java/teetime/examples/throughput/methodcall/stage/AbstractStage.java index 50bb9f9248ee85bb0f2cb65a400cb248fdadd1fc..0e7614b2a47be672ecec979ab9ed98eead10614f 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/stage/AbstractStage.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/AbstractStage.java @@ -12,7 +12,7 @@ public abstract class AbstractStage<I, O> implements StageWithPort<I, O> { private final OutputPort<O> outputPort = new OutputPort<O>(); // protected final CommittableQueue<O> outputElements = new CommittableResizableArrayQueue<O>(null, 4); - private final CommittableQueue<O> outputElements = null; + // private final CommittableQueue<O> outputElements = null; private Stage<?, ?> parentStage; @@ -67,9 +67,10 @@ public abstract class AbstractStage<I, O> implements StageWithPort<I, O> { this.execute4(elements); - this.outputElements.commit(); + // this.outputElements.commit(); - return this.outputElements; + // return this.outputElements; + return null; } // @Override diff --git a/src/test/java/teetime/examples/throughput/methodcall/stage/Clock.java b/src/test/java/teetime/examples/throughput/methodcall/stage/Clock.java index 0381e75851140f097d3c71f9c07db6e20d5c91d9..f6d8fe3da71d4fd06c2f0521f0e88dfca9265709 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/stage/Clock.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/Clock.java @@ -1,6 +1,5 @@ package teetime.examples.throughput.methodcall.stage; -import teetime.examples.throughput.methodcall.ProducerStage; import teetime.util.list.CommittableQueue; public class Clock extends ProducerStage<Void, Long> { diff --git a/src/test/java/teetime/examples/throughput/methodcall/stage/CollectorSink.java b/src/test/java/teetime/examples/throughput/methodcall/stage/CollectorSink.java index 2dfce1365845431b13a62a827310adf72bf8ac80..481d12728dcfa0400d82ba0a29b8aeb64da5e21e 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/stage/CollectorSink.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/CollectorSink.java @@ -17,7 +17,6 @@ package teetime.examples.throughput.methodcall.stage; import java.util.List; -import teetime.examples.throughput.methodcall.ConsumerStage; import teetime.util.list.CommittableQueue; /** diff --git a/src/test/java/teetime/examples/throughput/methodcall/ConsumerStage.java b/src/test/java/teetime/examples/throughput/methodcall/stage/ConsumerStage.java similarity index 83% rename from src/test/java/teetime/examples/throughput/methodcall/ConsumerStage.java rename to src/test/java/teetime/examples/throughput/methodcall/stage/ConsumerStage.java index 710b6afef21da63dc3f4f6ef2ec639243180bfd8..e9db16c8cb574ea036ced42b8afe28e078cb92a2 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/ConsumerStage.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/ConsumerStage.java @@ -1,6 +1,5 @@ -package teetime.examples.throughput.methodcall; +package teetime.examples.throughput.methodcall.stage; -import teetime.examples.throughput.methodcall.stage.AbstractStage; import teetime.util.list.CommittableQueue; public abstract class ConsumerStage<I, O> extends AbstractStage<I, O> { @@ -23,7 +22,7 @@ public abstract class ConsumerStage<I, O> extends AbstractStage<I, O> { public void executeWithPorts() { I element = this.getInputPort().receive(); - this.setReschedulable(this.getInputPort().pipe.size() > 0); + this.setReschedulable(this.getInputPort().getPipe().size() > 0); this.execute5(element); diff --git a/src/test/java/teetime/examples/throughput/methodcall/stage/Delay.java b/src/test/java/teetime/examples/throughput/methodcall/stage/Delay.java index b1c590777c8b843fcf740dedd029486250f74adf..5995c4573798ef705f50f6eb5e909f278e833da9 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/stage/Delay.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/Delay.java @@ -21,7 +21,7 @@ public class Delay<I> extends AbstractStage<I, I> { // System.out.println("#elements: " + this.getInputPort().pipe.size()); // TODO implement receiveAll() and sendMultiple() - while (!this.getInputPort().pipe.isEmpty()) { + while (!this.getInputPort().getPipe().isEmpty()) { I element = this.getInputPort().receive(); this.send(element); } diff --git a/src/test/java/teetime/examples/throughput/methodcall/stage/Distributor.java b/src/test/java/teetime/examples/throughput/methodcall/stage/Distributor.java index 628dd181cf076f972fca5f969c8685b109e00516..322159b5fe452478dc7ad6ef359a1e20389f9940 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/stage/Distributor.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/Distributor.java @@ -3,12 +3,11 @@ package teetime.examples.throughput.methodcall.stage; import java.util.ArrayList; import java.util.List; -import teetime.examples.throughput.methodcall.ConsumerStage; import teetime.examples.throughput.methodcall.OutputPort; import teetime.util.concurrent.spsc.Pow2; import teetime.util.list.CommittableQueue; -public class Distributor<T> extends ConsumerStage<T, T> { +public final class Distributor<T> extends AbstractStage<T, T> { private final List<OutputPort<T>> outputPortList = new ArrayList<OutputPort<T>>(); @@ -41,8 +40,8 @@ public class Distributor<T> extends ConsumerStage<T, T> { @Override public void onIsPipelineHead() { for (OutputPort<?> op : this.outputPorts) { - op.pipe.close(); - System.out.println("End signal sent, size: " + op.pipe.size()); + op.getPipe().close(); + System.out.println("End signal sent, size: " + op.getPipe().size()); } // for (OutputPort<?> op : this.outputPorts) { @@ -74,4 +73,13 @@ public class Distributor<T> extends ConsumerStage<T, T> { return outputPort; } + @Override + public void executeWithPorts() { + T element = this.getInputPort().receive(); + + this.setReschedulable(this.getInputPort().getPipe().size() > 0); + + this.execute5(element); + } + } diff --git a/src/test/java/teetime/examples/throughput/methodcall/stage/EndStage.java b/src/test/java/teetime/examples/throughput/methodcall/stage/EndStage.java index 23439c4384f50a5c6e484a52c9dfe9f912575a80..c5a501d56a2fda2404210270442f45f283afc162 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/stage/EndStage.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/EndStage.java @@ -3,7 +3,7 @@ package teetime.examples.throughput.methodcall.stage; import java.util.LinkedList; import java.util.List; -import teetime.examples.throughput.methodcall.Closure; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.examples.throughput.methodcall.InputPort; import teetime.examples.throughput.methodcall.OutputPort; import teetime.examples.throughput.methodcall.Stage; @@ -18,7 +18,7 @@ public class EndStage<T> implements StageWithPort<T, T> { } public int count; - public Closure<Void, ?> closure; + public ConstructorClosure<?> closure; public List<Object> list = new LinkedList<Object>(); @Override diff --git a/src/test/java/teetime/examples/throughput/methodcall/stage/NoopFilter.java b/src/test/java/teetime/examples/throughput/methodcall/stage/NoopFilter.java index 7fdf98b2bca1ab6f0149be7222429d2cd01c1122..98413fbb37cf3d2878c6f7c6f991fe66277e36c8 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/stage/NoopFilter.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/NoopFilter.java @@ -15,7 +15,6 @@ ***************************************************************************/ package teetime.examples.throughput.methodcall.stage; -import teetime.examples.throughput.methodcall.ConsumerStage; import teetime.util.list.CommittableQueue; /** diff --git a/src/test/java/teetime/examples/throughput/methodcall/stage/ObjectProducer.java b/src/test/java/teetime/examples/throughput/methodcall/stage/ObjectProducer.java index 86ee06067edfb243a58a171d4489d1ab66d93c2f..9db2918a4452415453586888c5232bfb143fd716 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/stage/ObjectProducer.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/ObjectProducer.java @@ -15,8 +15,7 @@ ***************************************************************************/ package teetime.examples.throughput.methodcall.stage; -import teetime.examples.throughput.methodcall.Closure; -import teetime.examples.throughput.methodcall.ProducerStage; +import teetime.examples.throughput.methodcall.ConstructorClosure; import teetime.util.list.CommittableQueue; /** @@ -27,28 +26,32 @@ import teetime.util.list.CommittableQueue; public class ObjectProducer<T> extends ProducerStage<Void, T> { private long numInputObjects; - private Closure<Void, T> inputObjectCreator; + private ConstructorClosure<T> inputObjectCreator; /** * @since 1.10 */ - public ObjectProducer(final long numInputObjects, final Closure<Void, T> inputObjectCreator) { + public ObjectProducer(final long numInputObjects, final ConstructorClosure<T> inputObjectCreator) { this.numInputObjects = numInputObjects; this.inputObjectCreator = inputObjectCreator; } @Override public T execute(final Object element) { - if (this.numInputObjects == 0) { - this.setReschedulable(false); - return null; - } + // if (this.numInputObjects == 0) { + // this.setReschedulable(false); + // return null; + // } try { - // final T newObject = this.inputObjectCreator.call(); - final T newObject = null; + final T newObject = this.inputObjectCreator.create(); + // final T newObject = null; this.numInputObjects--; + if (this.numInputObjects == 0) { + this.setReschedulable(false); + } + return newObject; } catch (final Exception e) { throw new IllegalStateException(e); @@ -63,11 +66,11 @@ public class ObjectProducer<T> extends ProducerStage<Void, T> { this.numInputObjects = numInputObjects; } - public Closure<Void, T> getInputObjectCreator() { + public ConstructorClosure<T> getInputObjectCreator() { return this.inputObjectCreator; } - public void setInputObjectCreator(final Closure<Void, T> inputObjectCreator) { + public void setInputObjectCreator(final ConstructorClosure<T> inputObjectCreator) { this.inputObjectCreator = inputObjectCreator; } @@ -95,26 +98,23 @@ public class ObjectProducer<T> extends ProducerStage<Void, T> { @Override protected void execute5(final Void element) { + T newObject = null; + newObject = this.inputObjectCreator.create(); + this.numInputObjects--; + if (this.numInputObjects == 0) { this.setReschedulable(false); - return; + // this.getOutputPort().pipe.close(); } - // try { - T newObject = null; - newObject = this.inputObjectCreator.execute(null); - this.numInputObjects--; // System.out.println(this.getClass().getSimpleName() + ": sending " + this.numInputObjects); this.send(newObject); - // } catch (final Exception e) { - // throw new IllegalStateException(e); - // } } - @Override - public void onIsPipelineHead() { - // this.getOutputPort().pipe = null; // no performance increase - super.onIsPipelineHead(); - } + // @Override + // public void onIsPipelineHead() { + // // this.getOutputPort().pipe = null; // no performance increase + // super.onIsPipelineHead(); + // } } diff --git a/src/test/java/teetime/examples/throughput/methodcall/stage/Pipeline.java b/src/test/java/teetime/examples/throughput/methodcall/stage/Pipeline.java index 86e33fa985308a942033e07204a3a078666846f3..14a5ba46a8cbc28143c522804f95b8d8d3e2d260 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/stage/Pipeline.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/Pipeline.java @@ -63,23 +63,24 @@ public class Pipeline<I, O> implements StageWithPort<I, O> { @Override public void executeWithPorts() { - StageWithPort firstStage = this.stages[this.firstStageIndex]; + StageWithPort<?, ?> firstStage = this.stages[this.firstStageIndex]; firstStage.executeWithPorts(); this.updateRescheduable(firstStage); // this.setReschedulable(stage.isReschedulable()); } - private final void updateRescheduable(Stage<?, ?> stage) { - while (!stage.isReschedulable()) { + private final void updateRescheduable(final Stage<?, ?> stage) { + Stage<?, ?> currentStage = stage; + while (!currentStage.isReschedulable()) { this.firstStageIndex++; - stage = stage.next(); - if (stage == null) { // loop reaches the last stage + currentStage = currentStage.next(); + if (currentStage == null) { // loop reaches the last stage this.setReschedulable(false); this.cleanUp(); return; } - stage.onIsPipelineHead(); + currentStage.onIsPipelineHead(); // System.out.println("firstStageIndex: " + this.firstStageIndex + ", class:" + stage.getClass().getSimpleName()); } this.setReschedulable(true); diff --git a/src/test/java/teetime/examples/throughput/methodcall/ProducerStage.java b/src/test/java/teetime/examples/throughput/methodcall/stage/ProducerStage.java similarity index 81% rename from src/test/java/teetime/examples/throughput/methodcall/ProducerStage.java rename to src/test/java/teetime/examples/throughput/methodcall/stage/ProducerStage.java index 731075b1147402c7053b653b16c29280c9a54c7a..b87d04832b436cb153d0658bc73affc96037d12c 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/ProducerStage.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/ProducerStage.java @@ -1,6 +1,5 @@ -package teetime.examples.throughput.methodcall; +package teetime.examples.throughput.methodcall.stage; -import teetime.examples.throughput.methodcall.stage.AbstractStage; import teetime.util.list.CommittableQueue; public abstract class ProducerStage<I, O> extends AbstractStage<I, O> { @@ -15,7 +14,7 @@ public abstract class ProducerStage<I, O> extends AbstractStage<I, O> { boolean outputIsEmpty = outputElements.isEmpty(); if (outputIsEmpty) { - this.getOutputPort().pipe.close(); + this.getOutputPort().getPipe().close(); } return outputElements; diff --git a/src/test/java/teetime/examples/throughput/methodcall/stage/Relay.java b/src/test/java/teetime/examples/throughput/methodcall/stage/Relay.java index fe6bc87b9becefefeab6b821b79b34261d38ecb3..c0677872c691cb10b4e8a7432f187b08e8200dba 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/stage/Relay.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/Relay.java @@ -12,14 +12,12 @@ public class Relay<T> extends AbstractStage<T, T> { public void executeWithPorts() { T element = this.getInputPort().receive(); if (null == element) { - if (this.getInputPort().pipe.isClosed()) { + if (this.getInputPort().getPipe().isClosed()) { this.setReschedulable(false); - System.out.println("got end signal; pipe.size: " + this.getInputPort().pipe.size()); - return; + System.out.println("got end signal; pipe.size: " + this.getInputPort().getPipe().size()); } return; } - this.send(element); } @@ -31,7 +29,10 @@ public class Relay<T> extends AbstractStage<T, T> { @Override public void onIsPipelineHead() { - // do nothing + System.out.println("onIsPipelineHead"); + if (this.getInputPort().getPipe().isClosed()) { + this.setReschedulable(false); + } } @Override diff --git a/src/test/java/teetime/examples/throughput/methodcall/stage/Sink.java b/src/test/java/teetime/examples/throughput/methodcall/stage/Sink.java index 4b358384eac52e356abcc8082726d6b729f31bf3..9e68db8f4941a1e96f30d19ac753b3e73e3c310f 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/stage/Sink.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/Sink.java @@ -1,6 +1,5 @@ package teetime.examples.throughput.methodcall.stage; -import teetime.examples.throughput.methodcall.ConsumerStage; import teetime.util.list.CommittableQueue; public class Sink<T> extends ConsumerStage<T, T> { diff --git a/src/test/java/teetime/examples/throughput/methodcall/stage/StartTimestampFilter.java b/src/test/java/teetime/examples/throughput/methodcall/stage/StartTimestampFilter.java index fdcc6d44c062bc501698c440d5db48f59f73ebc9..da5b2c04c3a72168db50f25694c6195a5ee80906 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/stage/StartTimestampFilter.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/StartTimestampFilter.java @@ -16,7 +16,6 @@ package teetime.examples.throughput.methodcall.stage; import teetime.examples.throughput.TimestampObject; -import teetime.examples.throughput.methodcall.ConsumerStage; import teetime.util.list.CommittableQueue; /** diff --git a/src/test/java/teetime/examples/throughput/methodcall/stage/StopTimestampFilter.java b/src/test/java/teetime/examples/throughput/methodcall/stage/StopTimestampFilter.java index 0dfd5adced75c402b44fbc31635511bfba656e26..dd6691ca672274a5df8be82f22bec54d9b0263e5 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/stage/StopTimestampFilter.java +++ b/src/test/java/teetime/examples/throughput/methodcall/stage/StopTimestampFilter.java @@ -16,7 +16,6 @@ package teetime.examples.throughput.methodcall.stage; import teetime.examples.throughput.TimestampObject; -import teetime.examples.throughput.methodcall.ConsumerStage; import teetime.util.list.CommittableQueue; /**