diff --git a/app/src/jmh/java/de/uni_marburg/powersort/benchmark/DummySortBenchmark.java b/app/src/jmh/java/de/uni_marburg/powersort/benchmark/DummySortBenchmark.java deleted file mode 100644 index 2091b60..0000000 --- a/app/src/jmh/java/de/uni_marburg/powersort/benchmark/DummySortBenchmark.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.uni_marburg.powersort.benchmark; - -import de.uni_marburg.powersort.sort.DummySort; - -public class DummySortBenchmark extends AbstractBenchmark { - @Override - public void sort() { - DummySort.sort(workingCopy, 0, workingCopy.length, NaturalOrder.INSTANCE, null, 0, 0); - } -} diff --git a/app/src/jmh/java/de/uni_marburg/powersort/benchmark/AbstractBenchmark.java b/app/src/jmh/java/de/uni_marburg/powersort/benchmark/MainJmh.java similarity index 70% rename from app/src/jmh/java/de/uni_marburg/powersort/benchmark/AbstractBenchmark.java rename to app/src/jmh/java/de/uni_marburg/powersort/benchmark/MainJmh.java index 2be81c0..1b55391 100644 --- a/app/src/jmh/java/de/uni_marburg/powersort/benchmark/AbstractBenchmark.java +++ b/app/src/jmh/java/de/uni_marburg/powersort/benchmark/MainJmh.java @@ -2,6 +2,7 @@ package de.uni_marburg.powersort.benchmark; import de.uni_marburg.powersort.data.DataEnum; import de.uni_marburg.powersort.data.ObjectSupplier; +import de.uni_marburg.powersort.sort.SortEnum; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -33,33 +34,28 @@ import java.util.concurrent.TimeUnit; * State objects naturally encapsulate the state on which benchmark is working on. */ @State(Scope.Benchmark) -public abstract class AbstractBenchmark { +public class MainJmh { @Param() private DataEnum dataEnum; + @Param() + private SortEnum sortEnum; - private DataEnum prevDataEnum = null; private ObjectSupplier data; - /* package-protected */ Object[] workingCopy; // TODO: This is inaccurate. How to create and use separate arrays for each warmup x iteration x sortAlgorithm ? @Setup(Level.Invocation) public void setup() { - if (dataEnum != prevDataEnum){ - System.out.println(prevDataEnum + " => " + dataEnum); - prevDataEnum = dataEnum; - data = dataEnum.get(); - } + // TODO: We tried to store the old `dataEnum` in a separate variable and only call `dataEnum.get()` if `dataEnum` changed. But the separate variable was always reverted to `null`. Why? Maybe as the benchmark method does not use it? + // TODO: This leads to different random lists used for each sort impl. + // + // TODO: This is better anyways: Store random list on disk and reuse it for reproducibility + data = dataEnum.get(); workingCopy = data.getCopy(); } @Benchmark public void benchmark() { - sort(); + sortEnum.get().sort(workingCopy); } - - /** - * Sorts this.array with some sorting algorithm. - */ - /* package-protected */ abstract void sort(); } diff --git a/app/src/jmh/java/de/uni_marburg/powersort/benchmark/MergeSortBenchmark.java b/app/src/jmh/java/de/uni_marburg/powersort/benchmark/MergeSortBenchmark.java deleted file mode 100644 index f125585..0000000 --- a/app/src/jmh/java/de/uni_marburg/powersort/benchmark/MergeSortBenchmark.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.uni_marburg.powersort.benchmark; - -import de.uni_marburg.powersort.sort.MergeSort; - -public class MergeSortBenchmark extends AbstractBenchmark { - @Override - public void sort() { - MergeSort.legacyMergeSort(workingCopy, NaturalOrder.INSTANCE); - } -}