< prev index next >

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

Print this page
@@ -20,11 +20,10 @@
   * or visit www.oracle.com if you need additional information or have any
   * questions.
   */
  package org.openjdk.bench.jdk.incubator.foreign;
  
- import jdk.incubator.foreign.MemoryAccess;
  import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.foreign.ResourceScope;
  import org.openjdk.jmh.annotations.Benchmark;
  import org.openjdk.jmh.annotations.BenchmarkMode;
  import org.openjdk.jmh.annotations.Fork;

@@ -40,11 +39,11 @@
  import java.nio.ByteBuffer;
  import java.nio.ByteOrder;
  import java.util.concurrent.TimeUnit;
  
  import static jdk.incubator.foreign.MemoryLayout.PathElement.sequenceElement;
- import static jdk.incubator.foreign.MemoryLayouts.JAVA_DOUBLE;
+ import static jdk.incubator.foreign.ValueLayout.JAVA_DOUBLE;
  
  @BenchmarkMode(Mode.AverageTime)
  @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
  @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
  @State(org.openjdk.jmh.annotations.Scope.Thread)

@@ -73,14 +72,14 @@
              unsafe.putDouble(unsafe_addrOut + (i * CARRIER_SIZE), i);
          }
          segmentIn = MemorySegment.allocateNative(ALLOC_SIZE, ResourceScope.newConfinedScope());
          segmentOut = MemorySegment.allocateNative(ALLOC_SIZE, ResourceScope.newConfinedScope());
          for (int i = 0; i < ELEM_SIZE; i++) {
-             MemoryAccess.setDoubleAtIndex(segmentIn, i, i);
+             segmentIn.setAtIndex(JAVA_DOUBLE, i, i);
          }
          for (int i = 0; i < ELEM_SIZE; i++) {
-             MemoryAccess.setDoubleAtIndex(segmentOut, i, i);
+             segmentOut.setAtIndex(JAVA_DOUBLE, i, i);
          }
          byteBufferIn = ByteBuffer.allocateDirect(ALLOC_SIZE).order(ByteOrder.nativeOrder());
          byteBufferOut = ByteBuffer.allocateDirect(ALLOC_SIZE).order(ByteOrder.nativeOrder());
          for (int i = 0; i < ELEM_SIZE; i++) {
              byteBufferIn.putDouble(i * CARRIER_SIZE , i);

@@ -110,13 +109,13 @@
      }
  
      @Benchmark
      public void segment_loop() {
          for (int i = 0; i < ELEM_SIZE; i ++) {
-             MemoryAccess.setDoubleAtIndex(segmentOut, i,
-                     MemoryAccess.getDoubleAtIndex(segmentIn, i) +
-                     MemoryAccess.getDoubleAtIndex(segmentOut, i));
+             segmentOut.setAtIndex(JAVA_DOUBLE, i,
+                     segmentIn.getAtIndex(JAVA_DOUBLE, i) +
+                     segmentOut.getAtIndex(JAVA_DOUBLE, i));
          }
      }
  
      @Benchmark
      public void BB_loop() {
< prev index next >