< prev index next >

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

Print this page
@@ -22,13 +22,12 @@
   */
  
  
  package org.openjdk.bench.java.lang;
  
- import java.util.concurrent.Callable;
+ import java.lang.ScopedValue.CallableOp;
  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.*;
  

@@ -126,20 +125,20 @@
      // destroy it.
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public int CreateBindThenGetThenRemove_ScopedValue() throws Exception {
-         return ScopedValue.where(sl1, THE_ANSWER).call(sl1::get);
+         return ScopedValue.callWhere(sl1, THE_ANSWER, sl1::get);
      }
  
  
      // Create a Carrier ahead of time: might be slightly faster
      private static final ScopedValue.Carrier HOLD_42 = ScopedValue.where(sl1, 42);
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public int bindThenGetThenRemove_ScopedValue() throws Exception {
-         return HOLD_42.call(sl1::get);
+         return ScopedValue.callWhere(HOLD_42, sl1::get);
      }
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public int bindThenGetThenRemove_ThreadLocal() throws Exception {

@@ -162,22 +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(aCallable);
+         return ScopedValue.callWhere(HOLD_42, aCallableOp);
      }
-     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;
+     private static final CallableOp<Class<?>, RuntimeException> aCallableOp = () -> ScopedValues.class;
  
      @Benchmark
      @OutputTimeUnit(TimeUnit.NANOSECONDS)
      public Object bind_ThreadLocal() throws Exception {
          try {
< prev index next >