Adding micro-benchmarks for traceId and spanId generation (#2170)
This commit is contained in:
parent
e90a6a886b
commit
6bbe8d47dc
|
|
@ -3,6 +3,7 @@ plugins {
|
||||||
id "maven-publish"
|
id "maven-publish"
|
||||||
|
|
||||||
id "ru.vyarus.animalsniffer"
|
id "ru.vyarus.animalsniffer"
|
||||||
|
id "me.champeau.gradle.jmh"
|
||||||
}
|
}
|
||||||
|
|
||||||
description = 'OpenTelemetry SDK AWS Instrumentation Support'
|
description = 'OpenTelemetry SDK AWS Instrumentation Support'
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright The OpenTelemetry Authors
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.opentelemetry.sdk.extension.aws;
|
||||||
|
|
||||||
|
import io.opentelemetry.sdk.extension.aws.trace.AwsXrayIdGenerator;
|
||||||
|
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.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;
|
||||||
|
|
||||||
|
@State(Scope.Benchmark)
|
||||||
|
public class AwsXrayIdGeneratorBenchmark {
|
||||||
|
private final AwsXrayIdGenerator idGenerator = new AwsXrayIdGenerator();
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
@Measurement(iterations = 15, time = 1)
|
||||||
|
@Warmup(iterations = 5, time = 1)
|
||||||
|
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||||
|
@BenchmarkMode(Mode.AverageTime)
|
||||||
|
@Fork(1)
|
||||||
|
public String generateTraceId() {
|
||||||
|
return idGenerator.generateTraceId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
@Measurement(iterations = 15, time = 1)
|
||||||
|
@Warmup(iterations = 5, time = 1)
|
||||||
|
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||||
|
@BenchmarkMode(Mode.AverageTime)
|
||||||
|
@Fork(1)
|
||||||
|
public String generateSpanId() {
|
||||||
|
return idGenerator.generateSpanId();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue