-
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.
Makes traceIdHigh convertable to AWS X-Ray
This customizes the trace ID generator to make the high bits convertable to Amazon X-Ray trace ID format v1. See openzipkin/zipkin#1754
- Loading branch information
Adrian Cole
committed
Oct 3, 2017
1 parent
a362bb9
commit ebde177
Showing
4 changed files
with
151 additions
and
1 deletion.
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
111 changes: 111 additions & 0 deletions
111
instrumentation/benchmarks/src/main/java/brave/internal/PlatformBenchmarks.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,111 @@ | ||
/** | ||
* Copyright 2015-2016 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; | ||
|
||
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.Group; | ||
import org.openjdk.jmh.annotations.GroupThreads; | ||
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.State; | ||
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; | ||
|
||
@Measurement(iterations = 5, time = 1) | ||
@Warmup(iterations = 10, time = 1) | ||
@Fork(3) | ||
@BenchmarkMode(Mode.Throughput) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
@State(Scope.Group) | ||
public class PlatformBenchmarks { | ||
Platform jre6 = Platform.Jre6.build(false); | ||
Platform jre7 = Platform.Jre7.buildIfSupported(false); | ||
|
||
@Benchmark @Group("no_contention") @GroupThreads(1) | ||
public long no_contention_nextTraceIdHigh_jre6() { | ||
return jre6.nextTraceIdHigh(); | ||
} | ||
|
||
@Benchmark @Group("mild_contention") @GroupThreads(2) | ||
public long mild_contention_nextTraceIdHigh_jre6() { | ||
return jre6.nextTraceIdHigh(); | ||
} | ||
|
||
@Benchmark @Group("high_contention") @GroupThreads(8) | ||
public long high_contention_nextTraceIdHigh_jre6() { | ||
return jre6.nextTraceIdHigh(); | ||
} | ||
|
||
@Benchmark @Group("no_contention") @GroupThreads(1) | ||
public long no_contention_randomLong_jre6() { | ||
return jre6.randomLong(); | ||
} | ||
|
||
@Benchmark @Group("mild_contention") @GroupThreads(2) | ||
public long mild_contention_randomLong_jre6() { | ||
return jre6.randomLong(); | ||
} | ||
|
||
@Benchmark @Group("high_contention") @GroupThreads(8) | ||
public long high_contention_randomLong_jre6() { | ||
return jre6.randomLong(); | ||
} | ||
|
||
@Benchmark @Group("no_contention") @GroupThreads(1) | ||
public long no_contention_nextTraceIdHigh_jre7() { | ||
return jre7.nextTraceIdHigh(); | ||
} | ||
|
||
@Benchmark @Group("mild_contention") @GroupThreads(2) | ||
public long mild_contention_nextTraceIdHigh_jre7() { | ||
return jre7.nextTraceIdHigh(); | ||
} | ||
|
||
@Benchmark @Group("high_contention") @GroupThreads(8) | ||
public long high_contention_nextTraceIdHigh_jre7() { | ||
return jre7.nextTraceIdHigh(); | ||
} | ||
|
||
@Benchmark @Group("no_contention") @GroupThreads(1) | ||
public long no_contention_randomLong_jre7() { | ||
return jre7.randomLong(); | ||
} | ||
|
||
@Benchmark @Group("mild_contention") @GroupThreads(2) | ||
public long mild_contention_randomLong_jre7() { | ||
return jre7.randomLong(); | ||
} | ||
|
||
@Benchmark @Group("high_contention") @GroupThreads(8) | ||
public long high_contention_randomLong_jre7() { | ||
return jre7.randomLong(); | ||
} | ||
|
||
// Convenience main entry-point | ||
public static void main(String[] args) throws RunnerException { | ||
Options opt = new OptionsBuilder() | ||
.include(".*" + PlatformBenchmarks.class.getSimpleName() + ".*") | ||
.build(); | ||
|
||
new Runner(opt).run(); | ||
} | ||
} |