Skip to content

Commit f2bf9fc

Browse files
authored
Don't run cpuTotal benchmark in CI (#551)
1 parent 595ffdb commit f2bf9fc

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

Benchmarks/Benchmarks/Router/Benchmarks.swift

+11-17
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,23 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import Benchmark
16+
import Foundation
1617
import Hummingbird
1718

1819
let benchmarks = {
19-
#if CI
2020
Benchmark.defaultConfiguration = .init(
21-
metrics: [
22-
.instructions,
23-
.mallocCountTotal,
24-
],
21+
metrics: ProcessInfo.processInfo.environment["CI"] != nil ?
22+
[
23+
.instructions,
24+
.mallocCountTotal,
25+
] :
26+
[
27+
.cpuTotal,
28+
.instructions,
29+
.mallocCountTotal,
30+
],
2531
warmupIterations: 10
2632
)
2733
trieRouterBenchmarks()
2834
routerBenchmarks()
29-
#else
30-
Benchmark.defaultConfiguration = .init(
31-
metrics: [
32-
.cpuTotal,
33-
.instructions,
34-
.mallocCountTotal,
35-
],
36-
warmupIterations: 10
37-
)
38-
trieRouterBenchmarks()
39-
routerBenchmarks()
40-
#endif
4135
}

Benchmarks/Benchmarks/Router/RouterBenchmarks.swift

+4-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public struct BenchmarkRequestContextSource: RequestContextSource {
4040

4141
/// Writes ByteBuffers to AsyncChannel outbound writer
4242
struct BenchmarkBodyWriter: Sendable, ResponseBodyWriter {
43-
func finish(_ trailingHeaders: HTTPFields?) async throws {}
43+
func finish(_: HTTPFields?) async throws {}
4444
func write(_: ByteBuffer) async throws {}
4545
}
4646

@@ -110,7 +110,6 @@ struct EmptyMiddleware<Context>: RouterMiddleware {
110110
}
111111
}
112112

113-
114113
extension HTTPField.Name {
115114
static let test = Self("Test")!
116115
}
@@ -168,7 +167,7 @@ func routerBenchmarks() {
168167
try await write(buffer)
169168
try await write(buffer)
170169
try await write(buffer)
171-
} createRouter: {
170+
} createRouter: {
172171
let router = Router(context: BasicBenchmarkContext.self)
173172
router.post { request, _ in
174173
Response(status: .ok, headers: [:], body: .init { writer in
@@ -185,7 +184,7 @@ func routerBenchmarks() {
185184
"Router:Middleware",
186185
configuration: .init(warmupIterations: 10),
187186
request: .init(method: .get, scheme: "http", authority: "localhost", path: "/")
188-
) {
187+
) {
189188
let router = Router(context: BasicBenchmarkContext.self)
190189
router.middlewares.add(EmptyMiddleware())
191190
router.middlewares.add(EmptyMiddleware())
@@ -207,7 +206,7 @@ func routerBenchmarks() {
207206
EmptyMiddleware()
208207
EmptyMiddleware()
209208
EmptyMiddleware()
210-
Get { _,_ -> HTTPResponse.Status in
209+
Get { _, _ -> HTTPResponse.Status in
211210
.ok
212211
}
213212
}

0 commit comments

Comments
 (0)