Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup jmh and trace context benchmarks #920

Merged
merged 1 commit into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;
Expand Down Expand Up @@ -63,10 +64,11 @@ public void setup() {
}

@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime})
@BenchmarkMode({Mode.AverageTime})
@Fork(1)
@Measurement(iterations = 15, time = 1)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 50_000, time = 1, timeUnit = TimeUnit.MILLISECONDS)
public SpanContext measureExtract() {
return httpTraceContext.extract(carrier, getter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
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.State;
import org.openjdk.jmh.annotations.TearDown;
Expand Down Expand Up @@ -62,10 +63,11 @@ public void set(Map<String, String> carrier, String key, String value) {

/** Benchmark for measuring inject with default trace state and sampled trace options. */
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime})
@BenchmarkMode({Mode.AverageTime})
@Fork(1)
@Measurement(iterations = 15, time = 1)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 50_000, time = 1, timeUnit = TimeUnit.MILLISECONDS)
public Map<String, String> measureInject() {
httpTraceContext.inject(contextToTest, carrier, setter);
return carrier;
Expand Down
10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ subprojects {
findBugsJsr305Version = '3.0.2'
grpcVersion = '1.24.0'
guavaVersion = '28.1-android'
jmhVersion = '1.19'
opentracingVersion = '0.33.0'
protobufVersion = '3.9.0'
protocVersion = '3.9.0'
Expand All @@ -107,6 +108,8 @@ subprojects {
grpc_stub : "io.grpc:grpc-stub:${grpcVersion}",
guava : "com.google.guava:guava:${guavaVersion}",
javax_annotations : "javax.annotation:javax.annotation-api:1.3.2",
jmh_core : "org.openjdk.jmh:jmh-core:${jmhVersion}",
jmh_bytecode : "org.openjdk.jmh:jmh-generator-bytecode:${jmhVersion}",
jsr305 : "com.google.code.findbugs:jsr305:${findBugsJsr305Version}",
protobuf : "com.google.protobuf:protobuf-java:${protobufVersion}",
protobuf_util : "com.google.protobuf:protobuf-java-util:${protobufVersion}",
Expand Down Expand Up @@ -229,22 +232,21 @@ subprojects {
// Always include the jmhreport plugin and run it after jmh task.
pluginManager.apply "io.morethan.jmhreport"
dependencies {
jmh 'org.openjdk.jmh:jmh-core:1.19',
'org.openjdk.jmh:jmh-generator-bytecode:1.19'
jmh libraries.jmh_core,
libraries.jmh_bytecode
}

// invoke jmh on a single benchmark class like so:
// ./gradlew -PjmhIncludeSingleClass=StatsTraceContextBenchmark clean :grpc-core:jmh
jmh {
warmupIterations = 5
iterations = 10
fork = 1
failOnError = true
resultFormat = 'JSON'
// None of our benchmarks need the tests, and we have pseudo-circular
// dependencies that break when including them. (context's testCompile
// depends on core; core's testCompile depends on testing)
includeTests = false
profilers = ["gc"]
if (project.hasProperty('jmhIncludeSingleClass')) {
include = [
project.property('jmhIncludeSingleClass')
Expand Down