Skip to content

Commit 0ffa27a

Browse files
committed
Make Benchmarks better
1 parent 31f491c commit 0ffa27a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Diff for: Benchmarks/Benchmarks/NIOPosixBenchmarks/Benchmarks.swift

+17-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ private let eventLoop = MultiThreadedEventLoopGroup.singleton.next()
2020
let benchmarks = {
2121
let defaultMetrics: [BenchmarkMetric] = [
2222
.mallocCountTotal,
23-
.cpuTotal
23+
.cpuTotal,
24+
.contextSwitches
2425
]
2526

2627
Benchmark(
27-
"TCPEcho",
28+
"TCPEcho pure NIO 1M times",
2829
configuration: .init(
2930
metrics: defaultMetrics,
3031
scalingFactor: .one
@@ -36,6 +37,19 @@ let benchmarks = {
3637
)
3738
}
3839

40+
Benchmark(
41+
"TCPEcho pure async/await NIO 1M times",
42+
configuration: .init(
43+
metrics: defaultMetrics,
44+
scalingFactor: .one
45+
)
46+
) { benchmark in
47+
try await runTCPEchoAsyncChannel(
48+
numberOfWrites: 1_000_000,
49+
eventLoop: eventLoop
50+
)
51+
}
52+
3953
// This benchmark is only available above 5.9 since our EL conformance
4054
// to serial executor is also gated behind 5.9.
4155
#if compiler(>=5.9)
@@ -67,7 +81,7 @@ let benchmarks = {
6781
#if compiler(>=6.0)
6882
if #available(macOS 15.0, *) {
6983
Benchmark(
70-
"TCPEchoAsyncChannel using task executor preference",
84+
"TCPEchoAsyncChannel using task executor preference 1M times",
7185
configuration: .init(
7286
metrics: defaultMetrics,
7387
scalingFactor: .one

0 commit comments

Comments
 (0)