-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removes IpLiteral dependency from ZipkinV2JsonWriter (#1414)
Signed-off-by: Adrian Cole <[email protected]>
- Loading branch information
1 parent
710e7c3
commit 665e3e8
Showing
4 changed files
with
103 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...mentation/benchmarks/src/main/java/brave/internal/codec/ZipkinV2JsonWriterBenchmarks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2013-2024 The OpenZipkin Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package brave.internal.codec; | ||
|
||
import brave.Tags; | ||
import brave.handler.MutableSpan; | ||
import java.util.concurrent.TimeUnit; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Level; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
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; | ||
import org.openjdk.jmh.annotations.Threads; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
import org.openjdk.jmh.runner.Runner; | ||
import org.openjdk.jmh.runner.RunnerException; | ||
import org.openjdk.jmh.runner.options.Options; | ||
import org.openjdk.jmh.runner.options.OptionsBuilder; | ||
|
||
import static brave.handler.MutableSpanBenchmarks.newBigClientMutableSpan; | ||
import static brave.handler.MutableSpanBenchmarks.newServerMutableSpan; | ||
|
||
@Measurement(iterations = 5, time = 1) | ||
@Warmup(iterations = 10, time = 1) | ||
@Fork(3) | ||
@BenchmarkMode(Mode.SampleTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
@State(Scope.Thread) | ||
@Threads(1) | ||
public class ZipkinV2JsonWriterBenchmarks { | ||
|
||
static final ZipkinV2JsonWriter writer = new ZipkinV2JsonWriter(Tags.ERROR); | ||
static final MutableSpan serverSpan = newServerMutableSpan(); | ||
static final MutableSpan bigClientSpan = newBigClientMutableSpan(); | ||
static final byte[] buffer = new byte[1024]; | ||
|
||
@Benchmark public int sizeInBytes_serverSpan() { | ||
return writer.sizeInBytes(serverSpan); | ||
} | ||
|
||
@Benchmark public void write_serverSpan() { | ||
writer.write(serverSpan, new WriteBuffer(buffer, 0)); | ||
} | ||
|
||
@Benchmark public int sizeInBytes_bigClientSpan() { | ||
return writer.sizeInBytes(bigClientSpan); | ||
} | ||
|
||
@Benchmark public void write_bigClientSpan() { | ||
writer.write(bigClientSpan, new WriteBuffer(buffer, 0)); | ||
} | ||
|
||
// Convenience main entry-point | ||
public static void main(String[] args) throws RunnerException { | ||
Options opt = new OptionsBuilder() | ||
.addProfiler("gc") | ||
.include(".*" + ZipkinV2JsonWriter.class.getSimpleName() + ".*") | ||
.build(); | ||
|
||
new Runner(opt).run(); | ||
} | ||
} |