MCPcopy Create free account
hub / github.com/grpc/grpc-java / AttachDetachBenchmark

Class AttachDetachBenchmark

api/src/jmh/java/io/grpc/AttachDetachBenchmark.java:29–50  ·  view source on GitHub ↗

StatusBenchmark.

Source from the content-addressed store, hash-verified

27
28/** StatusBenchmark. */
29@State(Scope.Benchmark)
30public class AttachDetachBenchmark {
31
32 private final Context.Key<Integer> key = Context.keyWithDefault("key", 9999);
33 private final Context cu = Context.current().withValue(key, 8888);
34
35 /**
36 * Javadoc comment.
37 */
38 @Benchmark
39 @BenchmarkMode(Mode.SampleTime)
40 @OutputTimeUnit(TimeUnit.NANOSECONDS)
41 @GroupThreads(6)
42 public int attachDetach() {
43 Context old = cu.attach();
44 try {
45 return key.get();
46 } finally {
47 Context.current().detach(old);
48 }
49 }
50}

Callers

nothing calls this directly

Calls 3

keyWithDefaultMethod · 0.95
currentMethod · 0.95
withValueMethod · 0.80

Tested by

no test coverage detected