mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8331189: Implementation of Scoped Values (Third Preview)
Reviewed-by: aph, jpai, mcimadamore
This commit is contained in:
parent
4acafb809c
commit
707154235b
7 changed files with 96 additions and 268 deletions
|
@ -24,9 +24,8 @@
|
|||
|
||||
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;
|
||||
|
||||
|
@ -164,18 +163,9 @@ public class ScopedValues {
|
|||
@Benchmark
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
public Object bind_ScopedValue() throws Exception {
|
||||
return HOLD_42.call(aCallable);
|
||||
return HOLD_42.call(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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue