Skip to content

Commit

Permalink
Don't run cpuTotal benchmark in CI (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler authored Sep 14, 2024
1 parent 595ffdb commit f2bf9fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
28 changes: 11 additions & 17 deletions Benchmarks/Benchmarks/Router/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,23 @@
//===----------------------------------------------------------------------===//

import Benchmark
import Foundation
import Hummingbird

let benchmarks = {
#if CI
Benchmark.defaultConfiguration = .init(
metrics: [
.instructions,
.mallocCountTotal,
],
metrics: ProcessInfo.processInfo.environment["CI"] != nil ?
[
.instructions,
.mallocCountTotal,
] :
[
.cpuTotal,
.instructions,
.mallocCountTotal,
],
warmupIterations: 10
)
trieRouterBenchmarks()
routerBenchmarks()
#else
Benchmark.defaultConfiguration = .init(
metrics: [
.cpuTotal,
.instructions,
.mallocCountTotal,
],
warmupIterations: 10
)
trieRouterBenchmarks()
routerBenchmarks()
#endif
}
9 changes: 4 additions & 5 deletions Benchmarks/Benchmarks/Router/RouterBenchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct BenchmarkRequestContextSource: RequestContextSource {

/// Writes ByteBuffers to AsyncChannel outbound writer
struct BenchmarkBodyWriter: Sendable, ResponseBodyWriter {
func finish(_ trailingHeaders: HTTPFields?) async throws {}
func finish(_: HTTPFields?) async throws {}
func write(_: ByteBuffer) async throws {}
}

Expand Down Expand Up @@ -110,7 +110,6 @@ struct EmptyMiddleware<Context>: RouterMiddleware {
}
}


extension HTTPField.Name {
static let test = Self("Test")!
}
Expand Down Expand Up @@ -168,7 +167,7 @@ func routerBenchmarks() {
try await write(buffer)
try await write(buffer)
try await write(buffer)
} createRouter: {
} createRouter: {
let router = Router(context: BasicBenchmarkContext.self)
router.post { request, _ in
Response(status: .ok, headers: [:], body: .init { writer in
Expand All @@ -185,7 +184,7 @@ func routerBenchmarks() {
"Router:Middleware",
configuration: .init(warmupIterations: 10),
request: .init(method: .get, scheme: "http", authority: "localhost", path: "/")
) {
) {
let router = Router(context: BasicBenchmarkContext.self)
router.middlewares.add(EmptyMiddleware())
router.middlewares.add(EmptyMiddleware())
Expand All @@ -207,7 +206,7 @@ func routerBenchmarks() {
EmptyMiddleware()
EmptyMiddleware()
EmptyMiddleware()
Get { _,_ -> HTTPResponse.Status in
Get { _, _ -> HTTPResponse.Status in
.ok
}
}
Expand Down

0 comments on commit f2bf9fc

Please sign in to comment.