< prev index next >

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

Print this page
*** 24,11 ***
   */
  
  package org.openjdk.bench.jdk.incubator.foreign;
  
  import jdk.incubator.foreign.ResourceScope;
- import jdk.incubator.foreign.SegmentAllocator;
  import org.openjdk.jmh.annotations.Benchmark;
  import org.openjdk.jmh.annotations.BenchmarkMode;
  import org.openjdk.jmh.annotations.Fork;
  import org.openjdk.jmh.annotations.Measurement;
  import org.openjdk.jmh.annotations.Mode;
--- 24,10 ---

*** 36,19 ***
  import org.openjdk.jmh.annotations.OutputTimeUnit;
  import org.openjdk.jmh.annotations.Setup;
  import org.openjdk.jmh.annotations.State;
  import org.openjdk.jmh.annotations.TearDown;
  import org.openjdk.jmh.annotations.Warmup;
- import sun.misc.Unsafe;
  
  import jdk.incubator.foreign.MemorySegment;
  import java.nio.ByteBuffer;
  import java.util.concurrent.TimeUnit;
  import java.util.function.Supplier;
  
- import static jdk.incubator.foreign.MemoryLayouts.JAVA_INT;
- 
  @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.MILLISECONDS)
--- 35,16 ---

*** 69,11 ***
          ResourceScope makeScope() {
              return scopeFactory.get();
          }
      }
  
!     @Param({"CONFINED", "SHARED", "IMPLICIT"})
      public ScopeKind scopeKind;
  
      // large(ish) segments/buffers with same content, 0, for mismatch, non-multiple-of-8 sized
      static final int SIZE_WITH_TAIL = (1024 * 1024) + 7;
  
--- 65,11 ---
          ResourceScope makeScope() {
              return scopeFactory.get();
          }
      }
  
!     @Param({"CONFINED", "SHARED"})
      public ScopeKind scopeKind;
  
      // large(ish) segments/buffers with same content, 0, for mismatch, non-multiple-of-8 sized
      static final int SIZE_WITH_TAIL = (1024 * 1024) + 7;
  

*** 119,12 ***
          }
      }
  
      @TearDown
      public void tearDown() {
!         if (!scope.isImplicit())
-             scope.close();
      }
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public long mismatch_large_segment() {
--- 115,11 ---
          }
      }
  
      @TearDown
      public void tearDown() {
!         scope.close();
      }
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public long mismatch_large_segment() {

*** 132,15 ***
      }
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public long mismatch_large_segment_acquire() {
!         var handle = mismatchSegmentLarge1.scope().acquire();
!         try {
              return mismatchSegmentLarge1.mismatch(mismatchSegmentLarge2);
-         } finally {
-             mismatchSegmentLarge1.scope().release(handle);
          }
      }
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
--- 127,13 ---
      }
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public long mismatch_large_segment_acquire() {
!         try (ResourceScope scope = ResourceScope.newConfinedScope()) {
!             scope.keepAlive(mismatchSegmentLarge1.scope());
              return mismatchSegmentLarge1.mismatch(mismatchSegmentLarge2);
          }
      }
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)

*** 155,15 ***
      }
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public long mismatch_small_segment_acquire() {
!         var handle = mismatchSegmentLarge1.scope().acquire();
!         try {
              return mismatchSegmentSmall1.mismatch(mismatchSegmentSmall2);
-         } finally {
-             mismatchSegmentLarge1.scope().release(handle);
          }
      }
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
--- 148,13 ---
      }
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public long mismatch_small_segment_acquire() {
!         try (ResourceScope scope = ResourceScope.newConfinedScope()) {
!             scope.keepAlive(mismatchSegmentLarge1.scope());
              return mismatchSegmentSmall1.mismatch(mismatchSegmentSmall2);
          }
      }
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
< prev index next >