< prev index next >

test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantHeap.java

Print this page

 32 import org.openjdk.jmh.annotations.Mode;
 33 import org.openjdk.jmh.annotations.OutputTimeUnit;
 34 import org.openjdk.jmh.annotations.Param;
 35 import org.openjdk.jmh.annotations.Setup;
 36 import org.openjdk.jmh.annotations.State;
 37 import org.openjdk.jmh.annotations.TearDown;
 38 import org.openjdk.jmh.annotations.Warmup;
 39 import sun.misc.Unsafe;
 40 
 41 import java.nio.ByteBuffer;
 42 import java.nio.ByteOrder;
 43 import java.util.concurrent.TimeUnit;
 44 
 45 import static java.lang.foreign.ValueLayout.*;
 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 = "--enable-preview")
 53 public class LoopOverNonConstantHeap extends JavaLayouts {
 54 
 55     static final Unsafe unsafe = Utils.unsafe;
 56 
 57     static final int ELEM_SIZE = 1_000_000;
 58     static final int CARRIER_SIZE = (int)JAVA_INT.byteSize();
 59     static final int ALLOC_SIZE = ELEM_SIZE * CARRIER_SIZE;
 60     static final int UNSAFE_BYTE_BASE = unsafe.arrayBaseOffset(byte[].class);
 61     static final int UNSAFE_INT_BASE = unsafe.arrayBaseOffset(int[].class);
 62 
 63     MemorySegment segment, alignedSegment;
 64     byte[] base;
 65     int[] alignedBase;
 66 
 67     ByteBuffer byteBuffer;
 68 
 69     @Param(value = {"false", "true"})
 70     boolean polluteProfile;
 71 
 72     @Setup

 32 import org.openjdk.jmh.annotations.Mode;
 33 import org.openjdk.jmh.annotations.OutputTimeUnit;
 34 import org.openjdk.jmh.annotations.Param;
 35 import org.openjdk.jmh.annotations.Setup;
 36 import org.openjdk.jmh.annotations.State;
 37 import org.openjdk.jmh.annotations.TearDown;
 38 import org.openjdk.jmh.annotations.Warmup;
 39 import sun.misc.Unsafe;
 40 
 41 import java.nio.ByteBuffer;
 42 import java.nio.ByteOrder;
 43 import java.util.concurrent.TimeUnit;
 44 
 45 import static java.lang.foreign.ValueLayout.*;
 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(3)
 53 public class LoopOverNonConstantHeap extends JavaLayouts {
 54 
 55     static final Unsafe unsafe = Utils.unsafe;
 56 
 57     static final int ELEM_SIZE = 1_000_000;
 58     static final int CARRIER_SIZE = (int)JAVA_INT.byteSize();
 59     static final int ALLOC_SIZE = ELEM_SIZE * CARRIER_SIZE;
 60     static final int UNSAFE_BYTE_BASE = unsafe.arrayBaseOffset(byte[].class);
 61     static final int UNSAFE_INT_BASE = unsafe.arrayBaseOffset(int[].class);
 62 
 63     MemorySegment segment, alignedSegment;
 64     byte[] base;
 65     int[] alignedBase;
 66 
 67     ByteBuffer byteBuffer;
 68 
 69     @Param(value = {"false", "true"})
 70     boolean polluteProfile;
 71 
 72     @Setup
< prev index next >