Skip to content

Commit

Permalink
Stop depending on swift-collections-benchmark (apple#86)
Browse files Browse the repository at this point in the history
Instead, move the benchmark suite into its own private nested package, under `Benchmarks/`.

The recommended way to build & run benchmarks is via the `Utils/run-benchmarks.sh` script, which continues to work as before with this change.

# Conflicts:
#	.swiftpm/xcode/xcshareddata/xcschemes/swift-collections-benchmark.xcscheme
#	Package.swift
  • Loading branch information
lorentey committed Aug 19, 2021
1 parent 31848ac commit f559b32
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 134 deletions.
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/
.*.sw?
/Benchmarks/.swiftpm
/Benchmarks/.build

This file was deleted.

34 changes: 34 additions & 0 deletions Benchmarks/Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"object": {
"pins": [
{
"package": "swift-argument-parser",
"repositoryURL": "https://github.com/apple/swift-argument-parser",
"state": {
"branch": null,
"revision": "83b23d940471b313427da226196661856f6ba3e0",
"version": "0.4.4"
}
},
{
"package": "swift-collections-benchmark",
"repositoryURL": "https://github.com/apple/swift-collections-benchmark",
"state": {
"branch": null,
"revision": "665cbb154a55f45bcedd2ab4faf17b1b7ac06de3",
"version": "0.0.2"
}
},
{
"package": "swift-system",
"repositoryURL": "https://github.com/apple/swift-system",
"state": {
"branch": null,
"revision": "2bc160bfe34d843ae5ff47168080add24dfd7eac",
"version": "0.0.2"
}
}
]
},
"version": 1
}
47 changes: 47 additions & 0 deletions Benchmarks/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// swift-tools-version:5.3
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2021 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
//
//===----------------------------------------------------------------------===//

import PackageDescription

let package = Package(
name: "swift-collections.Benchmarks",
dependencies: [
.package(name: "swift-collections", path: ".."),
.package(url: "https://github.com/apple/swift-collections-benchmark", from: "0.0.1"),
],
targets: [
.target(
name: "Benchmarks",
dependencies: [
.product(name: "Collections", package: "swift-collections"),
.product(name: "CollectionsBenchmark", package: "swift-collections-benchmark"),
"CppBenchmarks",
],
path: "Benchmarks",
resources: [
.copy("Library.json"),
]
),
.target(
name: "CppBenchmarks",
path: "CppBenchmarks"
),
.target(
name: "benchmark",
dependencies: [
"Benchmarks",
],
path: "benchmark-tool"
),
],
cxxLanguageStandard: .cxx1z
)
File renamed without changes.
32 changes: 1 addition & 31 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ let package = Package(
.library(name: "DequeModule", targets: ["DequeModule"]),
.library(name: "OrderedCollections", targets: ["OrderedCollections"]),
],
dependencies: [
// This is only used in the benchmark executable target.
.package(url: "https://github.com/apple/swift-collections-benchmark", from: "0.0.1"),
],
targets: [
.target(
name: "Collections",
Expand Down Expand Up @@ -86,31 +82,6 @@ let package = Package(
dependencies: ["CollectionsTestSupport"],
swiftSettings: settings),

// Benchmarking
.target(
name: "Benchmarks",
dependencies: [
.product(name: "CollectionsBenchmark", package: "swift-collections-benchmark"),
"CppBenchmarks",
"Collections",
],
path: "Benchmarks/Benchmarks",
resources: [
.copy("Library.json"),
]
),
.target(
name: "CppBenchmarks",
path: "Benchmarks/CppBenchmarks"
),
.target(
name: "swift-collections-benchmark",
dependencies: [
"Benchmarks",
],
path: "Benchmarks/swift-collections-benchmark"
),

// Deque<Element>
.target(
name: "DequeModule",
Expand All @@ -130,6 +101,5 @@ let package = Package(
name: "OrderedCollectionsTests",
dependencies: ["OrderedCollections", "CollectionsTestSupport"],
swiftSettings: settings),
],
cxxLanguageStandard: .cxx1z
]
)
4 changes: 2 additions & 2 deletions Utils/run-benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eu

srcroot="$(dirname "$0")/.."
srcroot="$(dirname "$0")/../Benchmarks"
results="batch.results"

command="${1:-help}"
Expand All @@ -12,7 +12,7 @@ run() {
local flags
flags="-c release"
flags="$flags -Xswiftc -Xllvm -Xswiftc -align-module-to-page-size"
swift run --package-path "$srcroot" $flags swift-collections-benchmark "$@"
swift run --package-path "$srcroot" $flags benchmark "$@"
}

case "$command" in
Expand Down

0 comments on commit f559b32

Please sign in to comment.