mirror of https://github.com/apache/lucene.git
stabilize vectorutil benchmark
This commit is contained in:
parent
e292a5fe4f
commit
6bf2188b35
|
@ -24,8 +24,14 @@ import org.openjdk.jmh.annotations.*;
|
||||||
@BenchmarkMode(Mode.Throughput)
|
@BenchmarkMode(Mode.Throughput)
|
||||||
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
||||||
@State(Scope.Benchmark)
|
@State(Scope.Benchmark)
|
||||||
@Warmup(iterations = 3, time = 3)
|
// first iteration is complete garbage, so make sure we really warmup
|
||||||
@Measurement(iterations = 5, time = 3)
|
@Warmup(iterations = 4, time = 1)
|
||||||
|
// real iterations. not useful to spend tons of time here, better to fork more
|
||||||
|
@Measurement(iterations = 5, time = 1)
|
||||||
|
// engage some noise reduction
|
||||||
|
@Fork(
|
||||||
|
value = 3,
|
||||||
|
jvmArgsAppend = {"-Xmx2g", "-Xms2g", "-XX:+AlwaysPreTouch"})
|
||||||
public class VectorUtilBenchmark {
|
public class VectorUtilBenchmark {
|
||||||
|
|
||||||
private byte[] bytesA;
|
private byte[] bytesA;
|
||||||
|
@ -36,7 +42,7 @@ public class VectorUtilBenchmark {
|
||||||
@Param({"1", "128", "207", "256", "300", "512", "702", "1024"})
|
@Param({"1", "128", "207", "256", "300", "512", "702", "1024"})
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
@Setup(Level.Trial)
|
@Setup(Level.Iteration)
|
||||||
public void init() {
|
public void init() {
|
||||||
ThreadLocalRandom random = ThreadLocalRandom.current();
|
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||||
|
|
||||||
|
@ -56,84 +62,72 @@ public class VectorUtilBenchmark {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@Fork(value = 1)
|
|
||||||
public float binaryCosineScalar() {
|
public float binaryCosineScalar() {
|
||||||
return VectorUtil.cosine(bytesA, bytesB);
|
return VectorUtil.cosine(bytesA, bytesB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@Fork(
|
@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
|
||||||
value = 1,
|
|
||||||
jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
|
|
||||||
public float binaryCosineVector() {
|
public float binaryCosineVector() {
|
||||||
return VectorUtil.cosine(bytesA, bytesB);
|
return VectorUtil.cosine(bytesA, bytesB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@Fork(value = 1)
|
|
||||||
public int binaryDotProductScalar() {
|
public int binaryDotProductScalar() {
|
||||||
return VectorUtil.dotProduct(bytesA, bytesB);
|
return VectorUtil.dotProduct(bytesA, bytesB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@Fork(
|
@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
|
||||||
value = 1,
|
|
||||||
jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
|
|
||||||
public int binaryDotProductVector() {
|
public int binaryDotProductVector() {
|
||||||
return VectorUtil.dotProduct(bytesA, bytesB);
|
return VectorUtil.dotProduct(bytesA, bytesB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@Fork(value = 1)
|
|
||||||
public int binarySquareScalar() {
|
public int binarySquareScalar() {
|
||||||
return VectorUtil.squareDistance(bytesA, bytesB);
|
return VectorUtil.squareDistance(bytesA, bytesB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@Fork(
|
@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
|
||||||
value = 1,
|
|
||||||
jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
|
|
||||||
public int binarySquareVector() {
|
public int binarySquareVector() {
|
||||||
return VectorUtil.squareDistance(bytesA, bytesB);
|
return VectorUtil.squareDistance(bytesA, bytesB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@Fork(value = 1)
|
|
||||||
public float floatCosineScalar() {
|
public float floatCosineScalar() {
|
||||||
return VectorUtil.cosine(floatsA, floatsB);
|
return VectorUtil.cosine(floatsA, floatsB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@Fork(
|
@Fork(
|
||||||
value = 1,
|
value = 15,
|
||||||
jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
|
jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
|
||||||
public float floatCosineVector() {
|
public float floatCosineVector() {
|
||||||
return VectorUtil.cosine(floatsA, floatsB);
|
return VectorUtil.cosine(floatsA, floatsB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@Fork(value = 1)
|
|
||||||
public float floatDotProductScalar() {
|
public float floatDotProductScalar() {
|
||||||
return VectorUtil.dotProduct(floatsA, floatsB);
|
return VectorUtil.dotProduct(floatsA, floatsB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@Fork(
|
@Fork(
|
||||||
value = 1,
|
value = 15,
|
||||||
jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
|
jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
|
||||||
public float floatDotProductVector() {
|
public float floatDotProductVector() {
|
||||||
return VectorUtil.dotProduct(floatsA, floatsB);
|
return VectorUtil.dotProduct(floatsA, floatsB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@Fork(value = 1)
|
|
||||||
public float floatSquareScalar() {
|
public float floatSquareScalar() {
|
||||||
return VectorUtil.squareDistance(floatsA, floatsB);
|
return VectorUtil.squareDistance(floatsA, floatsB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@Fork(
|
@Fork(
|
||||||
value = 1,
|
value = 15,
|
||||||
jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
|
jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
|
||||||
public float floatSquareVector() {
|
public float floatSquareVector() {
|
||||||
return VectorUtil.squareDistance(floatsA, floatsB);
|
return VectorUtil.squareDistance(floatsA, floatsB);
|
||||||
|
|
Loading…
Reference in New Issue