< prev index next >

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

Print this page
@@ -21,18 +21,12 @@
   * questions.
   */
  
  package org.openjdk.bench.jdk.incubator.foreign;
  
- import jdk.incubator.foreign.CLinker;
- import jdk.incubator.foreign.MemoryAccess;
- import jdk.incubator.foreign.MemoryAddress;
  import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.foreign.ResourceScope;
- import jdk.incubator.vector.ByteVector;
- import jdk.incubator.vector.IntVector;
- import jdk.incubator.vector.VectorSpecies;
  import org.openjdk.jmh.annotations.Benchmark;
  import org.openjdk.jmh.annotations.BenchmarkMode;
  import org.openjdk.jmh.annotations.CompilerControl;
  import org.openjdk.jmh.annotations.Fork;
  import org.openjdk.jmh.annotations.Measurement;

@@ -42,13 +36,14 @@
  import org.openjdk.jmh.annotations.Setup;
  import org.openjdk.jmh.annotations.State;
  import org.openjdk.jmh.annotations.Warmup;
  
  import java.nio.ByteBuffer;
- import java.nio.ByteOrder;
  import java.util.concurrent.TimeUnit;
  
+ import static jdk.incubator.foreign.ValueLayout.JAVA_BYTE;
+ 
  @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)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)

@@ -117,21 +112,21 @@
  
      @Benchmark
      public int segmentNativeScalar() {
          int size = 0;
          for (int i = 0; i < srcArray.length; i++) {
-             var v = MemoryAccess.getByteAtOffset(srcSegmentImplicit, i);
+             var v = srcSegmentImplicit.get(JAVA_BYTE, i);
              size += v;
          }
          return size;
      }
  
      @Benchmark
      public int segmentNativeScalarConst() {
          int size = 0;
          for (int i = 0; i < 1024; i++) {
-             var v = MemoryAccess.getByteAtOffset(srcSegmentImplicit, i);
+             var v = srcSegmentImplicit.get(JAVA_BYTE, i);
              size += v;
          }
          return size;
      }
  }
< prev index next >