Skip to content

Commit b4c71be

Browse files
committed
more benchmarks
1 parent dfcbcdb commit b4c71be

2 files changed

Lines changed: 66 additions & 32 deletions

File tree

Benchmarks/Benchmarks/TracingBenchmarks/AtrributeDSLBenchmark.swift

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,66 @@ import Benchmark
1616
import Tracing
1717

1818
let benchmarks: @Sendable () -> Void = {
19-
let defaultMetrics: [BenchmarkMetric] = [
20-
.mallocCountTotal
21-
]
19+
let configurationWithMalloc: Benchmark.Configuration = .init(
20+
metrics: [
21+
.mallocCountTotal
22+
],
23+
timeUnits: .nanoseconds
24+
)
25+
26+
let configurationWithMallocAndInstructions: Benchmark.Configuration = .init(
27+
metrics: [
28+
.mallocCountTotal,
29+
.instructions,
30+
],
31+
timeUnits: .nanoseconds
32+
)
2233

2334
Benchmark(
2435
"NoopTracing.startSpan_endSpan",
25-
configuration: .init(
26-
metrics: defaultMetrics,
27-
timeUnits: .nanoseconds,
28-
scalingFactor: .mega
29-
)
36+
configuration: configurationWithMalloc
3037
) { benchmark in
3138
let span = startSpan("name")
3239
defer { span.end() }
3340
}
3441

42+
Benchmark(
43+
"NoopTracing.startSpan_endSpan.with_instructions",
44+
configuration: configurationWithMallocAndInstructions
45+
) { benchmark in
46+
let span = startSpan("name")
47+
defer { span.end() }
48+
}
49+
50+
Benchmark(
51+
"NoopTracing.startSpan_endSpan.withInstrumentScope",
52+
configuration: configurationWithMallocAndInstructions
53+
) { benchmark in
54+
withInstrument(NoOpInstrument()) {
55+
for _ in benchmark.scaledIterations {
56+
let span = startSpan("name")
57+
span.end()
58+
blackHole(span)
59+
}
60+
}
61+
}
62+
63+
Benchmark(
64+
"NoopTracing.startSpan_endSpan.withMultiplexScope",
65+
configuration: configurationWithMallocAndInstructions
66+
) { benchmark in
67+
withInstrument(MultiplexInstrument([NoOpInstrument(), NoOpInstrument()])) {
68+
for _ in benchmark.scaledIterations {
69+
let span = startSpan("name")
70+
span.end()
71+
blackHole(span)
72+
}
73+
}
74+
}
75+
3576
Benchmark(
3677
"NoopTracing.attribute. set, span.attributes['http.status_code'] = 200",
37-
configuration: .init(
38-
metrics: defaultMetrics,
39-
timeUnits: .nanoseconds,
40-
scalingFactor: .mega
41-
)
78+
configuration: configurationWithMalloc
4279
) { benchmark in
4380
let span = startSpan("name")
4481
span.attributes["http.status_code"] = 200
@@ -47,11 +84,7 @@ let benchmarks: @Sendable () -> Void = {
4784

4885
Benchmark(
4986
"NoopTracing.attribute. set, span.attributes.http.status_code = 200",
50-
configuration: .init(
51-
metrics: defaultMetrics,
52-
timeUnits: .nanoseconds,
53-
scalingFactor: .mega
54-
)
87+
configuration: configurationWithMalloc
5588
) { benchmark in
5689
let span = startSpan("name")
5790
span.attributes.http.statusCode = 200

Benchmarks/Package.resolved

Lines changed: 15 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)