From ea7dbff4cab42867fc2b4b62c6c0d485e594168c Mon Sep 17 00:00:00 2001 From: Nelson Tavares de Sousa <stu103017@mail.uni-kiel.de> Date: Mon, 13 Oct 2014 16:19:33 +0200 Subject: [PATCH] Added legacystages to re-enable test execution --- .settings/org.eclipse.core.resources.prefs | 1 - src/main/java/teetime/stage/NoopFilter.java | 2 +- .../experiment01/LegacyCollectorSink.java | 61 +++++++++++++++++ .../experiment01/LegacyNoopFilter.java | 29 ++++++++ .../experiment01/LegacyObjectProducer.java | 62 +++++++++++++++++ .../LegacyStartTimestampFilter.java | 32 +++++++++ .../LegacyStopTimestampFilter.java | 32 +++++++++ .../MethodCallThroughputAnalysis1.java | 66 +++++++++---------- 8 files changed, 250 insertions(+), 35 deletions(-) create mode 100644 src/performancetest/java/teetime/examples/experiment01/LegacyCollectorSink.java create mode 100644 src/performancetest/java/teetime/examples/experiment01/LegacyNoopFilter.java create mode 100644 src/performancetest/java/teetime/examples/experiment01/LegacyObjectProducer.java create mode 100644 src/performancetest/java/teetime/examples/experiment01/LegacyStartTimestampFilter.java create mode 100644 src/performancetest/java/teetime/examples/experiment01/LegacyStopTimestampFilter.java diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 29abf999..98960902 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,6 +1,5 @@ eclipse.preferences.version=1 encoding//src/main/java=UTF-8 encoding//src/main/resources=UTF-8 -encoding//src/test/java=UTF-8 encoding//src/test/resources=UTF-8 encoding/<project>=UTF-8 diff --git a/src/main/java/teetime/stage/NoopFilter.java b/src/main/java/teetime/stage/NoopFilter.java index 4a721152..aaef5e79 100644 --- a/src/main/java/teetime/stage/NoopFilter.java +++ b/src/main/java/teetime/stage/NoopFilter.java @@ -20,7 +20,7 @@ import teetime.framework.OutputPort; /** * @author Christian Wulf - * + * * @since 1.10 */ public class NoopFilter<T> extends ConsumerStage<T> { diff --git a/src/performancetest/java/teetime/examples/experiment01/LegacyCollectorSink.java b/src/performancetest/java/teetime/examples/experiment01/LegacyCollectorSink.java new file mode 100644 index 00000000..a87507ce --- /dev/null +++ b/src/performancetest/java/teetime/examples/experiment01/LegacyCollectorSink.java @@ -0,0 +1,61 @@ +/*************************************************************************** + * Copyright 2014 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ +package teetime.examples.experiment01; + +import java.util.List; + +/** + * @author Christian Wulf + * + * @since 1.10 + */ +public class LegacyCollectorSink<T> { + + // private final InputPort<T> inputPort = this.createInputPort(); + // + // public final InputPort<T> getInputPort() { + // return this.inputPort; + // } + + private final List<T> elements; + private final int threshold; + + public LegacyCollectorSink(final List<T> list, final int threshold) { + this.elements = list; + this.threshold = threshold; + } + + public LegacyCollectorSink(final List<T> list) { + this(list, 100000); + } + + public void onIsPipelineHead() { + System.out.println("size: " + this.elements.size()); + } + + protected void execute(final T element) { + this.elements.add(element); + + if ((this.elements.size() % this.threshold) == 0) { + System.out.println("size: " + this.elements.size()); + } + + // if (this.elements.size() > 90000) { + // // System.out.println("size > 90000: " + this.elements.size()); + // } + } + +} diff --git a/src/performancetest/java/teetime/examples/experiment01/LegacyNoopFilter.java b/src/performancetest/java/teetime/examples/experiment01/LegacyNoopFilter.java new file mode 100644 index 00000000..bc43446d --- /dev/null +++ b/src/performancetest/java/teetime/examples/experiment01/LegacyNoopFilter.java @@ -0,0 +1,29 @@ +/*************************************************************************** + * Copyright 2014 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ +package teetime.examples.experiment01; + +/** + * @author Christian Wulf + * + * @since 1.10 + */ +public class LegacyNoopFilter<T> { + + protected T execute(final T element) { + return element; + } + +} diff --git a/src/performancetest/java/teetime/examples/experiment01/LegacyObjectProducer.java b/src/performancetest/java/teetime/examples/experiment01/LegacyObjectProducer.java new file mode 100644 index 00000000..909537a3 --- /dev/null +++ b/src/performancetest/java/teetime/examples/experiment01/LegacyObjectProducer.java @@ -0,0 +1,62 @@ +/*************************************************************************** + * Copyright 2014 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ +package teetime.examples.experiment01; + +import teetime.util.ConstructorClosure; + +/** + * @author Christian Wulf + * + * @since 1.10 + */ +public class LegacyObjectProducer<T> { + + private long numInputObjects; + private ConstructorClosure<T> inputObjectCreator; + + /** + * @since 1.10 + */ + public LegacyObjectProducer(final long numInputObjects, final ConstructorClosure<T> inputObjectCreator) { + this.numInputObjects = numInputObjects; + this.inputObjectCreator = inputObjectCreator; + } + + public long getNumInputObjects() { + return this.numInputObjects; + } + + public void setNumInputObjects(final long numInputObjects) { + this.numInputObjects = numInputObjects; + } + + public ConstructorClosure<T> getInputObjectCreator() { + return this.inputObjectCreator; + } + + public void setInputObjectCreator(final ConstructorClosure<T> inputObjectCreator) { + this.inputObjectCreator = inputObjectCreator; + } + + protected T execute() { + T newObject = this.inputObjectCreator.create(); + this.numInputObjects--; + + return newObject; + + } + +} diff --git a/src/performancetest/java/teetime/examples/experiment01/LegacyStartTimestampFilter.java b/src/performancetest/java/teetime/examples/experiment01/LegacyStartTimestampFilter.java new file mode 100644 index 00000000..4a38bce2 --- /dev/null +++ b/src/performancetest/java/teetime/examples/experiment01/LegacyStartTimestampFilter.java @@ -0,0 +1,32 @@ +/*************************************************************************** + * Copyright 2014 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ +package teetime.examples.experiment01; + +import teetime.util.TimestampObject; + +/** + * @author Christian Wulf + * + * @since 1.10 + */ +public class LegacyStartTimestampFilter { + + protected TimestampObject execute(final TimestampObject element) { + element.setStartTimestamp(System.nanoTime()); + return element; + } + +} diff --git a/src/performancetest/java/teetime/examples/experiment01/LegacyStopTimestampFilter.java b/src/performancetest/java/teetime/examples/experiment01/LegacyStopTimestampFilter.java new file mode 100644 index 00000000..6a867a36 --- /dev/null +++ b/src/performancetest/java/teetime/examples/experiment01/LegacyStopTimestampFilter.java @@ -0,0 +1,32 @@ +/*************************************************************************** + * Copyright 2014 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ +package teetime.examples.experiment01; + +import teetime.util.TimestampObject; + +/** + * @author Christian Wulf + * + * @since 1.10 + */ +public class LegacyStopTimestampFilter { + + protected TimestampObject execute(final TimestampObject element) { + element.setStopTimestamp(System.nanoTime()); + return element; + } + +} diff --git a/src/performancetest/java/teetime/examples/experiment01/MethodCallThroughputAnalysis1.java b/src/performancetest/java/teetime/examples/experiment01/MethodCallThroughputAnalysis1.java index f84be673..c618f559 100644 --- a/src/performancetest/java/teetime/examples/experiment01/MethodCallThroughputAnalysis1.java +++ b/src/performancetest/java/teetime/examples/experiment01/MethodCallThroughputAnalysis1.java @@ -37,45 +37,45 @@ public class MethodCallThroughputAnalysis1 extends OldAnalysis { @Override public void init() { super.init(); - // this.runnable = this.buildPipeline(); + this.runnable = this.buildPipeline(); } /** * @param numNoopFilters * @since 1.10 */ - // private Runnable buildPipeline() { - // @SuppressWarnings("unchecked") - // final NoopFilter<TimestampObject>[] noopFilters = new NoopFilter[this.numNoopFilters]; - // // create stages - // final ObjectProducer<TimestampObject> objectProducer = new ObjectProducer<TimestampObject>(this.numInputObjects, this.inputObjectCreator); - // final StartTimestampFilter startTimestampFilter = new StartTimestampFilter(); - // for (int i = 0; i < noopFilters.length; i++) { - // noopFilters[i] = new NoopFilter<TimestampObject>(); - // } - // final StopTimestampFilter stopTimestampFilter = new StopTimestampFilter(); - // final CollectorSink<TimestampObject> collectorSink = new CollectorSink<TimestampObject>(this.timestampObjects); - // - // final Runnable runnable = new Runnable() { - // @Override - // public void run() { - // while (true) { - // TimestampObject object = objectProducer.execute(null); - // if (object == null) { - // return; - // } - // - // object = startTimestampFilter.execute(object); - // for (final NoopFilter<TimestampObject> noopFilter : noopFilters) { - // object = noopFilter.execute(object); - // } - // object = stopTimestampFilter.execute(object); - // collectorSink.execute(object); - // } - // } - // }; - // return runnable; - // } + private Runnable buildPipeline() { + @SuppressWarnings("unchecked") + final LegacyNoopFilter<TimestampObject>[] noopFilters = new LegacyNoopFilter[this.numNoopFilters]; + // create stages + final LegacyObjectProducer<TimestampObject> objectProducer = new LegacyObjectProducer<TimestampObject>(this.numInputObjects, this.inputObjectCreator); + final LegacyStartTimestampFilter startTimestampFilter = new LegacyStartTimestampFilter(); + for (int i = 0; i < noopFilters.length; i++) { + noopFilters[i] = new LegacyNoopFilter<TimestampObject>(); + } + final LegacyStopTimestampFilter stopTimestampFilter = new LegacyStopTimestampFilter(); + final LegacyCollectorSink<TimestampObject> collectorSink = new LegacyCollectorSink<TimestampObject>(this.timestampObjects); + + final Runnable runnable = new Runnable() { + @Override + public void run() { + while (true) { + TimestampObject object = objectProducer.execute(); + if (object == null) { + return; + } + + object = startTimestampFilter.execute(object); + for (final LegacyNoopFilter<TimestampObject> noopFilter : noopFilters) { + object = noopFilter.execute(object); + } + object = stopTimestampFilter.execute(object); + collectorSink.execute(object); + } + } + }; + return runnable; + } @Override public void start() { -- GitLab