8343844: Add benchmarks for superword/autovectorization in FFM BulkOperations
Reviewed-by: mcimadamore
This commit is contained in:
parent
72f67fb16a
commit
2fb0c1dd62
@ -38,6 +38,7 @@ import org.openjdk.jmh.annotations.Warmup;
|
||||
|
||||
import java.lang.foreign.Arena;
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -74,6 +75,20 @@ public class SegmentBulkFill {
|
||||
Arrays.fill(array, (byte) 0);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void arraysFillLoop() {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void bufferFillLoop() {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
buffer.put(i, (byte)0);
|
||||
}
|
||||
}
|
||||
|
||||
@Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.fill=31"})
|
||||
@Benchmark
|
||||
public void heapSegmentFillJava() {
|
||||
@ -86,6 +101,13 @@ public class SegmentBulkFill {
|
||||
heapSegment.fill((byte) 0);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void heapSegmentFillLoop() {
|
||||
for (long i = 0; i < heapSegment.byteSize(); i++) {
|
||||
heapSegment.set(ValueLayout.JAVA_BYTE, i, (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.fill=31"})
|
||||
@Benchmark
|
||||
public void nativeSegmentFillJava() {
|
||||
@ -98,6 +120,13 @@ public class SegmentBulkFill {
|
||||
nativeSegment.fill((byte) 0);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void nativeSegmentFillLoop() {
|
||||
for (long i = 0; i < nativeSegment.byteSize(); i++) {
|
||||
nativeSegment.set(ValueLayout.JAVA_BYTE, i, (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.fill=31"})
|
||||
@Benchmark
|
||||
public void unalignedSegmentFillJava() {
|
||||
@ -110,4 +139,11 @@ public class SegmentBulkFill {
|
||||
unalignedSegment.fill((byte) 0);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void unalignedSegmentFillLoop() {
|
||||
for (long i = 0; i < unalignedSegment.byteSize(); i++) {
|
||||
unalignedSegment.set(ValueLayout.JAVA_BYTE, i, (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user