30 import org.openjdk.jmh.annotations.Measurement;
31 import org.openjdk.jmh.annotations.Mode;
32 import org.openjdk.jmh.annotations.OutputTimeUnit;
33 import org.openjdk.jmh.annotations.Param;
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.IntBuffer;
41 import java.util.concurrent.TimeUnit;
42
43 import static java.lang.foreign.ValueLayout.*;
44
45 @BenchmarkMode(Mode.AverageTime)
46 @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
47 @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
48 @State(org.openjdk.jmh.annotations.Scope.Thread)
49 @OutputTimeUnit(TimeUnit.MILLISECONDS)
50 @Fork(value = 3, jvmArgsAppend = "--enable-preview")
51 public class LoopOverNewHeap extends JavaLayouts {
52
53 static final Unsafe unsafe = Utils.unsafe;
54
55 static final int ELEM_SIZE = 1_000_000;
56 static final int CARRIER_SIZE = (int)JAVA_INT.byteSize();
57
58 @Param(value = {"false", "true"})
59 boolean polluteProfile;
60
61 @Setup
62 public void setup() {
63 if (polluteProfile) {
64 for (int i = 0 ; i < 10000 ; i++) {
65 MemorySegment intB = MemorySegment.ofArray(new byte[ELEM_SIZE]);
66 MemorySegment intI = MemorySegment.ofArray(new int[ELEM_SIZE]);
67 MemorySegment intD = MemorySegment.ofArray(new double[ELEM_SIZE]);
68 MemorySegment intF = MemorySegment.ofArray(new float[ELEM_SIZE]);
69 }
70 }
|
30 import org.openjdk.jmh.annotations.Measurement;
31 import org.openjdk.jmh.annotations.Mode;
32 import org.openjdk.jmh.annotations.OutputTimeUnit;
33 import org.openjdk.jmh.annotations.Param;
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.IntBuffer;
41 import java.util.concurrent.TimeUnit;
42
43 import static java.lang.foreign.ValueLayout.*;
44
45 @BenchmarkMode(Mode.AverageTime)
46 @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
47 @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
48 @State(org.openjdk.jmh.annotations.Scope.Thread)
49 @OutputTimeUnit(TimeUnit.MILLISECONDS)
50 @Fork(3)
51 public class LoopOverNewHeap extends JavaLayouts {
52
53 static final Unsafe unsafe = Utils.unsafe;
54
55 static final int ELEM_SIZE = 1_000_000;
56 static final int CARRIER_SIZE = (int)JAVA_INT.byteSize();
57
58 @Param(value = {"false", "true"})
59 boolean polluteProfile;
60
61 @Setup
62 public void setup() {
63 if (polluteProfile) {
64 for (int i = 0 ; i < 10000 ; i++) {
65 MemorySegment intB = MemorySegment.ofArray(new byte[ELEM_SIZE]);
66 MemorySegment intI = MemorySegment.ofArray(new int[ELEM_SIZE]);
67 MemorySegment intD = MemorySegment.ofArray(new double[ELEM_SIZE]);
68 MemorySegment intF = MemorySegment.ofArray(new float[ELEM_SIZE]);
69 }
70 }
|