diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index e51252870bee5..0f2b6a9f75c7b 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -173,7 +173,7 @@ set(SWIFT_MULTISOURCE_SWIFT3_BENCHES set(PrimsSplit_sources multi-source/PrimsSplit/Prims.swift - multi-source/PrimsSplit/main.swift) + multi-source/PrimsSplit/Prims_main.swift) set(SWIFT_MULTISOURCE_SWIFT4_BENCHES ) diff --git a/benchmark/Package.swift b/benchmark/Package.swift new file mode 100644 index 0000000000000..8e21ea97764c1 --- /dev/null +++ b/benchmark/Package.swift @@ -0,0 +1,88 @@ +// swift-tools-version:4.0 + +import PackageDescription +import Foundation + +// This is a stop gap hack so we can edit benchmarks in Xcode. +let singleSourceLibraries: [String] = { + let f = FileManager.`default` + let dirURL = URL(fileURLWithPath: "single-source").absoluteURL + let fileURLs = try! f.contentsOfDirectory(at: dirURL, + includingPropertiesForKeys: nil) + return fileURLs.flatMap { (path: URL) -> String? in + let c = path.lastPathComponent.split(separator: ".") + // Too many components. Must be a gyb file. + if c.count > 2 { + return nil + } + if c[1] != "swift" { + return nil + } + + // We do not support this test. + if c[0] == "ObjectiveCNoBridgingStubs" { + return nil + } + + assert(c[0] != "PrimsSplit") + return String(c[0]) + } +}() + +let multiSourceLibraries: [String] = { + let f = FileManager.`default` + let dirURL = URL(fileURLWithPath: "multi-source").absoluteURL + let fileURLs = try! f.contentsOfDirectory(at: dirURL, + includingPropertiesForKeys: nil) + return fileURLs.map { (path: URL) -> String in + return path.lastPathComponent + } +}() + +let p = Package( + name: "swiftbench", + products: [ + .library(name: "TestsUtils", type: .static, targets: ["TestsUtils"]), + .library(name: "DriverUtils", type: .static, targets: ["DriverUtils"]), + .library(name: "ObjectiveCTests", type: .static, targets: ["ObjectiveCTests"]), + .executable(name: "SwiftBench", targets: ["SwiftBench"]), + .library(name: "PrimsSplit", type: .static, targets: ["PrimsSplit"]) + ] + singleSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) } + + multiSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) }, + targets: [ + .target(name: "TestsUtils", + path: "utils", + sources: ["TestsUtils.swift"]), + .target(name: "DriverUtils", + dependencies: [.target(name: "TestsUtils")], + path: "utils", + sources: ["DriverUtils.swift", "ArgParse.swift"]), + .target(name: "SwiftBench", + dependencies: [ + .target(name: "TestsUtils"), + .target(name: "ObjectiveCTests"), + .target(name: "DriverUtils"), + ] + singleSourceLibraries.map { .target(name: $0) } + + multiSourceLibraries.map { .target(name: $0) }, + path: "utils", + sources: ["main.swift"]), + .target(name: "ObjectiveCTests", + path: "utils/ObjectiveCTests", + publicHeadersPath: "."), + ] + singleSourceLibraries.map { x in + return .target(name: x, + dependencies: [ + .target(name: "TestsUtils"), + .target(name: "ObjectiveCTests"), + ], + path: "single-source", + sources: ["\(x).swift"]) + } + multiSourceLibraries.map { x in + return .target(name: x, + dependencies: [ + .target(name: "TestsUtils") + ], + path: "multi-source/\(x)") + }, + swiftLanguageVersions: [4] +) diff --git a/benchmark/multi-source/PrimsSplit/main.swift b/benchmark/multi-source/PrimsSplit/Prims_main.swift similarity index 100% rename from benchmark/multi-source/PrimsSplit/main.swift rename to benchmark/multi-source/PrimsSplit/Prims_main.swift diff --git a/benchmark/utils/main.swift b/benchmark/utils/main.swift index d54433e4a2b40..4234a26ca0aa1 100644 --- a/benchmark/utils/main.swift +++ b/benchmark/utils/main.swift @@ -92,7 +92,9 @@ import NopDeinit import ObjectAllocation import ObjectiveCBridging import ObjectiveCBridgingStubs +#if !SWIFT_PACKAGE import ObjectiveCNoBridgingStubs +#endif import ObserverClosure import ObserverForwarderStruct import ObserverPartiallyAppliedMethod @@ -252,7 +254,9 @@ registerBenchmark(NopDeinit) registerBenchmark(ObjectAllocation) registerBenchmark(ObjectiveCBridging) registerBenchmark(ObjectiveCBridgingStubs) +#if !SWIFT_PACKAGE registerBenchmark(ObjectiveCNoBridgingStubs) +#endif registerBenchmark(ObserverClosure) registerBenchmark(ObserverForwarderStruct) registerBenchmark(ObserverPartiallyAppliedMethod)