diff options
author | Bogdan Drutu <bdrutu@google.com> | 2017-04-12 18:39:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-12 18:39:10 -0700 |
commit | e0f6ae0640ac9ebeb20733aa8b5400d5b8261ed7 (patch) | |
tree | 38ffd5bc439b3e4357f7b3166298064a192dc882 /benchmarks/src | |
parent | 5bae08320e7c285172b006f2319c75e9097aaf78 (diff) | |
download | opencensus-java-e0f6ae0640ac9ebeb20733aa8b5400d5b8261ed7.tar.gz |
BinaryPropagationHandler split between interface and implementation. (#203)
* PropagationUtil split between BinaryPropagationHandler (for the interface definition) and BinaryPropagationHandlerImpl (for the implementation).
Diffstat (limited to 'benchmarks/src')
-rw-r--r-- | benchmarks/src/jmh/java/com/google/instrumentation/trace/BinaryPropagationHandlerImplBenchmark.java | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/benchmarks/src/jmh/java/com/google/instrumentation/trace/BinaryPropagationHandlerImplBenchmark.java b/benchmarks/src/jmh/java/com/google/instrumentation/trace/BinaryPropagationHandlerImplBenchmark.java index e0aaa38f..32e7a154 100644 --- a/benchmarks/src/jmh/java/com/google/instrumentation/trace/BinaryPropagationHandlerImplBenchmark.java +++ b/benchmarks/src/jmh/java/com/google/instrumentation/trace/BinaryPropagationHandlerImplBenchmark.java @@ -20,7 +20,6 @@ import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Mode; import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; /** Benchmarks for {@link BinaryPropagationHandler}. */ @@ -33,48 +32,44 @@ public class BinaryPropagationHandlerImplBenchmark { private static final SpanId spanId = SpanId.fromBytes(spanIdBytes); private static final byte[] traceOptionsBytes = new byte[] {1}; private static final TraceOptions traceOptions = TraceOptions.fromBytes(traceOptionsBytes); - private SpanContext spanContext; - private byte[] spanContextBinary; - - /** Setup function for benchmarks. */ - @Setup - public void setUp() { - spanContext = new SpanContext(traceId, spanId, traceOptions); - spanContextBinary = BinaryPropagationHandler.toBinaryValue(spanContext); - } + private static final SpanContext spanContext = new SpanContext(traceId, spanId, traceOptions); + private static final BinaryPropagationHandler binaryPropagationHandler = + BinaryPropagationHandlerImpl.INSTANCE; + private static final byte[] spanContextBinary = + binaryPropagationHandler.toBinaryValue(spanContext); /** * This benchmark attempts to measure performance of {@link - * BinaryPropagationHandler#toBinaryValue(SpanContext)}. + * BinaryPropagationHandlerImpl#toBinaryValue(SpanContext)}. */ @Benchmark @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public byte[] toBinaryValueSpanContext() { - return BinaryPropagationHandler.toBinaryValue(spanContext); + return binaryPropagationHandler.toBinaryValue(spanContext); } /** * This benchmark attempts to measure performance of {@link - * BinaryPropagationHandler#fromBinaryValue(byte[])}. + * BinaryPropagationHandlerImpl#fromBinaryValue(byte[])}. */ @Benchmark @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public SpanContext fromBinaryValueSpanContext() throws ParseException { - return BinaryPropagationHandler.fromBinaryValue(spanContextBinary); + return binaryPropagationHandler.fromBinaryValue(spanContextBinary); } /** * This benchmark attempts to measure performance of {@link - * BinaryPropagationHandler#toBinaryValue(SpanContext)} then {@link - * BinaryPropagationHandler#fromBinaryValue(byte[])}. + * BinaryPropagationHandlerImpl#toBinaryValue(SpanContext)} then {@link + * BinaryPropagationHandlerImpl#fromBinaryValue(byte[])}. */ @Benchmark @BenchmarkMode(Mode.SampleTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public SpanContext toFromBinarySpanContext() throws ParseException { - return BinaryPropagationHandler.fromBinaryValue( - BinaryPropagationHandler.toBinaryValue(spanContext)); + return binaryPropagationHandler.fromBinaryValue( + binaryPropagationHandler.toBinaryValue(spanContext)); } } |