From 9a806026cbb674362be2058f9c516445ded5092f Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Tue, 20 May 2025 17:03:42 -0700 Subject: [PATCH 01/14] Update Xcode/SwiftPM fluff --- .gitignore | 2 + .swiftpm/configuration/Package.resolved | 25 +++++ ...ift-collections-benchmark-Package.xcscheme | 91 ------------------- ...e => swift-collections-benchmark.xcscheme} | 7 +- 4 files changed, 31 insertions(+), 94 deletions(-) create mode 100644 .swiftpm/configuration/Package.resolved delete mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/swift-collections-benchmark-Package.xcscheme rename .swiftpm/xcode/xcshareddata/xcschemes/{CollectionsBenchmark.xcscheme => swift-collections-benchmark.xcscheme} (94%) diff --git a/.gitignore b/.gitignore index c213bfa..286e2a2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ /*.xcodeproj xcuserdata/ /Results +/Documentation/Example/.build +/Documentation/Example/Package.resolved diff --git a/.swiftpm/configuration/Package.resolved b/.swiftpm/configuration/Package.resolved new file mode 100644 index 0000000..d874c62 --- /dev/null +++ b/.swiftpm/configuration/Package.resolved @@ -0,0 +1,25 @@ +{ + "object": { + "pins": [ + { + "package": "swift-argument-parser", + "repositoryURL": "https://github.com/apple/swift-argument-parser", + "state": { + "branch": null, + "revision": "41982a3656a71c768319979febd796c6fd111d5c", + "version": "1.5.0" + } + }, + { + "package": "swift-system", + "repositoryURL": "https://github.com/apple/swift-system", + "state": { + "branch": null, + "revision": "d2ba781702a1d8285419c15ee62fd734a9437ff5", + "version": "1.3.2" + } + } + ] + }, + "version": 1 +} diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/swift-collections-benchmark-Package.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/swift-collections-benchmark-Package.xcscheme deleted file mode 100644 index 53d0ac4..0000000 --- a/.swiftpm/xcode/xcshareddata/xcschemes/swift-collections-benchmark-Package.xcscheme +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/CollectionsBenchmark.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/swift-collections-benchmark.xcscheme similarity index 94% rename from .swiftpm/xcode/xcshareddata/xcschemes/CollectionsBenchmark.xcscheme rename to .swiftpm/xcode/xcshareddata/xcschemes/swift-collections-benchmark.xcscheme index 78cad2d..02a0d53 100644 --- a/.swiftpm/xcode/xcshareddata/xcschemes/CollectionsBenchmark.xcscheme +++ b/.swiftpm/xcode/xcshareddata/xcschemes/swift-collections-benchmark.xcscheme @@ -1,10 +1,11 @@ + buildImplicitDependencies = "YES" + buildArchitectures = "Automatic"> + shouldAutocreateTestPlan = "YES"> From b306c88e1407428592c51a867ff5082b58f272ac Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Tue, 20 May 2025 17:04:34 -0700 Subject: [PATCH 02/14] Stop supporting a built-in chart library --- .../Benchmark/Benchmark+ChartLibrary.swift | 12 +++--------- .../CollectionsBenchmark/Benchmark/Benchmark.swift | 4 +--- .../BenchmarkCLI/BenchmarkCLI+Library+List.swift | 4 ++-- .../BenchmarkCLI/BenchmarkCLI+Library+Render.swift | 4 ++-- .../BenchmarkCLI/BenchmarkCLI+Library+Run.swift | 4 ++-- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Sources/CollectionsBenchmark/Benchmark/Benchmark+ChartLibrary.swift b/Sources/CollectionsBenchmark/Benchmark/Benchmark+ChartLibrary.swift index b3c334c..d684235 100644 --- a/Sources/CollectionsBenchmark/Benchmark/Benchmark+ChartLibrary.swift +++ b/Sources/CollectionsBenchmark/Benchmark/Benchmark+ChartLibrary.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -47,14 +47,8 @@ extension Benchmark.ChartLibrary { } extension Benchmark { - internal func _loadLibrary(_ path: FilePath?) throws -> ChartLibrary { - if let path = path { - return try Benchmark.ChartLibrary.load(from: path) - } - if let library = self.chartLibrary { - return library - } - throw Benchmark.Error("No predefined library configuration") + internal func _loadLibrary(_ path: FilePath) throws -> ChartLibrary { + try Benchmark.ChartLibrary.load(from: path) } } diff --git a/Sources/CollectionsBenchmark/Benchmark/Benchmark.swift b/Sources/CollectionsBenchmark/Benchmark/Benchmark.swift index 94f84b4..da31f2c 100644 --- a/Sources/CollectionsBenchmark/Benchmark/Benchmark.swift +++ b/Sources/CollectionsBenchmark/Benchmark/Benchmark.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -17,8 +17,6 @@ public struct Benchmark { internal var _inputGenerators: [_TypeBox: (Int) -> Any] = [:] private let _executionContext = _ExecutionContext.shared - public var chartLibrary: ChartLibrary? = nil - public init(title: String = "") { self.title = title registerInputGenerator(for: Int.self) { size in diff --git a/Sources/CollectionsBenchmark/BenchmarkCLI/BenchmarkCLI+Library+List.swift b/Sources/CollectionsBenchmark/BenchmarkCLI/BenchmarkCLI+Library+List.swift index 5a72898..4981fb4 100644 --- a/Sources/CollectionsBenchmark/BenchmarkCLI/BenchmarkCLI+Library+List.swift +++ b/Sources/CollectionsBenchmark/BenchmarkCLI/BenchmarkCLI+Library+List.swift @@ -21,10 +21,10 @@ extension _BenchmarkCLI.Library { } @Option( - help: "Path to a library configuration file in JSON format. (default: built-in library)", + help: "Path to a library configuration file in JSON format.", completion: .file(extensions: ["json"]), transform: { str in FilePath(str) }) - var library: FilePath? + var library: FilePath @Flag(help: "List all tasks included in the library.") var tasks = false diff --git a/Sources/CollectionsBenchmark/BenchmarkCLI/BenchmarkCLI+Library+Render.swift b/Sources/CollectionsBenchmark/BenchmarkCLI/BenchmarkCLI+Library+Render.swift index ea8413d..0ef6f69 100644 --- a/Sources/CollectionsBenchmark/BenchmarkCLI/BenchmarkCLI+Library+Render.swift +++ b/Sources/CollectionsBenchmark/BenchmarkCLI/BenchmarkCLI+Library+Render.swift @@ -22,10 +22,10 @@ extension _BenchmarkCLI.Library { } @Option( - help: "Path to a library configuration file in JSON format. (default: built-in library)", + help: "Path to a library configuration file in JSON format.", completion: .file(extensions: ["json"]), transform: { str in FilePath(str) }) - var library: FilePath? + var library: FilePath @Argument( help: "A path to a benchmark results document.", diff --git a/Sources/CollectionsBenchmark/BenchmarkCLI/BenchmarkCLI+Library+Run.swift b/Sources/CollectionsBenchmark/BenchmarkCLI/BenchmarkCLI+Library+Run.swift index b93c284..e7ab9ea 100644 --- a/Sources/CollectionsBenchmark/BenchmarkCLI/BenchmarkCLI+Library+Run.swift +++ b/Sources/CollectionsBenchmark/BenchmarkCLI/BenchmarkCLI+Library+Run.swift @@ -21,10 +21,10 @@ extension _BenchmarkCLI.Library { } @Option( - help: "Path to a library configuration file in JSON format. (default: built-in library)", + help: "Path to a library configuration file in JSON format.", completion: .file(extensions: ["json"]), transform: { str in FilePath(str) }) - internal var library: FilePath? + internal var library: FilePath @Argument( help: "Output filename.", From 3b0860532711e03af34261327ceec61d52194d7a Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Tue, 20 May 2025 17:05:31 -0700 Subject: [PATCH 03/14] Bump required toolchain to Swift 6.0, and minimum deployment target to macOS 15 This allows the use of new core stdlib primitives, like struct Duration or struct Atomic. --- Package.swift | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/Package.swift b/Package.swift index ef72721..d844311 100644 --- a/Package.swift +++ b/Package.swift @@ -1,9 +1,9 @@ -// swift-tools-version:5.3 +// swift-tools-version:6.1 //===----------------------------------------------------------------------===// // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -17,22 +17,13 @@ import PackageDescription // To use enable them, uncomment the corresponding lines or define them // from the package manager command line: // -// swift build -Xswiftc -DUSE_FOUNDATION_DATE +// swift build -Xswiftc -DSOME_SETTING var settings: [SwiftSetting]? = [ - - // On Apple platforms, measure time using Foundation's `Date` instead of - // the default method. This is useful when you want to run benchmarks - // on an operating system that predates the introduction of the function - // this package would otherwise be using. -// .define("USE_FOUNDATION_DATE"), ] -// Prevent SPM 5.3 from throwing an error on empty settings arrays. -// (This has been fixed in 5.4.) -if settings?.isEmpty == true { settings = nil } - let package = Package( name: "swift-collections-benchmark", + platforms: [.macOS(.v15), .iOS(.v18), .watchOS(.v11), .tvOS(.v18), .visionOS(.v2)], products: [ .library(name: "CollectionsBenchmark", targets: ["CollectionsBenchmark"]), ], From cb1db64e0afdaf38d300bea60f5137890de5153e Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Tue, 20 May 2025 17:22:27 -0700 Subject: [PATCH 04/14] Update to latest versions of dependencies --- Package.resolved | 43 +++++++++++++++++++++---------------------- Package.swift | 4 ++-- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Package.resolved b/Package.resolved index 018829f..bf10441 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,25 +1,24 @@ { - "object": { - "pins": [ - { - "package": "swift-argument-parser", - "repositoryURL": "https://github.com/apple/swift-argument-parser", - "state": { - "branch": null, - "revision": "9f39744e025c7d377987f30b03770805dcb0bcd1", - "version": "1.1.4" - } - }, - { - "package": "swift-system", - "repositoryURL": "https://github.com/apple/swift-system", - "state": { - "branch": null, - "revision": "025bcb1165deab2e20d4eaba79967ce73013f496", - "version": "1.2.1" - } + "originHash" : "fd8098c511befeb09e71e5c075df627eb95b2e9614a53e9c75cc58a439abf5ec", + "pins" : [ + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser", + "state" : { + "revision" : "41982a3656a71c768319979febd796c6fd111d5c", + "version" : "1.5.0" } - ] - }, - "version": 1 + }, + { + "identity" : "swift-system", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-system", + "state" : { + "revision" : "a34201439c74b53f0fd71ef11741af7e7caf01e1", + "version" : "1.4.2" + } + } + ], + "version" : 3 } diff --git a/Package.swift b/Package.swift index d844311..898ffc1 100644 --- a/Package.swift +++ b/Package.swift @@ -28,8 +28,8 @@ let package = Package( .library(name: "CollectionsBenchmark", targets: ["CollectionsBenchmark"]), ], dependencies: [ - .package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.4"), - .package(url: "https://github.com/apple/swift-system", from: "1.2.1"), + .package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"), + .package(url: "https://github.com/apple/swift-system", from: "1.4.2"), ], targets: [ .target( From 8526d9ff12d647a991fc353761532ef5a4721524 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Tue, 20 May 2025 17:26:27 -0700 Subject: [PATCH 05/14] Sprinkle Sendable annotations over the project --- .../CollectionsBenchmark/Basics/Measurement.swift | 4 ++-- .../Basics/Sample+Statistic.swift | 4 ++-- Sources/CollectionsBenchmark/Basics/Sample.swift | 4 ++-- Sources/CollectionsBenchmark/Basics/Size.swift | 4 ++-- .../CollectionsBenchmark/Basics/TaskResults.swift | 4 ++-- Sources/CollectionsBenchmark/Basics/Tick.swift | 2 +- Sources/CollectionsBenchmark/Basics/Time.swift | 4 ++-- .../Benchmark/Benchmark+Error.swift | 4 ++-- .../Benchmark/Benchmark+Event.swift | 4 ++-- .../Benchmark/BenchmarkResults.swift | 4 ++-- Sources/CollectionsBenchmark/Benchmark/TaskID.swift | 4 ++-- .../CollectionsBenchmark/Benchmark/_TypeBox.swift | 4 ++-- .../BenchmarkCLI/BenchmarkCLI+Render.swift | 12 +++++++----- .../Charts/Geometry/EdgeInsets.swift | 4 ++-- .../CollectionsBenchmark/Charts/Graphics/Color.swift | 4 ++-- .../CollectionsBenchmark/Charts/Graphics/Font.swift | 4 ++-- .../Charts/Graphics/Stroke.swift | 10 +++++----- .../CollectionsBenchmark/Charts/Graphics/Text.swift | 6 +++--- Sources/CollectionsBenchmark/Charts/Theme.swift | 10 +++++----- .../Utilities/_SimpleOrderedDictionary.swift | 8 +++++++- .../Utilities/_SimpleOrderedSet.swift | 6 +++++- .../Utilities/_SimpleSortedBag.swift | 4 +++- .../Utilities/_SimpleSortedDictionary.swift | 8 +++++++- 23 files changed, 71 insertions(+), 51 deletions(-) diff --git a/Sources/CollectionsBenchmark/Basics/Measurement.swift b/Sources/CollectionsBenchmark/Basics/Measurement.swift index 72d938d..c7a6328 100644 --- a/Sources/CollectionsBenchmark/Basics/Measurement.swift +++ b/Sources/CollectionsBenchmark/Basics/Measurement.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -11,7 +11,7 @@ /// A point in the document coordinate system, i.e., a pair of size and /// time values. -public struct Measurement: Hashable, Codable { +public struct Measurement: Sendable, Hashable, Codable { public let size: Size public let time: Time diff --git a/Sources/CollectionsBenchmark/Basics/Sample+Statistic.swift b/Sources/CollectionsBenchmark/Basics/Sample+Statistic.swift index 2030736..232a80f 100644 --- a/Sources/CollectionsBenchmark/Basics/Sample+Statistic.swift +++ b/Sources/CollectionsBenchmark/Basics/Sample+Statistic.swift @@ -2,7 +2,7 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -12,7 +12,7 @@ import ArgumentParser extension Sample { - public enum Statistic: Hashable { + public enum Statistic: Sendable, Hashable { case maximum case sigma(Int) case mean diff --git a/Sources/CollectionsBenchmark/Basics/Sample.swift b/Sources/CollectionsBenchmark/Basics/Sample.swift index e2304b8..d013898 100644 --- a/Sources/CollectionsBenchmark/Basics/Sample.swift +++ b/Sources/CollectionsBenchmark/Basics/Sample.swift @@ -2,14 +2,14 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// -public struct Sample: Equatable { +public struct Sample: Sendable, Equatable { // Sorted array of measured durations. internal var _times: _SimpleSortedBag