<commit_before>// 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]
)
<commit_msg>[benchmark] Fix the swiftpm based benchmark build.<commit_after>// swift-tools-version:4.2

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
  }
}()

var products: [Product] = []
products.append(.library(name: "TestsUtils", type: .static, targets: ["TestsUtils"]))
products.append(.library(name: "DriverUtils", type: .static, targets: ["DriverUtils"]))
products.append(.library(name: "ObjectiveCTests", type: .static, targets: ["ObjectiveCTests"]))
products.append(.executable(name: "SwiftBench", targets: ["SwiftBench"]))
products.append(.library(name: "PrimsSplit", type: .static, targets: ["PrimsSplit"]))
products += singleSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) }
products += multiSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) }

var targets: [Target] = []
targets.append(.target(name: "TestsUtils", path: "utils", sources: ["TestsUtils.swift"]))
targets.append(.systemLibrary(name: "LibProc", path: "utils/LibProc"))
targets.append(
  .target(name: "DriverUtils",
    dependencies: [.target(name: "TestsUtils"), "LibProc"],
    path: "utils",
    sources: ["DriverUtils.swift", "ArgParse.swift"]))
targets.append(
    .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"]))
targets.append(
  .target(name: "ObjectiveCTests",
    path: "utils/ObjectiveCTests",
    publicHeadersPath: "."))
targets += singleSourceLibraries.map { x in
    return .target(name: x,
      dependencies: [
        .target(name: "TestsUtils"),
        .target(name: "ObjectiveCTests"),
      ],
      path: "single-source",
      sources: ["\(x).swift"])
}
targets += multiSourceLibraries.map { x in
  return .target(name: x,
    dependencies: [
      .target(name: "TestsUtils")
    ],
    path: "multi-source/\(x)")
}

let p = Package(
  name: "swiftbench",
  products: products,
  targets: targets,
  swiftLanguageVersions: [.v4]
)

{'fraction_non_alphanumeric': 0.15502882767456758, 'fraction_numerical': 0.004484304932735426, 'mean_word_length': 3.052563270603504, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2450532', 'n_tokens_mistral': 2007, 'n_tokens_neox': 1952, 'n_words': 466}