benchmark: refactor

This commit is contained in:
Daniel Langbein 2024-12-10 16:53:07 +00:00
parent 8e20550b44
commit a945a3278e
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
8 changed files with 15 additions and 13 deletions

View File

@ -1,9 +1,10 @@
package de.uni_marburg.powersort.benchmark;
import de.uni_marburg.powersort.TimSort;
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.*;
import org.openjdk.jmh.infra.Blackhole;
import java.util.concurrent.TimeUnit;
@ -28,16 +29,15 @@ public class BenchmarkJmh {
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Benchmark
public void rand1DummySort(State1 s, Blackhole bh) {
public void rand1DummySort(State1 s) {
DummySort.sort(s.a, 0, s.a.length, NaturalOrder.INSTANCE, null, 0, 0);
}
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Benchmark
public void rand1TimSort(State1 s, Blackhole bh) {
public void rand1TimSort(State1 s) {
TimSort.sort(s.a, 0, s.a.length, NaturalOrder.INSTANCE, null, 0, 0);
bh.consume(s);
}
@BenchmarkMode(Mode.AverageTime)

View File

@ -1,6 +1,8 @@
package de.uni_marburg.powersort.benchmark;
import de.uni_marburg.powersort.TimSort;
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.DescendingIntegers;
import de.uni_marburg.powersort.data.RandomIntegers;
import de.uni_marburg.powersort.data.ObjectSupplier;

View File

@ -24,7 +24,7 @@
* questions.
*/
package de.uni_marburg.powersort;
package de.uni_marburg.powersort.sort;
/**
* This is a near duplicate of {@link TimSort}, modified for use with

View File

@ -1,4 +1,4 @@
package de.uni_marburg.powersort.benchmark;
package de.uni_marburg.powersort.sort;
import java.util.Arrays;
import java.util.Comparator;
@ -8,7 +8,7 @@ import java.util.Comparator;
* <p>
* Uses Arrays.sort() for sorting.
*/
class DummySort {
public class DummySort {
public static <T> void sort(T[] a, int lo, int hi, Comparator<? super T> c,
T[] work, int workBase, int workLen) {
assert lo == 0;

View File

@ -1,4 +1,4 @@
package de.uni_marburg.powersort.benchmark;
package de.uni_marburg.powersort.sort;
import java.util.Arrays;
import java.util.Comparator;

View File

@ -1,4 +1,4 @@
package de.uni_marburg.powersort.benchmark;
package de.uni_marburg.powersort.sort;
import java.util.Comparator;

View File

@ -1,4 +1,4 @@
package de.uni_marburg.powersort;
package de.uni_marburg.powersort.sort;
import java.util.Comparator;

View File

@ -24,7 +24,7 @@
* questions.
*/
package de.uni_marburg.powersort;
package de.uni_marburg.powersort.sort;
import java.util.Comparator;