From 8baba9bb7872296dbd8fb1e4b0f12770beec3492 Mon Sep 17 00:00:00 2001 From: Christian Wulf <chw@informatik.uni-kiel.de> Date: Wed, 18 Jun 2014 19:26:41 +0200 Subject: [PATCH] fixed errors --- .checkstyle | 2 +- conf/cs-conf.xml | 4 +- ...dCallThoughputTimestampAnalysis10Test.java | 6 +-- ...dCallThoughputTimestampAnalysis11Test.java | 6 +-- ...dCallThoughputTimestampAnalysis12Test.java | 6 +-- ...dCallThoughputTimestampAnalysis13Test.java | 6 +-- ...dCallThoughputTimestampAnalysis14Test.java | 6 +-- ...dCallThoughputTimestampAnalysis15Test.java | 6 +-- ...dCallThoughputTimestampAnalysis16Test.java | 6 +-- ...dCallThoughputTimestampAnalysis17Test.java | 6 +-- ...odCallThoughputTimestampAnalysis1Test.java | 6 +-- ...odCallThoughputTimestampAnalysis2Test.java | 6 +-- ...odCallThoughputTimestampAnalysis3Test.java | 6 +-- ...odCallThoughputTimestampAnalysis4Test.java | 6 +-- ...odCallThoughputTimestampAnalysis5Test.java | 6 +-- ...odCallThoughputTimestampAnalysis6Test.java | 6 +-- ...odCallThoughputTimestampAnalysis7Test.java | 6 +-- ...odCallThoughputTimestampAnalysis8Test.java | 6 +-- ...odCallThoughputTimestampAnalysis9Test.java | 6 +-- .../throughput/methodcall/Closure.java | 6 --- .../methodcall/ConstructorClosure.java | 8 +++ .../throughput/methodcall/InputPort.java | 10 +++- .../MethodCallThroughputAnalysis1.java | 5 +- .../MethodCallThroughputAnalysis10.java | 5 +- .../MethodCallThroughputAnalysis11.java | 16 +++--- .../MethodCallThroughputAnalysis12.java | 5 +- .../MethodCallThroughputAnalysis13.java | 5 +- .../MethodCallThroughputAnalysis14.java | 5 +- .../MethodCallThroughputAnalysis15.java | 25 ++-------- .../MethodCallThroughputAnalysis16.java | 6 +-- .../MethodCallThroughputAnalysis17.java | 26 ++++++---- .../MethodCallThroughputAnalysis2.java | 7 ++- .../MethodCallThroughputAnalysis3.java | 7 ++- .../MethodCallThroughputAnalysis4.java | 7 ++- .../MethodCallThroughputAnalysis5.java | 7 ++- .../MethodCallThroughputAnalysis6.java | 7 ++- .../MethodCallThroughputAnalysis7.java | 7 ++- .../MethodCallThroughputAnalysis8.java | 7 ++- .../MethodCallThroughputAnalysis9.java | 7 ++- .../methodcall/OrderedGrowableArrayPipe.java | 4 +- .../methodcall/OrderedGrowablePipe.java | 4 +- .../throughput/methodcall/OutputPort.java | 10 +++- .../examples/throughput/methodcall/Pipe.java | 4 +- .../methodcall/SingleElementPipe.java | 4 +- .../throughput/methodcall/SpScPipe.java | 4 +- .../methodcall/UnorderedGrowablePipe.java | 7 ++- .../methodcall/stage/AbstractStage.java | 7 +-- .../throughput/methodcall/stage/Clock.java | 1 - .../methodcall/stage/CollectorSink.java | 1 - .../methodcall/{ => stage}/ConsumerStage.java | 5 +- .../throughput/methodcall/stage/Delay.java | 2 +- .../methodcall/stage/Distributor.java | 16 ++++-- .../throughput/methodcall/stage/EndStage.java | 4 +- .../methodcall/stage/NoopFilter.java | 1 - .../methodcall/stage/ObjectProducer.java | 50 +++++++++---------- .../throughput/methodcall/stage/Pipeline.java | 13 ++--- .../methodcall/{ => stage}/ProducerStage.java | 5 +- .../throughput/methodcall/stage/Relay.java | 11 ++-- .../throughput/methodcall/stage/Sink.java | 1 - .../stage/StartTimestampFilter.java | 1 - .../methodcall/stage/StopTimestampFilter.java | 1 - 61 files changed, 222 insertions(+), 220 deletions(-) delete mode 100644 src/test/java/teetime/examples/throughput/methodcall/Closure.java create mode 100644 src/test/java/teetime/examples/throughput/methodcall/ConstructorClosure.java rename src/test/java/teetime/examples/throughput/methodcall/{ => stage}/ConsumerStage.java (83%) rename src/test/java/teetime/examples/throughput/methodcall/{ => stage}/ProducerStage.java (81%) diff --git a/.checkstyle b/.checkstyle index fd0e0101..a5f3e707 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 4d22e9d8..950501a5 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 1329d235..53802779 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 6a195b28..0191eb46 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 fb060993..81b7d6d8 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 fe1aaf13..03f694b4 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 67579159..70dfb915 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 fec03aa9..3553ea92 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 83325754..28734546 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 23964a05..b5dababf 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 9ed23342..47f9be43 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 07086663..45564115 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 6b4d7993..ee6947e8 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 535ca153..68f60772 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 5288049d..106e5b0b 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 4a7923f3..72c788c7 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 ef511bb5..bb544218 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 8a9b34ff..902155fb 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 4c41d199..5f781ada 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 f208c9a1..00000000 --- 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 00000000..9577fef6 --- /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 3da7d22b..02e69fd4 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 e9955067..b8933462 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 0ca0b26f..cd520670 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 9e6e763c..ca5ab5d2 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 afa57c29..2bc90dd6 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 dd1e6d56..81f72d7c 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 7dbf5690..9eb9f521 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 9946f542..c0bf7568 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 d3a2d10f..e58e1b93 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 ec9b620c..81da2950 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 3ff1ec4d..55f565cb 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 e40e3bb5..e9876786 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 f60c0838..e543ad26 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 ae54e4b4..4c59946b 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 ee056d28..4d3a33be 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 ac22b177..8b5ac8a9 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 5de987ca..30ba261b 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 257e213d..075bb788 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 ad653410..7f5aea2f 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 62f7bf9a..645cd004 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 19f2bc5e..837d67eb 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 e6e9c00e..0e6081b0 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 ab6a33de..44409ddb 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 37380ef6..b545cf38 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 1f9032ce..87b94df6 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 50bb9f92..0e7614b2 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 0381e758..f6d8fe3d 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 2dfce136..481d1272 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 710b6afe..e9db16c8 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 b1c59077..5995c457 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 628dd181..322159b5 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 23439c43..c5a501d5 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 7fdf98b2..98413fbb 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 86ee0606..9db2918a 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 86e33fa9..14a5ba46 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 731075b1..b87d0483 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 fe6bc87b..c0677872 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 4b358384..9e68db8f 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 fdcc6d44..da5b2c04 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 0dfd5adc..dd6691ca 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; /** -- GitLab