mirror of
https://gitlab.uni-marburg.de/langbeid/powersort.git
synced 2025-01-21 19:50:35 +01:00
benchmark: refactor
This commit is contained in:
parent
684f28bb2b
commit
605d0c2781
@ -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();
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user