< prev index next >

test/micro/org/openjdk/bench/java/lang/ScopedValues.java

Print this page
*** 22,13 ***
   */
  
  
  package org.openjdk.bench.java.lang;
  
! import java.util.concurrent.Callable;
  import java.util.concurrent.TimeUnit;
- import java.util.function.Supplier;
  import org.openjdk.jmh.annotations.*;
  import org.openjdk.jmh.infra.Blackhole;
  
  import static org.openjdk.bench.java.lang.ScopedValuesData.*;
  
--- 22,12 ---
   */
  
  
  package org.openjdk.bench.java.lang;
  
! import java.lang.ScopedValue.CallableOp;
  import java.util.concurrent.TimeUnit;
  import org.openjdk.jmh.annotations.*;
  import org.openjdk.jmh.infra.Blackhole;
  
  import static org.openjdk.bench.java.lang.ScopedValuesData.*;
  

*** 162,22 ***
  
      // Test 4: The cost of binding, but not using any result
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public Object bind_ScopedValue() throws Exception {
!         return HOLD_42.call(aCallable);
      }
!     private static final Callable<Class<?>> aCallable = () -> ScopedValues.class;
- 
-     // Same, but make sure that Carrier.get(Supplier) is no slower
-     // than Carrier.call(Callable).
-     @Benchmark
-     @OutputTimeUnit(TimeUnit.NANOSECONDS)
-     public Object bindViaGet_ScopedValue() {
-         return HOLD_42.get(aSupplier);
-     }
-     private static final Supplier<Class<?>> aSupplier = () -> ScopedValues.class;
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public Object bind_ThreadLocal() throws Exception {
          try {
--- 161,13 ---
  
      // Test 4: The cost of binding, but not using any result
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public Object bind_ScopedValue() throws Exception {
!         return HOLD_42.call(aCallableOp);
      }
!     private static final CallableOp<Class<?>, RuntimeException> aCallableOp = () -> ScopedValues.class;
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public Object bind_ThreadLocal() throws Exception {
          try {
< prev index next >