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

modified some performance tests

parent 822c6d49
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,7 @@ import teetime.examples.throughput.TimestampObject; ...@@ -27,7 +27,7 @@ import teetime.examples.throughput.TimestampObject;
/** /**
* @author Christian Wulf * @author Christian Wulf
* *
* @since 1.10 * @since 1.10
*/ */
public class StatisticsUtil { public class StatisticsUtil {
...@@ -72,7 +72,7 @@ public class StatisticsUtil { ...@@ -72,7 +72,7 @@ public class StatisticsUtil {
public static void printQuintiles(final Map<Double, Long> quintileValues) { public static void printQuintiles(final Map<Double, Long> quintileValues) {
for (final Entry<Double, Long> entry : quintileValues.entrySet()) { 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");
} }
} }
......
...@@ -22,7 +22,6 @@ import java.util.concurrent.Callable; ...@@ -22,7 +22,6 @@ import java.util.concurrent.Callable;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis6;
import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis7; import teetime.examples.throughput.methodcall.MethodCallThroughputAnalysis7;
import teetime.util.StatisticsUtil; import teetime.util.StatisticsUtil;
import teetime.util.StopWatch; import teetime.util.StopWatch;
......
...@@ -78,15 +78,20 @@ public class MethodCallThroughputAnalysis3 extends Analysis { ...@@ -78,15 +78,20 @@ public class MethodCallThroughputAnalysis3 extends Analysis {
@Override @Override
public boolean execute() { public boolean execute() {
// extracting the null-check does NOT improve performance // extracting the null-check does NOT improve performance
Stage stage = stages[0]; // Stage stage = stages[0];
Object element = stage.execute(null); // Object element = stage.execute(null);
if (element == null) { // if (element == null) {
return false; // return false;
} // }
Object element = null;
for (int i = 1; i < stages.length; i++) { for (int i = 0; i < stages.length; i++) {
stage = stages[i]; Stage stage = stages[i];
element = stage.execute(element); element = stage.execute(element);
if (element == null) {
return false;
}
} }
return true; return true;
......
...@@ -64,7 +64,7 @@ public class MethodCallThroughputAnalysis7 extends Analysis { ...@@ -64,7 +64,7 @@ public class MethodCallThroughputAnalysis7 extends Analysis {
final StopTimestampFilter stopTimestampFilter = new StopTimestampFilter(); final StopTimestampFilter stopTimestampFilter = new StopTimestampFilter();
final CollectorSink<TimestampObject> collectorSink = new CollectorSink<TimestampObject>(this.timestampObjects); 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(objectProducer);
stageList.add(startTimestampFilter); stageList.add(startTimestampFilter);
stageList.addAll(Arrays.asList(noopFilters)); stageList.addAll(Arrays.asList(noopFilters));
...@@ -72,19 +72,30 @@ public class MethodCallThroughputAnalysis7 extends Analysis { ...@@ -72,19 +72,30 @@ public class MethodCallThroughputAnalysis7 extends Analysis {
stageList.add(collectorSink); stageList.add(collectorSink);
// using an array decreases the performance from 60ms to 200ms (by 3x) // 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() { final WrappingPipeline pipeline = new WrappingPipeline() {
@Override @Override
public boolean execute() { public boolean execute() {
// using the foreach for arrays (i.e., w/o using an iterator variable) increases the performance from 200ms to 130ms // using the foreach for arrays (i.e., w/o using an iterator variable) increases the performance from 200ms to 130ms
Object element = null; Object element = null;
for (Stage stage : stages) { for (AbstractStage stage : stages) {
element = stage.execute(element); element = stage.execute(element);
if (element == null) { if (element == null) {
return false; 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; return true;
} }
......
...@@ -24,6 +24,7 @@ import teetime.util.list.CommittableQueue; ...@@ -24,6 +24,7 @@ import teetime.util.list.CommittableQueue;
*/ */
public class NoopFilter<T> extends ConsumerStage<T, T> { public class NoopFilter<T> extends ConsumerStage<T, T> {
@SuppressWarnings("unchecked")
@Override @Override
public T execute(final Object obj) { public T execute(final Object obj) {
return (T) obj; return (T) obj;
......
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