Skip to content

Remove old benchmark infra and replace with package-benchmark #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Benchmarks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.build/
Empty file added Benchmarks/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2020-2023 Apple Inc. and the Swift Distributed Tracing project
// authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

import Benchmark
import Tracing

let benchmarks = {
let defaultMetrics: [BenchmarkMetric] = [
.mallocCountTotal,
]

Benchmark(
"NoopTracing.startSpan/endSpan",
configuration: .init(
metrics: defaultMetrics,
timeUnits: .nanoseconds,
scalingFactor: .mega
)
) { benchmark in
let span = startSpan("name")
defer { span.end() }
}

Benchmark(
"NoopTracing.attribute: set, span.attributes['http.status_code'] = 200",
configuration: .init(
metrics: defaultMetrics,
timeUnits: .nanoseconds,
scalingFactor: .mega
)
) { benchmark in
let span = startSpan("name")
span.attributes["http.status_code"] = 200
defer { span.end() }
}

Benchmark(
"NoopTracing.attribute: set, span.attributes.http.status_code = 200",
configuration: .init(
metrics: defaultMetrics,
timeUnits: .nanoseconds,
scalingFactor: .mega
)
) { benchmark in
let span = startSpan("name")
span.attributes.http.statusCode = 200
defer { span.end() }
}
}

@dynamicMemberLookup
struct HTTPAttributes: SpanAttributeNamespace {
var attributes: SpanAttributes

init(attributes: SpanAttributes) {
self.attributes = attributes
}

struct NestedSpanAttributes: NestedSpanAttributesProtocol {
init() {}

var method: Key<String> { "http.method" }
var statusCode: Key<Int> { "http.status_code" }
}
}

extension SpanAttributes {
var http: HTTPAttributes {
get {
.init(attributes: self)
}
set {
self = newValue.attributes
}
}
}
86 changes: 86 additions & 0 deletions Benchmarks/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions Benchmarks/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// swift-tools-version: 5.9
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftCertificates open source project
//
// Copyright (c) 2023 Apple Inc. and the SwiftCertificates project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftCertificates project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

import PackageDescription

let package = Package(
name: "benchmarks",
platforms: [
.macOS("14"),
],
dependencies: [
.package(path: "../"),
.package(url: "https://github.com/ordo-one/package-benchmark.git", from: "1.22.0"),
],
targets: [
.executableTarget(
name: "TracingBenchmarks",
dependencies: [
.product(name: "Benchmark", package: "package-benchmark"),
.product(name: "Tracing", package: "swift-distributed-tracing"),
],
path: "Benchmarks/TracingBenchmarks",
plugins: [
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
]
),
]
)
19 changes: 0 additions & 19 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,5 @@ let package = Package(
.target(name: "Tracing"),
]
),

// ==== --------------------------------------------------------------------------------------------------------
// MARK: Performance / Benchmarks

.executableTarget(
name: "_TracingBenchmarks",
dependencies: [
.product(name: "ServiceContextModule", package: "swift-service-context"),
.target(name: "Tracing"),
.target(name: "_TracingBenchmarkTools"),
]
),
.target(
name: "_TracingBenchmarkTools",
dependencies: [
.target(name: "Instrumentation"),
],
exclude: ["README_SWIFT.md"]
),
]
)
Loading