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

added performance comparison for methodcall variant

parent 35142f0f
No related branches found
No related tags found
No related merge requests found
Showing
with 133 additions and 41 deletions
...@@ -70,7 +70,7 @@ public class StatisticsUtil { ...@@ -70,7 +70,7 @@ public class StatisticsUtil {
performanceResult.avgDurInNs = avgDurInNs; performanceResult.avgDurInNs = avgDurInNs;
printQuintiles(quintileValues); System.out.println(getQuantilesString(quintileValues));
final long confidenceWidthInNs = StatisticsUtil.calculateConfidenceWidth(sortedDurationsInNs, avgDurInNs); final long confidenceWidthInNs = StatisticsUtil.calculateConfidenceWidth(sortedDurationsInNs, avgDurInNs);
...@@ -83,10 +83,14 @@ public class StatisticsUtil { ...@@ -83,10 +83,14 @@ public class StatisticsUtil {
return performanceResult; return performanceResult;
} }
public static void printQuintiles(final Map<Double, Long> quintileValues) { public static String getQuantilesString(final Map<Double, Long> quantilesValues) {
for (final Entry<Double, Long> entry : quintileValues.entrySet()) { StringBuilder builder = new StringBuilder();
System.out.println((entry.getKey() * 100) + " % : " + TimeUnit.NANOSECONDS.toNanos(entry.getValue()) + " ns"); for (final Entry<Double, Long> entry : quantilesValues.entrySet()) {
String quantile = (entry.getKey() * 100) + " % : " + TimeUnit.NANOSECONDS.toNanos(entry.getValue()) + " ns";
builder.append(quantile);
builder.append("\n");
} }
return builder.toString();
} }
public static long calculateConfidenceWidth(final List<Long> durations, final long avgDurInNs) { public static long calculateConfidenceWidth(final List<Long> durations, final long avgDurInNs) {
......
...@@ -28,9 +28,9 @@ public class CommittableResizableArrayQueue<T> implements CommittableQueue<T> { ...@@ -28,9 +28,9 @@ public class CommittableResizableArrayQueue<T> implements CommittableQueue<T> {
@Override @Override
public void addToTailUncommitted(final T element) { public void addToTailUncommitted(final T element) {
// if (this.lastFreeIndexUncommitted == this.capacity()) { // TODO uncomment if (this.lastFreeIndexUncommitted == this.capacity()) {
// this.grow(); this.grow();
// } }
this.put(this.lastFreeIndexUncommitted++, element); this.put(this.lastFreeIndexUncommitted++, element);
} }
......
...@@ -46,12 +46,16 @@ public class Pipeline<I, O> implements Stage<I, O> { ...@@ -46,12 +46,16 @@ public class Pipeline<I, O> implements Stage<I, O> {
// below is faster than above (probably because of the instantiation of a list iterator in each (!) execution) // below is faster than above (probably because of the instantiation of a list iterator in each (!) execution)
CommittableQueue queue = elements; CommittableQueue queue = elements;
// for (int i = this.startIndex; i < this.stages.length; i++) { for (int i = 0; i < this.stages.length; i++) {
// Stage<?, ?> stage = this.stages[i]; Stage<?, ?> stage = this.stages[i];
// queue = stage.execute2(queue); queue = stage.execute2(queue);
// } if (queue.isEmpty()) {
break;
}
}
// queue = this.firstStage.execute2(elements);
queue = this.firstStage.execute2(elements);
this.setReschedulable(this.firstStage.isReschedulable()); this.setReschedulable(this.firstStage.isReschedulable());
return queue; return queue;
......
...@@ -36,6 +36,7 @@ public class CollectorSink<T> extends ConsumerStage<T, Object> { ...@@ -36,6 +36,7 @@ public class CollectorSink<T> extends ConsumerStage<T, Object> {
this.elements = list; this.elements = list;
} }
@SuppressWarnings("unchecked")
@Override @Override
public Object execute(final Object element) { public Object execute(final Object element) {
this.elements.add((T) element); this.elements.add((T) element);
...@@ -57,10 +58,6 @@ public class CollectorSink<T> extends ConsumerStage<T, Object> { ...@@ -57,10 +58,6 @@ public class CollectorSink<T> extends ConsumerStage<T, Object> {
if ((this.elements.size() % THRESHOLD) == 0) { if ((this.elements.size() % THRESHOLD) == 0) {
System.out.println("size: " + this.elements.size()); System.out.println("size: " + this.elements.size());
} }
if (this.elements.size() > 90000) {
// System.out.println("size > 90000: " + this.elements.size());
}
} }
} }
...@@ -34,8 +34,7 @@ public class NoopFilter<T> extends ConsumerStage<T, T> { ...@@ -34,8 +34,7 @@ public class NoopFilter<T> extends ConsumerStage<T, T> {
@Override @Override
protected void execute4(final CommittableQueue<T> elements) { protected void execute4(final CommittableQueue<T> elements) {
T element = elements.removeFromHead(); T element = elements.removeFromHead();
// this.send(element); // "send" calls the next stage and so on this.send(element); // TODO ? "send" calls the next stage and so on
throw new IllegalStateException();
} }
} }
...@@ -72,15 +72,16 @@ public class ObjectProducer<T> extends ProducerStage<Void, T> { ...@@ -72,15 +72,16 @@ public class ObjectProducer<T> extends ProducerStage<Void, T> {
@Override @Override
protected void execute4(final CommittableQueue<Void> elements) { protected void execute4(final CommittableQueue<Void> elements) {
T newObject = null;
newObject = this.inputObjectCreator.create();
this.numInputObjects--;
if (this.numInputObjects == 0) { if (this.numInputObjects == 0) {
this.setReschedulable(false); this.setReschedulable(false);
// this.getOutputPort().pipe.close(); // this.getOutputPort().pipe.close();
return;
} }
T newObject = null;
newObject = this.inputObjectCreator.create();
this.numInputObjects--;
// System.out.println(this.getClass().getSimpleName() + ": sending " + this.numInputObjects); // System.out.println(this.getClass().getSimpleName() + ": sending " + this.numInputObjects);
this.send(newObject); this.send(newObject);
// throw new IllegalStateException(); // throw new IllegalStateException();
......
...@@ -37,7 +37,6 @@ public class StartTimestampFilter extends ConsumerStage<TimestampObject, Timesta ...@@ -37,7 +37,6 @@ public class StartTimestampFilter extends ConsumerStage<TimestampObject, Timesta
protected void execute4(final CommittableQueue<TimestampObject> elements) { protected void execute4(final CommittableQueue<TimestampObject> elements) {
TimestampObject element = elements.removeFromHead(); TimestampObject element = elements.removeFromHead();
element.setStartTimestamp(System.nanoTime()); element.setStartTimestamp(System.nanoTime());
// this.send(element); this.send(element);
throw new IllegalStateException();
} }
} }
...@@ -33,19 +33,11 @@ public class StopTimestampFilter extends ConsumerStage<TimestampObject, Timestam ...@@ -33,19 +33,11 @@ public class StopTimestampFilter extends ConsumerStage<TimestampObject, Timestam
return timestampObject; return timestampObject;
} }
// @Override
// public void execute3() {
// TimestampObject element = this.getInputPort().receive();
// element.setStopTimestamp(System.nanoTime());
// // this.getOutputPort().send(element);
// }
@Override @Override
protected void execute4(final CommittableQueue<TimestampObject> elements) { protected void execute4(final CommittableQueue<TimestampObject> elements) {
TimestampObject element = elements.removeFromHead(); TimestampObject element = elements.removeFromHead();
element.setStopTimestamp(System.nanoTime()); element.setStopTimestamp(System.nanoTime());
// this.send(element); this.send(element);
throw new IllegalStateException();
} }
} }
...@@ -24,7 +24,7 @@ public class StopWatchTest { ...@@ -24,7 +24,7 @@ public class StopWatchTest {
} }
Map<Double, Long> quintiles = StatisticsUtil.calculateQuintiles(durationsInNs); Map<Double, Long> quintiles = StatisticsUtil.calculateQuintiles(durationsInNs);
StatisticsUtil.printQuintiles(quintiles); StatisticsUtil.getQuantilesString(quintiles);
} }
public static BigInteger fib(final BigInteger n) { public static BigInteger fib(final BigInteger n) {
......
package teetime.variant.methodcall.examples;
import static org.junit.Assert.assertEquals;
import java.util.Map;
import java.util.Map.Entry;
import org.junit.AfterClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import teetime.variant.methodcall.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test;
import teetime.variant.methodcall.examples.experiment02.MethodCallThoughputTimestampAnalysis2Test;
import teetime.variant.methodcall.examples.experiment03.MethodCallThoughputTimestampAnalysis3Test;
import teetime.variant.methodcall.examples.experiment04.MethodCallThoughputTimestampAnalysis4Test;
import teetime.variant.methodcall.examples.experiment05.MethodCallThoughputTimestampAnalysis5Test;
import teetime.variant.methodcall.examples.experiment06.MethodCallThoughputTimestampAnalysis6Test;
import teetime.variant.methodcall.examples.experiment07.MethodCallThoughputTimestampAnalysis7Test;
import teetime.variant.methodcall.examples.experiment08.MethodCallThoughputTimestampAnalysis8Test;
import teetime.variant.methodcall.examples.experiment12.MethodCallThoughputTimestampAnalysis12Test;
import teetime.variant.methodcall.examples.experiment13.MethodCallThoughputTimestampAnalysis13Test;
import test.PerformanceResult;
import test.PerformanceTest;
@RunWith(Suite.class)
@SuiteClasses({
MethodCallThoughputTimestampAnalysis1Test.class,
MethodCallThoughputTimestampAnalysis2Test.class,
MethodCallThoughputTimestampAnalysis3Test.class,
MethodCallThoughputTimestampAnalysis4Test.class,
MethodCallThoughputTimestampAnalysis5Test.class,
MethodCallThoughputTimestampAnalysis6Test.class,
MethodCallThoughputTimestampAnalysis7Test.class,
MethodCallThoughputTimestampAnalysis8Test.class,
MethodCallThoughputTimestampAnalysis12Test.class,
MethodCallThoughputTimestampAnalysis13Test.class,
})
public class AllTests {
@AfterClass
public static void doYourOneTimeTeardown() {
Map<String, PerformanceResult> performanceResults = PerformanceTest.measurementRepository.performanceResults;
for (Entry<String, PerformanceResult> entry : performanceResults.entrySet()) {
System.out.println("---> " + entry.getKey() + "\n" + entry.getValue());
}
PerformanceResult test1 = performanceResults
.get("testWithManyObjects(teetime.variant.methodcall.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test)");
PerformanceResult test4 = performanceResults
.get("testWithManyObjects(teetime.variant.methodcall.examples.experiment04.MethodCallThoughputTimestampAnalysis4Test)");
PerformanceResult test7 = performanceResults
.get("testWithManyObjects(teetime.variant.methodcall.examples.experiment07.MethodCallThoughputTimestampAnalysis7Test)");
PerformanceResult test3 = performanceResults
.get("testWithManyObjects(teetime.variant.methodcall.examples.experiment03.MethodCallThoughputTimestampAnalysis3Test)");
PerformanceResult test8 = performanceResults
.get("testWithManyObjects(teetime.variant.methodcall.examples.experiment08.MethodCallThoughputTimestampAnalysis8Test)");
PerformanceResult test12 = performanceResults
.get("testWithManyObjects(teetime.variant.methodcall.examples.experiment12.MethodCallThoughputTimestampAnalysis12Test)");
PerformanceResult test13 = performanceResults
.get("testWithManyObjects(teetime.variant.methodcall.examples.experiment13.MethodCallThoughputTimestampAnalysis13Test)");
PerformanceResult test5 = performanceResults
.get("testWithManyObjects(teetime.variant.methodcall.examples.experiment05.MethodCallThoughputTimestampAnalysis5Test)");
PerformanceResult test2 = performanceResults
.get("testWithManyObjects(teetime.variant.methodcall.examples.experiment02.MethodCallThoughputTimestampAnalysis2Test)");
PerformanceResult test6 = performanceResults
.get("testWithManyObjects(teetime.variant.methodcall.examples.experiment06.MethodCallThoughputTimestampAnalysis6Test)");
assertEquals(1, (double) test4.quantiles.get(0.5) / test1.quantiles.get(0.5), 0.1);
assertEquals(2, (double) test7.quantiles.get(0.5) / test1.quantiles.get(0.5), 0.1);
assertEquals(3, (double) test3.quantiles.get(0.5) / test1.quantiles.get(0.5), 0.1);
assertEquals(3, (double) test8.quantiles.get(0.5) / test1.quantiles.get(0.5), 0.1);
assertEquals(7, (double) test12.quantiles.get(0.5) / test1.quantiles.get(0.5), 0.1);
assertEquals(7, (double) test13.quantiles.get(0.5) / test1.quantiles.get(0.5), 0.1);
assertEquals(9, (double) test5.quantiles.get(0.5) / test1.quantiles.get(0.5), 0.1);
assertEquals(17, (double) test2.quantiles.get(0.5) / test1.quantiles.get(0.5), 0.1);
assertEquals(59, (double) test6.quantiles.get(0.5) / test1.quantiles.get(0.5), 1.1);
}
}
...@@ -28,9 +28,6 @@ import test.PerformanceTest; ...@@ -28,9 +28,6 @@ import test.PerformanceTest;
*/ */
public class MethodCallThoughputTimestampAnalysis2Test extends PerformanceTest { public class MethodCallThoughputTimestampAnalysis2Test extends PerformanceTest {
// 500 times faster than our new framework
// TODO check why
@Test @Test
public void testWithManyObjects() { public void testWithManyObjects() {
System.out.println("Testing teetime (mc) with NUM_OBJECTS_TO_CREATE=" + NUM_OBJECTS_TO_CREATE + ", NUM_NOOP_FILTERS=" System.out.println("Testing teetime (mc) with NUM_OBJECTS_TO_CREATE=" + NUM_OBJECTS_TO_CREATE + ", NUM_NOOP_FILTERS="
......
...@@ -77,10 +77,8 @@ public class MethodCallThroughputAnalysis2 extends Analysis { ...@@ -77,10 +77,8 @@ public class MethodCallThroughputAnalysis2 extends Analysis {
@Override @Override
public void run() { public void run() {
CommittableQueue<Void> inputQueue = new CommittableResizableArrayQueue<Void>(null, 0); CommittableQueue<Void> inputQueue = new CommittableResizableArrayQueue<Void>(null, 0);
CommittableQueue<Object> outputQueue = new CommittableResizableArrayQueue<Object>(null, 0);
do { do {
outputQueue = pipeline.execute2(inputQueue); pipeline.execute2(inputQueue);
} while (pipeline.isReschedulable()); } while (pipeline.isReschedulable());
} }
}; };
......
...@@ -2,6 +2,8 @@ package test; ...@@ -2,6 +2,8 @@ package test;
import java.util.Map; import java.util.Map;
import teetime.util.StatisticsUtil;
public class PerformanceResult { public class PerformanceResult {
public long sumInNs; public long sumInNs;
...@@ -9,4 +11,23 @@ public class PerformanceResult { ...@@ -9,4 +11,23 @@ public class PerformanceResult {
public long avgDurInNs; public long avgDurInNs;
public long confidenceWidthInNs; public long confidenceWidthInNs;
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("sumInNs: ");
stringBuilder.append(this.sumInNs);
stringBuilder.append("\n");
stringBuilder.append("avgDurInNs: ");
stringBuilder.append(this.avgDurInNs);
stringBuilder.append("\n");
stringBuilder.append("confidenceWidthInNs: ");
stringBuilder.append(this.confidenceWidthInNs);
stringBuilder.append("\n");
stringBuilder.append(StatisticsUtil.getQuantilesString(this.quantiles));
return stringBuilder.toString();
}
} }
...@@ -21,7 +21,7 @@ public abstract class PerformanceTest { ...@@ -21,7 +21,7 @@ public abstract class PerformanceTest {
protected static final int NUM_OBJECTS_TO_CREATE = 100000; protected static final int NUM_OBJECTS_TO_CREATE = 100000;
protected static final int NUM_NOOP_FILTERS = 800; protected static final int NUM_NOOP_FILTERS = 800;
private static MeasurementRepository measurementRepository = new MeasurementRepository(); public static final MeasurementRepository measurementRepository = new MeasurementRepository();
private Description description; private Description description;
......
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