recover deleted JMH tests

update gradle and other third-party libs
This commit is contained in:
2019-08-22 19:57:27 +02:00
parent 506fb7b698
commit 0311ecd83c
6 changed files with 164 additions and 15 deletions

View File

@@ -0,0 +1,59 @@
package org.lucares.collections;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
@State(Scope.Benchmark)
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
public class BenchmarkRemoveAll {
private IntList base = null;
private IntList remove = null;
@Setup
public void setup() throws Exception {
final int values = 10_000;
base = IntList.of();
IntStream.range(0, values).forEachOrdered(i -> base.add(i));
base.sort();
remove = IntList.of();
IntStream.range(0, 50).forEachOrdered(i -> remove.add(i));
remove.sort();
}
@TearDown
public void tearDown() {
base = null;
remove = null;
}
@Benchmark
public void testRemoveAll() throws Exception {
final IntList tmp = base.clone();
tmp.removeAll(remove);
}
@Benchmark
public void testRemoveAll_withRemoveIf() throws Exception {
final IntList tmp = base.clone();
tmp.removeIf((val, index) -> remove.indexOf(val) >= 0);
}
}

View File

@@ -0,0 +1,70 @@
package org.lucares.collections;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
@State(Scope.Benchmark)
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
public class BenchmarkUnionIntersection {
private IntList aSorted = null;
private IntList bSorted = null;
private IntList cUnsorted = null;
private IntList dUnsorted = null;
@Setup
public void setup() throws Exception {
final int values = 10_000;
aSorted = IntList.of();
IntStream.range(0, values).forEachOrdered(aSorted::add);
aSorted.sort();
bSorted = IntList.of();
IntStream.range(0, values).forEachOrdered(bSorted::add);
bSorted.sort();
cUnsorted = IntList.of();
IntStream.range(0, values).forEachOrdered(cUnsorted::add);
cUnsorted.shuffle();
dUnsorted = IntList.of();
IntStream.range(0, values).forEachOrdered(dUnsorted::add);
dUnsorted.shuffle();
}
@TearDown
public void tearDown() {
aSorted = null;
bSorted = null;
cUnsorted = null;
dUnsorted = null;
}
@Benchmark
public void testUnionSortedLists() throws Exception {
IntList.union(aSorted, bSorted);
}
@Benchmark
public void testIntersectionSortedLists() throws Exception {
IntList.intersection(aSorted, bSorted);
}
}