< prev index next >

test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverPollutedBuffer.java

Print this page

 25 package org.openjdk.bench.jdk.incubator.foreign;
 26 
 27 
 28 import org.openjdk.jmh.annotations.Benchmark;
 29 import org.openjdk.jmh.annotations.BenchmarkMode;
 30 import org.openjdk.jmh.annotations.Fork;
 31 import org.openjdk.jmh.annotations.Measurement;
 32 import org.openjdk.jmh.annotations.Mode;
 33 import org.openjdk.jmh.annotations.OutputTimeUnit;
 34 import org.openjdk.jmh.annotations.Setup;
 35 import org.openjdk.jmh.annotations.State;
 36 import org.openjdk.jmh.annotations.TearDown;
 37 import org.openjdk.jmh.annotations.Warmup;
 38 import sun.misc.Unsafe;
 39 
 40 import java.nio.ByteBuffer;
 41 import java.nio.ByteOrder;
 42 import java.nio.FloatBuffer;
 43 import java.util.concurrent.TimeUnit;
 44 
 45 import static jdk.incubator.foreign.MemoryLayouts.JAVA_INT;
 46 
 47 @BenchmarkMode(Mode.AverageTime)
 48 @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
 49 @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
 50 @State(org.openjdk.jmh.annotations.Scope.Thread)
 51 @OutputTimeUnit(TimeUnit.MILLISECONDS)
 52 @Fork(value = 3, jvmArgsAppend = { "--add-modules=jdk.incubator.foreign" })
 53 public class LoopOverPollutedBuffer {
 54 
 55     static final int ELEM_SIZE = 1_000_000;
 56     static final int CARRIER_SIZE = (int) JAVA_INT.byteSize();
 57     static final int ALLOC_SIZE = ELEM_SIZE * CARRIER_SIZE;
 58 
 59     static final Unsafe unsafe = Utils.unsafe;
 60 
 61     ByteBuffer dbb = ByteBuffer.allocateDirect(ALLOC_SIZE).order(ByteOrder.nativeOrder());
 62     byte[] arr = new byte[ALLOC_SIZE];
 63     ByteBuffer hbb = ByteBuffer.wrap(arr).order(ByteOrder.nativeOrder());
 64     FloatBuffer hfb = hbb.asFloatBuffer();
 65 

 25 package org.openjdk.bench.jdk.incubator.foreign;
 26 
 27 
 28 import org.openjdk.jmh.annotations.Benchmark;
 29 import org.openjdk.jmh.annotations.BenchmarkMode;
 30 import org.openjdk.jmh.annotations.Fork;
 31 import org.openjdk.jmh.annotations.Measurement;
 32 import org.openjdk.jmh.annotations.Mode;
 33 import org.openjdk.jmh.annotations.OutputTimeUnit;
 34 import org.openjdk.jmh.annotations.Setup;
 35 import org.openjdk.jmh.annotations.State;
 36 import org.openjdk.jmh.annotations.TearDown;
 37 import org.openjdk.jmh.annotations.Warmup;
 38 import sun.misc.Unsafe;
 39 
 40 import java.nio.ByteBuffer;
 41 import java.nio.ByteOrder;
 42 import java.nio.FloatBuffer;
 43 import java.util.concurrent.TimeUnit;
 44 
 45 import static jdk.incubator.foreign.ValueLayout.JAVA_INT;
 46 
 47 @BenchmarkMode(Mode.AverageTime)
 48 @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
 49 @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
 50 @State(org.openjdk.jmh.annotations.Scope.Thread)
 51 @OutputTimeUnit(TimeUnit.MILLISECONDS)
 52 @Fork(value = 3, jvmArgsAppend = { "--add-modules=jdk.incubator.foreign" })
 53 public class LoopOverPollutedBuffer {
 54 
 55     static final int ELEM_SIZE = 1_000_000;
 56     static final int CARRIER_SIZE = (int) JAVA_INT.byteSize();
 57     static final int ALLOC_SIZE = ELEM_SIZE * CARRIER_SIZE;
 58 
 59     static final Unsafe unsafe = Utils.unsafe;
 60 
 61     ByteBuffer dbb = ByteBuffer.allocateDirect(ALLOC_SIZE).order(ByteOrder.nativeOrder());
 62     byte[] arr = new byte[ALLOC_SIZE];
 63     ByteBuffer hbb = ByteBuffer.wrap(arr).order(ByteOrder.nativeOrder());
 64     FloatBuffer hfb = hbb.asFloatBuffer();
 65 
< prev index next >