Skip to content

Commit

Permalink
improve benchmark setup
Browse files Browse the repository at this point in the history
  • Loading branch information
t089 authored and slashmo committed Sep 14, 2024
1 parent 02f0088 commit 319810a
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@

import Benchmark
import OTel
import W3CTraceContext

let benchmarks = {
Benchmark("OTelTraceIdRatioBasedSampler") { benchmark in

let sampler = OTelTraceIdRatioBasedSampler(ratio: 0.5)
for _ in benchmark.scaledIterations {

let traceIds = benchmark.scaledIterations.map { _ in TraceID.random() }

benchmark.startMeasurement()

for traceId in traceIds {
_ = sampler.samplingResult(
operationName: "some-op",
kind: .internal,
traceID: .random(),
traceID: traceId,
attributes: [:],
links: [],
parentContext: .topLevel)
}

benchmark.stopMeasurement()
}
// Add additional benchmarks here
}

0 comments on commit 319810a

Please sign in to comment.