Skip to content
Open
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
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ let disableJemalloc = ProcessInfo.processInfo.environment["BENCHMARK_DISABLE_JEM
let package = Package(
name: "Benchmark",
platforms: [
.macOS(.v13),
.iOS(.v16)
.macOS(.v10_15),
.iOS(.v13),
],
products: [
.plugin(name: "BenchmarkCommandPlugin", targets: ["BenchmarkCommandPlugin"]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct Benchmark: AsyncParsableCommand {
import Benchmark

@main
@available(macOS 13, iOS 16, tvOS 16, *)
struct BenchmarkRunner: BenchmarkRunnerHooks {
static func registerBenchmarks() {
_ = benchmarks()
Expand Down
4 changes: 4 additions & 0 deletions Plugins/BenchmarkTool/BenchmarkTool+Baselines.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct BenchmarkIdentifier: Codable, Hashable {
}
}

@available(macOS 13, iOS 16, tvOS 16, *)
extension Benchmark {
var benchmarkIdentifier: BenchmarkIdentifier {
.init(target: self.target, name: self.name)
Expand Down Expand Up @@ -177,6 +178,7 @@ struct BenchmarkBaseline: Codable {

let baselinesDirectory: String = ".benchmarkBaselines"

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkTool {
func printAllBaselines() {
var storagePath = FilePath(baselineStoragePath)
Expand Down Expand Up @@ -391,6 +393,7 @@ extension BenchmarkTool {
}
}

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkBaseline {
func thresholdsForBenchmarks(
_ benchmarks: [Benchmark],
Expand All @@ -417,6 +420,7 @@ extension BenchmarkBaseline {
}
}

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkBaseline: Equatable {
public func deviationsComparedToBaseline(_ rhs: BenchmarkBaseline,
benchmarks: [Benchmark]) -> BenchmarkResult.ThresholdDeviations {
Expand Down
1 change: 1 addition & 0 deletions Plugins/BenchmarkTool/BenchmarkTool+CreateBenchmark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import SystemPackage
#error("Unsupported Platform")
#endif

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkTool {
var benchmarksDirectory: String { "Benchmarks" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class InfluxCSVFormatter {
}
}

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkTool {
func convertToInflux(_ baseline: BenchmarkBaseline) throws -> String {
var outputString = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extension JMHPrimaryMetric {
}
}

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkTool {
func convertToJMH(_ baseline: BenchmarkBaseline) throws -> String {
var resultString = ""
Expand Down
1 change: 1 addition & 0 deletions Plugins/BenchmarkTool/BenchmarkTool+Export.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import SystemPackage
#error("Unsupported Platform")
#endif

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkTool {
func write(exportData: String,
hostIdentifier: String? = nil,
Expand Down
1 change: 1 addition & 0 deletions Plugins/BenchmarkTool/BenchmarkTool+JSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Benchmark
import Foundation
import SystemPackage

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkTool {
func write(_ reply: BenchmarkCommandRequest) throws {
let bytesArray = try JSONEncoder().encode(reply)
Expand Down
1 change: 1 addition & 0 deletions Plugins/BenchmarkTool/BenchmarkTool+Machine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Benchmark
#error("Unsupported Platform")
#endif

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkTool {
func benchmarkMachine() -> BenchmarkMachine {
let processors = sysconf(Int32(_SC_NPROCESSORS_ONLN))
Expand Down
1 change: 1 addition & 0 deletions Plugins/BenchmarkTool/BenchmarkTool+Operations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Foundation
import SystemPackage
import TextTable

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkTool {
mutating func queryBenchmarks(_ benchmarkPath: String) throws {
try write(.list)
Expand Down
1 change: 1 addition & 0 deletions Plugins/BenchmarkTool/BenchmarkTool+PrettyPrinting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extension OutputFormat {
}
}

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkTool {
private func printMarkdown(_ markdown: String, terminator: String = "\n") {
if format == .markdown {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import SystemPackage
#error("Unsupported Platform")
#endif

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkTool {
/// `makeBenchmarkThresholds` is a convenience function for reading p90 static thresholds that previously have been exported with `metricP90AbsoluteThresholds`
///
Expand Down
1 change: 1 addition & 0 deletions Plugins/BenchmarkTool/BenchmarkTool+Thresholds.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fileprivate struct ThresholdsTableEntry {
var relative: Double
}

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkTool {
func printThresholds(_ staticThresholdsPerBenchmark: [BenchmarkIdentifier : [BenchmarkMetric: BenchmarkThresholds.AbsoluteThreshold]]) {

Expand Down
1 change: 1 addition & 0 deletions Plugins/BenchmarkTool/BenchmarkTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ typealias BenchmarkResults = [BenchmarkIdentifier: [BenchmarkResult]]
fileprivate var failedBenchmarkRuns = 0

@main
@available(macOS 13, iOS 16, tvOS 16, *)
struct BenchmarkTool: AsyncParsableCommand {
@Option(name: .long, help: "The paths to the benchmarks to run")
var benchmarkExecutablePaths: [String] = []
Expand Down
1 change: 1 addition & 0 deletions Sources/Benchmark/Benchmark+ConvenienceInitializers.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@available(macOS 13, iOS 16, tvOS 16, *)
public extension Benchmark {
/// Definition of a Benchmark
/// - Parameters:
Expand Down
3 changes: 3 additions & 0 deletions Sources/Benchmark/Benchmark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Foundation
// swiftlint:disable file_length identifier_name

/// Defines a benchmark
@available(macOS 13, iOS 16, tvOS 16, *)
public final class Benchmark: Codable, Hashable { // swiftlint:disable:this type_body_length
@_documentation(visibility: internal)
public typealias BenchmarkClosure = (_ benchmark: Benchmark) -> Void
Expand Down Expand Up @@ -427,6 +428,7 @@ public final class Benchmark: Codable, Hashable { // swiftlint:disable:this type
}
}

@available(macOS 13, iOS 16, tvOS 16, *)
public extension Benchmark {
/// The configuration settings for running a benchmark.
struct Configuration: Codable {
Expand Down Expand Up @@ -505,6 +507,7 @@ public extension Benchmark {
// This is an additional convenience duplicating the free standing function blackHole() for those cases where
// another module happens to define it, as we have a type clash between module name and type name and otherwise
// the user would need to do `import func Benchmark.blackHole` which isn't that obvious - thus this duplication.
@available(macOS 13, iOS 16, tvOS 16, *)
public extension Benchmark {
/// A function to foil compiler optimizations that would otherwise optimize out code you want to benchmark.
///
Expand Down
5 changes: 5 additions & 0 deletions Sources/Benchmark/BenchmarkClock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Glibc
#endif

@_documentation(visibility: internal)
@available(macOS 13, iOS 16, tvOS 16, *)
public struct BenchmarkClock {
/// A continuous point in time used for `BenchmarkClock`.
public struct Instant: Codable, Sendable {
Expand All @@ -37,6 +38,7 @@ public struct BenchmarkClock {
}

@_documentation(visibility: internal)
@available(macOS 13, iOS 16, tvOS 16, *)
public extension Clock where Self == BenchmarkClock {
/// A clock that measures time that always increments but does not stop
/// incrementing while the system is asleep.
Expand All @@ -47,6 +49,7 @@ public extension Clock where Self == BenchmarkClock {
}

@_documentation(visibility: internal)
@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkClock: Clock {
/// The current continuous instant.
public var now: BenchmarkClock.Instant {
Expand Down Expand Up @@ -118,6 +121,7 @@ extension BenchmarkClock: Clock {
}

@_documentation(visibility: internal)
@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkClock.Instant: InstantProtocol {
public static var now: BenchmarkClock.Instant { BenchmarkClock.now }

Expand Down Expand Up @@ -182,6 +186,7 @@ extension BenchmarkClock.Instant: InstantProtocol {
}

@_documentation(visibility: internal)
@available(macOS 13, iOS 16, tvOS 16, *)
public extension Duration {
func nanoseconds() -> Int64 {
(components.seconds * 1_000_000_000) + (components.attoseconds / 1_000_000_000)
Expand Down
4 changes: 4 additions & 0 deletions Sources/Benchmark/BenchmarkExecutor+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//
// swiftlint:disable cyclomatic_complexity

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkExecutor {
func performanceCountersNeeded(_ metric: BenchmarkMetric) -> Bool {
switch metric {
Expand All @@ -20,6 +21,7 @@ extension BenchmarkExecutor {
}
}

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkExecutor {
func mallocStatsProducerNeeded(_ metric: BenchmarkMetric) -> Bool {
switch metric {
Expand All @@ -39,6 +41,7 @@ extension BenchmarkExecutor {
}
}

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkExecutor {
func operatingSystemsStatsProducerNeeded(_ metric: BenchmarkMetric) -> Bool {
switch metric {
Expand Down Expand Up @@ -82,6 +85,7 @@ extension BenchmarkExecutor {
}
}

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkExecutor {
func arcStatsProducerNeeded(_ metric: BenchmarkMetric) -> Bool {
switch metric {
Expand Down
1 change: 1 addition & 0 deletions Sources/Benchmark/BenchmarkExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// swiftlint:disable file_length

@available(macOS 13, iOS 16, tvOS 16, *)
struct BenchmarkExecutor { // swiftlint:disable:this type_body_length
init(quiet: Bool = false) {
self.quiet = quiet
Expand Down
2 changes: 2 additions & 0 deletions Sources/Benchmark/BenchmarkInternals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

// Command sent from benchmark runner to the benchmark under measurement

@available(macOS 13, iOS 16, tvOS 16, *)
@_documentation(visibility: internal)
public enum BenchmarkCommandRequest: Codable {
case list
Expand All @@ -21,6 +22,7 @@ public enum BenchmarkCommandRequest: Codable {
}

// Replies from benchmark under measure to benchmark runner
@available(macOS 13, iOS 16, tvOS 16, *)
@_documentation(visibility: internal)
public enum BenchmarkCommandReply: Codable {
case list(benchmark: Benchmark)
Expand Down
2 changes: 2 additions & 0 deletions Sources/Benchmark/BenchmarkRunner+ReadWrite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import Foundation
import SystemPackage

// For test dependency injection
@available(macOS 13, iOS 16, tvOS 16, *)
protocol BenchmarkRunnerReadWrite {
func write(_ reply: BenchmarkCommandReply) throws
func read() throws -> BenchmarkCommandRequest
}

@available(macOS 13, iOS 16, tvOS 16, *)
extension BenchmarkRunner {
func write(_ reply: BenchmarkCommandReply) throws {
guard outputFD != nil else {
Expand Down
2 changes: 2 additions & 0 deletions Sources/Benchmark/BenchmarkRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ public protocol BenchmarkRunnerHooks {
}

@_documentation(visibility: internal)
@available(macOS 13, iOS 16, tvOS 16, *)
public extension BenchmarkRunnerHooks {
static func main() async {
await BenchmarkRunner.setupBenchmarkRunner(registerBenchmarks: registerBenchmarks)
}
}

@_documentation(visibility: internal)
@available(macOS 13, iOS 16, tvOS 16, *)
public struct BenchmarkRunner: AsyncParsableCommand, BenchmarkRunnerReadWrite {
static var testReadWrite: BenchmarkRunnerReadWrite?

Expand Down
Loading