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

modified some performance tests

parent eed8e178
No related branches found
No related tags found
No related merge requests found
......@@ -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");
}
}
......
......@@ -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;
......
......@@ -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);
// Stage stage = stages[0];
// Object element = stage.execute(null);
// if (element == null) {
// return false;
// }
Object element = null;
for (int i = 0; i < stages.length; i++) {
Stage stage = stages[i];
element = stage.execute(element);
if (element == null) {
return false;
}
for (int i = 1; i < stages.length; i++) {
stage = stages[i];
element = stage.execute(element);
}
return true;
......
......@@ -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;
}
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment