diff --git a/app/src/jmh/java/de/uni_marburg/powersort/benchmark/BenchmarkJmh.java b/app/src/jmh/java/de/uni_marburg/powersort/benchmark/AbstractBenchmark.java similarity index 62% rename from app/src/jmh/java/de/uni_marburg/powersort/benchmark/BenchmarkJmh.java rename to app/src/jmh/java/de/uni_marburg/powersort/benchmark/AbstractBenchmark.java index 09b1685..8603207 100644 --- a/app/src/jmh/java/de/uni_marburg/powersort/benchmark/BenchmarkJmh.java +++ b/app/src/jmh/java/de/uni_marburg/powersort/benchmark/AbstractBenchmark.java @@ -1,8 +1,5 @@ package de.uni_marburg.powersort.benchmark; -import de.uni_marburg.powersort.sort.DummySort; -import de.uni_marburg.powersort.sort.MergeSort; -import de.uni_marburg.powersort.sort.TimSort; import de.uni_marburg.powersort.data.RandomIntegers; import org.openjdk.jmh.annotations.*; @@ -24,7 +21,7 @@ import java.util.concurrent.TimeUnit; * State objects naturally encapsulate the state on which benchmark is working on. */ @State(Scope.Benchmark) -public class BenchmarkJmh { +public abstract class AbstractBenchmark { private final RandomIntegers readonly = new RandomIntegers(); /* package-protected */ Integer[] array; @@ -35,17 +32,12 @@ public class BenchmarkJmh { } @Benchmark - public void rand1DummySort() { - DummySort.sort(array, 0, array.length, NaturalOrder.INSTANCE, null, 0, 0); + public void benchmark() { + sort(); } - @Benchmark - public void rand1TimSort() { - TimSort.sort(array, 0, array.length, NaturalOrder.INSTANCE, null, 0, 0); - } - - @Benchmark - public void rand1MergeSort() { - MergeSort.legacyMergeSort(array, NaturalOrder.INSTANCE); - } + /** + * Sorts this.array with some sorting algorithm. + */ + /* package-protected */ abstract void sort(); } 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 new file mode 100644 index 0000000..3bb2bf9 --- /dev/null +++ b/app/src/jmh/java/de/uni_marburg/powersort/benchmark/DummySortBenchmark.java @@ -0,0 +1,10 @@ +package de.uni_marburg.powersort.benchmark; + +import de.uni_marburg.powersort.sort.DummySort; + +public class DummySortBenchmark extends AbstractBenchmark { + @Override + public void sort() { + DummySort.sort(array, 0, array.length, NaturalOrder.INSTANCE, null, 0, 0); + } +} 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 new file mode 100644 index 0000000..75e4eb6 --- /dev/null +++ b/app/src/jmh/java/de/uni_marburg/powersort/benchmark/MergeSortBenchmark.java @@ -0,0 +1,10 @@ +package de.uni_marburg.powersort.benchmark; + +import de.uni_marburg.powersort.sort.MergeSort; + +public class MergeSortBenchmark extends AbstractBenchmark { + @Override + public void sort() { + MergeSort.legacyMergeSort(array, NaturalOrder.INSTANCE); + } +}