diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..908ae16
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,24 @@
+root = true
+
+[*]
+charset = utf-8
+insert_final_newline = true
+end_of_line = lf
+trim_trailing_whitespace = true
+
+[*.{swift,swift.gyb,cpp,h,yml}]
+indent_style = space
+tab_width = 4
+indent_size = 2
+
+[*.{sh,py}]
+indent_style = space
+indent_size = 4
+
+[.swiftci/*}]
+indent_style = space
+indent_size = 4
+
+[*.{md,txt}]
+indent_style = space
+indent_size = 2
diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml
index 4902e36..f2be977 100644
--- a/.github/workflows/pull_request.yml
+++ b/.github/workflows/pull_request.yml
@@ -8,6 +8,9 @@ jobs:
tests:
name: Test
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
+ with:
+ linux_exclude_swift_versions: '[{"swift_version": "5.8"}, {"swift_version": "5.9"}, {"swift_version": "5.10"}, {"swift_version": "6.0"}]'
+ windows_exclude_swift_versions: '[{"swift_version": "5.9"}, {"swift_version": "5.10"}, {"swift_version": "6.0"}]'
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
@@ -16,3 +19,5 @@ jobs:
license_header_check_enabled: false
unacceptable_language_check_enabled: false
format_check_enabled: false
+ api_breakage_check_enabled: false
+ docs_check_enabled: false
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/.spi.yml b/.spi.yml
index e492387..6398aa8 100644
--- a/.spi.yml
+++ b/.spi.yml
@@ -1,4 +1,4 @@
version: 1
builder:
configs:
- - documentation_targets: [CollectionsBenchmark]
\ No newline at end of file
+ - documentation_targets: [CollectionsBenchmark]
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">
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 ef72721..43e581f 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,28 +17,21 @@ 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
-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"),
+// swift build -Xswiftc -DSOME_SETTING
+let settings: [SwiftSetting] = [
+ .enableUpcomingFeature("MemberImportVisibility"),
+ .enableUpcomingFeature("StrictConcurrency"),
]
-// 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"]),
],
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(
diff --git a/Sources/CollectionsBenchmark/Basics/Duration+Basics.swift b/Sources/CollectionsBenchmark/Basics/Duration+Basics.swift
new file mode 100644
index 0000000..f17c6ea
--- /dev/null
+++ b/Sources/CollectionsBenchmark/Basics/Duration+Basics.swift
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the Swift Collections open source project
+//
+// Copyright (c) 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
+//
+//===----------------------------------------------------------------------===//
+
+extension Duration {
+ // Backported from Swift 6.2
+ internal init(_attoseconds: Int128) {
+ self.init(_high: _attoseconds._high, low: _attoseconds._low)
+ }
+
+ // Backported from Swift 6.2
+ internal var _attoseconds: Int128 {
+ Int128(_low: _low, _high: _high)
+ }
+
+ // Backported from a utopistic future
+ internal var _seconds: Double {
+ Double(_attoseconds) / 1e18
+ }
+}
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..ec1d80a 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
@@ -25,7 +25,7 @@ extension Sample {
case .maximum: return maximum
case .sigma(let n):
guard let sigma = standardDeviation else { return nil }
- return Time(mean!.seconds + Double(n) * sigma.seconds)
+ return .seconds(mean!.seconds + Double(n) * sigma.seconds)
case .mean: return mean
case .minimum: return minimum
case .none: return nil
diff --git a/Sources/CollectionsBenchmark/Basics/Sample.swift b/Sources/CollectionsBenchmark/Basics/Sample.swift
index e2304b8..9766357 100644
--- a/Sources/CollectionsBenchmark/Basics/Sample.swift
+++ b/Sources/CollectionsBenchmark/Basics/Sample.swift
@@ -2,14 +2,16 @@
//
// 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 {
+import Foundation // For String(format:)
+
+public struct Sample: Sendable, Equatable {
// Sorted array of measured durations.
internal var _times: _SimpleSortedBag