Skip to content

Modernize this code base #24

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 14 commits into from
May 22, 2025
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
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/*.xcodeproj
xcuserdata/
/Results
/Documentation/Example/.build
/Documentation/Example/Package.resolved
2 changes: 1 addition & 1 deletion .spi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1
builder:
configs:
- documentation_targets: [CollectionsBenchmark]
- documentation_targets: [CollectionsBenchmark]
25 changes: 25 additions & 0 deletions .swiftpm/configuration/Package.resolved
Original file line number Diff line number Diff line change
@@ -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
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand All @@ -27,7 +28,7 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
43 changes: 21 additions & 22 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -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
}
25 changes: 9 additions & 16 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(
Expand Down
27 changes: 27 additions & 0 deletions Sources/CollectionsBenchmark/Basics/Duration+Basics.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
4 changes: 2 additions & 2 deletions Sources/CollectionsBenchmark/Basics/Measurement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions Sources/CollectionsBenchmark/Basics/Sample+Statistic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -12,7 +12,7 @@
import ArgumentParser

extension Sample {
public enum Statistic: Hashable {
public enum Statistic: Sendable, Hashable {
case maximum
case sigma(Int)
case mean
Expand All @@ -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
Expand Down
Loading