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;
|
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 de.uni_marburg.powersort.data.RandomIntegers;
|
||||||
import org.openjdk.jmh.annotations.*;
|
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 objects naturally encapsulate the state on which benchmark is working on.
|
||||||
*/
|
*/
|
||||||
@State(Scope.Benchmark)
|
@State(Scope.Benchmark)
|
||||||
public class BenchmarkJmh {
|
public abstract class AbstractBenchmark {
|
||||||
private final RandomIntegers readonly = new RandomIntegers();
|
private final RandomIntegers readonly = new RandomIntegers();
|
||||||
/* package-protected */ Integer[] array;
|
/* package-protected */ Integer[] array;
|
||||||
|
|
||||||
@ -35,17 +32,12 @@ public class BenchmarkJmh {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
public void rand1DummySort() {
|
public void benchmark() {
|
||||||
DummySort.sort(array, 0, array.length, NaturalOrder.INSTANCE, null, 0, 0);
|
sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
/**
|
||||||
public void rand1TimSort() {
|
* Sorts this.array with some sorting algorithm.
|
||||||
TimSort.sort(array, 0, array.length, NaturalOrder.INSTANCE, null, 0, 0);
|
*/
|
||||||
}
|
/* package-protected */ abstract void sort();
|
||||||
|
|
||||||
@Benchmark
|
|
||||||
public void rand1MergeSort() {
|
|
||||||
MergeSort.legacyMergeSort(array, NaturalOrder.INSTANCE);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -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