-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Both `KeyValues` and `Tags` unconditionally maintain the invariant that they wrap distinct key-value pairs.
- Loading branch information
1 parent
9c4f5f2
commit 91f804c
Showing
6 changed files
with
67 additions
and
12 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
53 changes: 53 additions & 0 deletions
53
...re/observability/micrometer/MicrometerMeterListenerConfigurationResolveTagsBenchmark.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,53 @@ | ||
package reactor.core.observability.micrometer; | ||
|
||
import io.micrometer.core.instrument.Tags; | ||
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.Param; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
import org.reactivestreams.Publisher; | ||
import reactor.core.publisher.Mono; | ||
|
||
@BenchmarkMode({Mode.AverageTime}) | ||
@Warmup(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS) | ||
@Measurement(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS) | ||
@Fork(value = 1) | ||
@OutputTimeUnit(TimeUnit.NANOSECONDS) | ||
@State(Scope.Benchmark) | ||
public class MicrometerMeterListenerConfigurationResolveTagsBenchmark { | ||
@Param({"1", "2", "5", "10"}) | ||
private int distinctTagCount; | ||
|
||
@Param({"1", "2", "5", "10"}) | ||
private int totalTagCount; | ||
|
||
private Publisher<Void> publisher; | ||
|
||
@Setup(Level.Iteration) | ||
public void setup() { | ||
publisher = addTags(Mono.empty(), distinctTagCount, totalTagCount); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
@Benchmark | ||
public Tags measureThroughput() { | ||
return MicrometerMeterListenerConfiguration.resolveTags(publisher, Tags.of("k", "v")); | ||
} | ||
|
||
private static <T> Mono<T> addTags(Mono<T> source, int distinct, int total) { | ||
if (total == 0) { | ||
return source; | ||
} | ||
|
||
return addTags(source.tag("k-" + total % distinct, "v-" + total), distinct, total - 1); | ||
} | ||
} |
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
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