Skip to content
Snippets Groups Projects
Commit 5588e6a7 authored by Christian Wulf's avatar Christian Wulf
Browse files

added speedup measurement in analysis 16 (2+1->2.0, 4+1->3.5)

parent 8baba9bb
No related branches found
No related tags found
No related merge requests found
......@@ -107,4 +107,5 @@ public class StatisticsUtil {
}
return quintileValues;
}
}
......@@ -44,12 +44,20 @@ public class MethodCallThoughputTimestampAnalysis16Test {
}
@Test
public void testWithManyObjects() {
public void testWithManyObjectsAnd1Thread() {
long durationWith1Thread = this.performAnalysis(1, -1);
this.performAnalysis(2, durationWith1Thread);
this.performAnalysis(4, durationWith1Thread);
// this.performAnalysis(8, stopWatch.getDurationInNs());
}
private long performAnalysis(final int numThreads, final long durationWith1Thread) {
System.out.println("Testing teetime (mc) with NUM_OBJECTS_TO_CREATE=" + NUM_OBJECTS_TO_CREATE + ", NUM_NOOP_FILTERS="
+ NUM_NOOP_FILTERS + "...");
final StopWatch stopWatch = new StopWatch();
final MethodCallThroughputAnalysis16 analysis = new MethodCallThroughputAnalysis16();
analysis.setNumWorkerThreads(numThreads);
analysis.setNumNoopFilters(NUM_NOOP_FILTERS);
analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() {
@Override
......@@ -69,11 +77,18 @@ public class MethodCallThoughputTimestampAnalysis16Test {
List<TimestampObject> timestampObjects = ListUtil.merge(analysis.getTimestampObjectsList());
StatisticsUtil.printStatistics(stopWatch.getDurationInNs(), timestampObjects);
if (durationWith1Thread != -1) {
double speedup = (double) durationWith1Thread / stopWatch.getDurationInNs();
System.out.println("Speedup (from 1 to " + numThreads + " threads): " + String.format("%.2f", speedup));
}
return stopWatch.getDurationInNs();
}
public static void main(final String[] args) {
MethodCallThoughputTimestampAnalysis16Test test = new MethodCallThoughputTimestampAnalysis16Test();
test.before();
test.testWithManyObjects();
test.testWithManyObjectsAnd1Thread();
}
}
......@@ -49,6 +49,8 @@ public class MethodCallThoughputTimestampAnalysis17Test {
+ NUM_NOOP_FILTERS + "...");
final StopWatch stopWatch = new StopWatch();
// int count = 10;
// while (count-- > 0) {
final MethodCallThroughputAnalysis17 analysis = new MethodCallThroughputAnalysis17();
analysis.setNumNoopFilters(NUM_NOOP_FILTERS);
analysis.setInput(NUM_OBJECTS_TO_CREATE, new ConstructorClosure<TimestampObject>() {
......@@ -70,5 +72,6 @@ public class MethodCallThoughputTimestampAnalysis17Test {
List<TimestampObject> timestampObjects = ListUtil.merge(analysis.getTimestampObjectsList());
StatisticsUtil.printStatistics(stopWatch.getDurationInNs(), timestampObjects);
// }
}
}
......@@ -50,15 +50,17 @@ public class MethodCallThroughputAnalysis16 extends Analysis {
private Thread[] workerThreads;
private int numWorkerThreads;
@Override
public void init() {
super.init();
Pipeline<Void, TimestampObject> producerPipeline = this.buildProducerPipeline(this.numInputObjects, this.inputObjectCreator);
this.producerThread = new Thread(new RunnableStage(producerPipeline));
int numWorkerThreads = Math.min(NUM_WORKER_THREADS, 1); // only for testing purpose
this.numWorkerThreads = Math.min(NUM_WORKER_THREADS, this.numWorkerThreads);
this.workerThreads = new Thread[numWorkerThreads];
this.workerThreads = new Thread[this.numWorkerThreads];
for (int i = 0; i < this.workerThreads.length; i++) {
List<TimestampObject> resultList = new ArrayList<TimestampObject>(this.numInputObjects);
this.timestampObjectsList.add(resultList);
......@@ -67,14 +69,14 @@ public class MethodCallThroughputAnalysis16 extends Analysis {
this.workerThreads[i] = new Thread(workerRunnable);
}
this.producerThread.start();
try {
this.producerThread.join();
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// this.producerThread.start();
//
// try {
// this.producerThread.join();
// } catch (InterruptedException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
}
private Pipeline<Void, TimestampObject> buildProducerPipeline(final int numInputObjects, final ConstructorClosure<TimestampObject> inputObjectCreator) {
......@@ -131,10 +133,19 @@ public class MethodCallThroughputAnalysis16 extends Analysis {
public void start() {
super.start();
this.producerThread.start();
for (Thread workerThread : this.workerThreads) {
workerThread.start();
}
try {
this.producerThread.join();
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
for (Thread workerThread : this.workerThreads) {
workerThread.join();
......@@ -162,4 +173,12 @@ public class MethodCallThroughputAnalysis16 extends Analysis {
return this.timestampObjectsList;
}
public int getNumWorkerThreads() {
return this.numWorkerThreads;
}
public void setNumWorkerThreads(final int numWorkerThreads) {
this.numWorkerThreads = numWorkerThreads;
}
}
......@@ -31,7 +31,6 @@ 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
......@@ -90,12 +89,6 @@ public class MethodCallThroughputAnalysis17 extends Analysis {
// this.producerThread.run();
new RunnableStage(producerPipeline).run();
// Pipeline<Void, TimestampObject> stage = producerPipeline;
// stage.onStart();
// do {
// stage.executeWithPorts();
// } while (stage.isReschedulable());
// try {
// this.producerThread.join();
// } catch (InterruptedException e1) {
......@@ -103,13 +96,6 @@ public class MethodCallThroughputAnalysis17 extends Analysis {
// e1.printStackTrace();
// }
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
super.init();
}
......@@ -186,11 +172,8 @@ 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) {
......@@ -205,8 +188,6 @@ 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 ConstructorClosure<TimestampObject> inputObjectCreator) {
......
......@@ -9,6 +9,8 @@ import teetime.util.list.CommittableQueue;
public final class Distributor<T> extends AbstractStage<T, T> {
// TODO do not inherit from AbstractStage since it provides the default output port that is unnecessary for the distributor
private final List<OutputPort<T>> outputPortList = new ArrayList<OutputPort<T>>();
private OutputPort<T>[] outputPorts;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment