diff --git a/src/main/java/teetime/util/StatisticsUtil.java b/src/main/java/teetime/util/StatisticsUtil.java index 00e2b16fc696d7d3661a6722a8e3db95bf739efb..cd0e3d4340c5244b7e1be388127f27a5f09d00b2 100644 --- a/src/main/java/teetime/util/StatisticsUtil.java +++ b/src/main/java/teetime/util/StatisticsUtil.java @@ -27,7 +27,7 @@ import teetime.examples.throughput.TimestampObject; /** * @author Christian Wulf - * + * * @since 1.10 */ public class StatisticsUtil { @@ -72,7 +72,7 @@ public class StatisticsUtil { public static void printQuintiles(final Map<Double, Long> quintileValues) { for (final Entry<Double, Long> entry : quintileValues.entrySet()) { - System.out.println((entry.getKey() * 100) + " % : " + TimeUnit.NANOSECONDS.toMicros(entry.getValue()) + " µs"); + System.out.println((entry.getKey() * 100) + " % : " + TimeUnit.NANOSECONDS.toNanos(entry.getValue()) + " ns"); } } diff --git a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis7Test.java b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis7Test.java index 7d816c11d38d3d96a128b669b6dcc6a6231ddaeb..ef511bb5a1f9a66733ed574e4125b7984082a6e5 100644 --- a/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis7Test.java +++ b/src/test/java/teetime/examples/throughput/MethodCallThoughputTimestampAnalysis7Test.java @@ -22,7 +22,6 @@ import java.util.concurrent.Callable; import org.junit.Before; import org.junit.Test; -import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis6; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis7; import teetime.util.StatisticsUtil; import teetime.util.StopWatch; diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis3.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis3.java index c627098aff98288cf1f4d2dac3f4f3157adc863e..29b7a0ab53511842a483b9bffae34ddd0c8f27b5 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis3.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis3.java @@ -78,15 +78,20 @@ public class MethodCallThroughputAnalysis3 extends Analysis { @Override public boolean execute() { // extracting the null-check does NOT improve performance - Stage stage = stages[0]; - Object element = stage.execute(null); - if (element == null) { - return false; - } + // Stage stage = stages[0]; + // Object element = stage.execute(null); + // if (element == null) { + // return false; + // } + + Object element = null; - for (int i = 1; i < stages.length; i++) { - stage = stages[i]; + for (int i = 0; i < stages.length; i++) { + Stage stage = stages[i]; element = stage.execute(element); + if (element == null) { + return false; + } } return true; diff --git a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis7.java b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis7.java index 965a101b534040d7b4a0601e33622f0cfa86fc09..b9e4060e639204e72c3f8572852670de449d009e 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis7.java +++ b/src/test/java/teetime/examples/throughput/methodcall/MethodCallThroughputAnalysis7.java @@ -64,7 +64,7 @@ public class MethodCallThroughputAnalysis7 extends Analysis { final StopTimestampFilter stopTimestampFilter = new StopTimestampFilter(); final CollectorSink<TimestampObject> collectorSink = new CollectorSink<TimestampObject>(this.timestampObjects); - final List<Stage> stageList = new ArrayList<Stage>(); + final List<AbstractStage> stageList = new ArrayList<AbstractStage>(); stageList.add(objectProducer); stageList.add(startTimestampFilter); stageList.addAll(Arrays.asList(noopFilters)); @@ -72,19 +72,30 @@ public class MethodCallThroughputAnalysis7 extends Analysis { stageList.add(collectorSink); // using an array decreases the performance from 60ms to 200ms (by 3x) - final Stage[] stages = stageList.toArray(new Stage[0]); + final AbstractStage[] stages = stageList.toArray(new AbstractStage[0]); final WrappingPipeline pipeline = new WrappingPipeline() { @Override public boolean execute() { // using the foreach for arrays (i.e., w/o using an iterator variable) increases the performance from 200ms to 130ms Object element = null; - for (Stage stage : stages) { + for (AbstractStage stage : stages) { element = stage.execute(element); if (element == null) { return false; } } + + // changing the type of stages decreases performance by 2 (e.g., NoopFilter -> Stage) + // the VM seems to not optimize the code anymore if the concrete type is not declared + + // for (final NoopFilter<TimestampObject> noopFilter : noopFilters) { + // element = noopFilter.execute(element); + // } + // + // element = stopTimestampFilter.execute(element); + // element = collectorSink.execute(element); + return true; } diff --git a/src/test/java/teetime/examples/throughput/methodcall/NoopFilter.java b/src/test/java/teetime/examples/throughput/methodcall/NoopFilter.java index a62cdbe4eefc333d5aff2620b7a879f4c643343e..f1d1367e852559cdfa00a4de7b77c6dc85b3bc38 100644 --- a/src/test/java/teetime/examples/throughput/methodcall/NoopFilter.java +++ b/src/test/java/teetime/examples/throughput/methodcall/NoopFilter.java @@ -24,6 +24,7 @@ import teetime.util.list.CommittableQueue; */ public class NoopFilter<T> extends ConsumerStage<T, T> { + @SuppressWarnings("unchecked") @Override public T execute(final Object obj) { return (T) obj;