Skip to content

Commit 89835de

Browse files
committed
Merge remote-tracking branch 'origin/mmbm-range-relative-thresholds-options-bak' into mmbm-range-relative-thresholds-options-bak
1 parent 2e1b93c commit 89835de

25 files changed

+115
-117
lines changed

Benchmarks/Benchmarks/Basic/BenchmarkRunner+Basic.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ let benchmarks: @Sendable () -> Void = {
125125
}
126126
}
127127

128-
let parameterization = (0...5).map { 1 << $0 } // 1, 2, 4, ...
128+
let parameterization = (0...5).map { 1 << $0 } // 1, 2, 4, ...
129129

130130
parameterization.forEach { count in
131131
Benchmark("Parameterized", configuration: .init(tags: ["count": count.description])) { benchmark in

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ let package = Package(
117117
)
118118
// Check if this is a SPI build, then we need to disable jemalloc for macOS
119119

120-
let macOSSPIBuild: Bool // Disables jemalloc for macOS SPI builds as the infrastructure doesn't have jemalloc there
120+
let macOSSPIBuild: Bool // Disables jemalloc for macOS SPI builds as the infrastructure doesn't have jemalloc there
121121

122122
#if canImport(Darwin)
123123
if let spiBuildEnvironment = ProcessInfo.processInfo.environment["SPI_BUILD"], spiBuildEnvironment == "1" {
@@ -144,7 +144,7 @@ var dependencies: [PackageDescription.Target.Dependency] = [
144144
"BenchmarkShared",
145145
]
146146

147-
if macOSSPIBuild == false { // jemalloc always disable for macOSSPIBuild
147+
if macOSSPIBuild == false { // jemalloc always disable for macOSSPIBuild
148148
if let disableJemalloc, disableJemalloc != "false", disableJemalloc != "0" {
149149
print("Jemalloc disabled through environment variable.")
150150
} else {

Plugins/BenchmarkBoilerplateGenerator/BenchmarkBoilerplateGenerator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct Benchmark: AsyncParsableCommand {
2020
var output: String
2121

2222
mutating func run() async throws {
23-
let outputPath = FilePath(output) // package
23+
let outputPath = FilePath(output) // package
2424
var boilerplate = """
2525
import Benchmark
2626

Plugins/BenchmarkCommandPlugin/BenchmarkCommandPlugin.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import Glibc
3737
let specifiedTargets = try argumentExtractor.extractSpecifiedTargets(in: context.package, withOption: "target")
3838
let skipTargets = try argumentExtractor.extractSpecifiedTargets(in: context.package, withOption: "skip-target")
3939
let outputFormats = argumentExtractor.extractOption(named: "format")
40-
let pathSpecified = argumentExtractor.extractOption(named: "path") // export path
40+
let pathSpecified = argumentExtractor.extractOption(named: "path") // export path
4141
let quietRunning = argumentExtractor.extractFlag(named: "quiet")
4242
let noProgress = argumentExtractor.extractFlag(named: "no-progress")
4343
let checkAbsoluteThresholdsPath = argumentExtractor.extractOption(named: "check-absolute-path")
@@ -143,16 +143,16 @@ import Glibc
143143
)
144144
throw MyError.invalidArgument
145145
}
146-
} catch { // We will throw if we can use the target name (it's unused!)
146+
} catch { // We will throw if we can use the target name (it's unused!)
147147
}
148148
}
149149

150150
let swiftSourceModuleTargets: [SwiftSourceModuleTarget]
151-
var shouldBuildTargets = true // We don't rebuild the targets when we dont need to execute them, e.g. baseline read/compare
151+
var shouldBuildTargets = true // We don't rebuild the targets when we dont need to execute them, e.g. baseline read/compare
152152

153153
let packageBenchmarkIdentifier = "package-benchmark"
154154
let benchmarkToolName = "BenchmarkTool"
155-
let benchmarkTool: PackagePlugin.Path // = try context.tool(named: benchmarkToolName)
155+
let benchmarkTool: PackagePlugin.Path // = try context.tool(named: benchmarkToolName)
156156

157157
var args: [String] = [
158158
benchmarkToolName,
@@ -473,7 +473,7 @@ import Glibc
473473
}
474474

475475
let buildResult = try packageManager.build(
476-
.product(target.name), // .all(includingTests: false),
476+
.product(target.name), // .all(includingTests: false),
477477
parameters: .init(configuration: .release)
478478
)
479479

Plugins/BenchmarkTool/BenchmarkTool+Baselines.swift

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ struct BenchmarkMachine: Codable, Equatable {
3333

3434
var hostname: String
3535
var processors: Int
36-
var processorType: String // e.g. arm64e
37-
var memory: Int // in GB
36+
var processorType: String // e.g. arm64e
37+
var memory: Int // in GB
3838
var kernelVersion: String
3939

4040
public static func == (lhs: BenchmarkMachine, rhs: BenchmarkMachine) -> Bool {
@@ -48,8 +48,8 @@ struct BenchmarkIdentifier: Codable, Hashable {
4848
self.name = name
4949
}
5050

51-
var target: String // The name of the executable benchmark target id
52-
var name: String // The name of the benchmark
51+
var target: String // The name of the executable benchmark target id
52+
var name: String // The name of the benchmark
5353

5454
public func hash(into hasher: inout Hasher) {
5555
hasher.combine(target)
@@ -178,7 +178,7 @@ let baselinesDirectory: String = ".benchmarkBaselines"
178178
extension BenchmarkTool {
179179
func printAllBaselines() {
180180
var storagePath = FilePath(baselineStoragePath)
181-
storagePath.append(baselinesDirectory) // package/.benchmarkBaselines
181+
storagePath.append(baselinesDirectory) // package/.benchmarkBaselines
182182
for file in storagePath.directoryEntries {
183183
if file.ends(with: ".") == false,
184184
file.ends(with: "..") == false
@@ -206,7 +206,7 @@ extension BenchmarkTool {
206206
var storagePath = FilePath(baselineStoragePath)
207207
let filemanager = FileManager.default
208208

209-
storagePath.append(baselinesDirectory) // package/.benchmarkBaselines
209+
storagePath.append(baselinesDirectory) // package/.benchmarkBaselines
210210
for file in storagePath.directoryEntries {
211211
if file.ends(with: ".") == false,
212212
file.ends(with: "..") == false
@@ -284,14 +284,14 @@ extension BenchmarkTool {
284284
│ └── ...
285285
└── ...
286286
*/
287-
var outputPath = FilePath(baselineStoragePath) // package
288-
var subPath = FilePath() // subpath rooted in package used for directory creation
287+
var outputPath = FilePath(baselineStoragePath) // package
288+
var subPath = FilePath() // subpath rooted in package used for directory creation
289289

290-
subPath.append(baselinesDirectory) // package/.benchmarkBaselines
291-
subPath.append("\(target)") // package/.benchmarkBaselines/myTarget1
292-
subPath.append(baselineName) // package/.benchmarkBaselines/myTarget1/named1
290+
subPath.append(baselinesDirectory) // package/.benchmarkBaselines
291+
subPath.append("\(target)") // package/.benchmarkBaselines/myTarget1
292+
subPath.append(baselineName) // package/.benchmarkBaselines/myTarget1/named1
293293

294-
outputPath.createSubPath(subPath) // Create destination subpath if needed
294+
outputPath.createSubPath(subPath) // Create destination subpath if needed
295295

296296
outputPath.append(subPath.components)
297297

@@ -348,13 +348,13 @@ extension BenchmarkTool {
348348
baselineIdentifier: String? = nil
349349
) throws -> BenchmarkBaseline? {
350350
var path = FilePath(baselineStoragePath)
351-
path.append(baselinesDirectory) // package/.benchmarkBaselines
352-
path.append(FilePath.Component(target)!) // package/.benchmarkBaselines/myTarget1
351+
path.append(baselinesDirectory) // package/.benchmarkBaselines
352+
path.append(FilePath.Component(target)!) // package/.benchmarkBaselines/myTarget1
353353

354354
if let baselineIdentifier {
355-
path.append(baselineIdentifier) // package/.benchmarkBaselines/myTarget1/named1
355+
path.append(baselineIdentifier) // package/.benchmarkBaselines/myTarget1/named1
356356
} else {
357-
path.append("default") // // package/.benchmarkBaselines/myTarget1/default
357+
path.append("default") // // package/.benchmarkBaselines/myTarget1/default
358358
}
359359

360360
if let hostIdentifier {
@@ -376,7 +376,7 @@ extension BenchmarkTool {
376376
let bufferSize = 16 * 1_024 * 1_024
377377
var done = false
378378

379-
while done == false { // readBytes.count < bufferLength {
379+
while done == false { // readBytes.count < bufferLength {
380380
let nextBytes = try [UInt8](unsafeUninitializedCapacity: bufferSize) { buf, count in
381381
count = try fd.read(into: UnsafeMutableRawBufferPointer(buf))
382382
if count == 0 {
@@ -396,7 +396,7 @@ extension BenchmarkTool {
396396
print("Failed to close fd for \(path) after reading.")
397397
}
398398
} catch {
399-
if errno != ENOENT { // file not found is ok, e.g. when no baselines exist
399+
if errno != ENOENT { // file not found is ok, e.g. when no baselines exist
400400
print("Failed to open file \(path), errno = [\(errno)]")
401401
}
402402
}
@@ -522,11 +522,11 @@ extension BenchmarkBaseline: Equatable {
522522

523523
for (lhsBenchmarkIdentifier, lhsBenchmarkResults) in lhs.results {
524524
for lhsBenchmarkResult in lhsBenchmarkResults {
525-
guard let rhsResults = rhs.results.first(where: { $0.key == lhsBenchmarkIdentifier }) else { // We couldn't find a result for one of the tests
525+
guard let rhsResults = rhs.results.first(where: { $0.key == lhsBenchmarkIdentifier }) else { // We couldn't find a result for one of the tests
526526
return false
527527
}
528528
guard let rhsBenchmarkResult = rhsResults.value.first(where: { $0.metric == lhsBenchmarkResult.metric })
529-
else { // We couldn't find the specific metric
529+
else { // We couldn't find the specific metric
530530
return false
531531
}
532532
if lhsBenchmarkResult != rhsBenchmarkResult {

Plugins/BenchmarkTool/BenchmarkTool+CreateBenchmark.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ extension BenchmarkTool {
4444
]
4545
"""
4646

47-
var outputPath = FilePath(baselineStoragePath) // package
48-
var subPath = FilePath() // subpath rooted in package used for directory creation
49-
subPath.append("Package.swift") // package/Benchmarks/targetName
47+
var outputPath = FilePath(baselineStoragePath) // package
48+
var subPath = FilePath() // subpath rooted in package used for directory creation
49+
subPath.append("Package.swift") // package/Benchmarks/targetName
5050
outputPath.append(subPath.components)
5151

5252
print("Adding new executable target \(targetName) to \(outputPath.description)")
@@ -110,13 +110,13 @@ extension BenchmarkTool {
110110
111111
"""
112112

113-
var outputPath = FilePath(baselineStoragePath) // package
114-
var subPath = FilePath() // subpath rooted in package used for directory creation
113+
var outputPath = FilePath(baselineStoragePath) // package
114+
var subPath = FilePath() // subpath rooted in package used for directory creation
115115

116-
subPath.append(benchmarksDirectory) // package/Benchmarks
117-
subPath.append("\(targetName)") // package/Benchmarks/targetName
116+
subPath.append(benchmarksDirectory) // package/Benchmarks
117+
subPath.append("\(targetName)") // package/Benchmarks/targetName
118118

119-
outputPath.createSubPath(subPath) // Create destination subpath if needed
119+
outputPath.createSubPath(subPath) // Create destination subpath if needed
120120
outputPath.append(subPath.components)
121121
outputPath.append("\(targetName).swift")
122122

Plugins/BenchmarkTool/BenchmarkTool+Export+JMHFormatter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ extension JMHPrimaryMetric {
5656
if result.metric.countable {
5757
scoreUnit = result.metric == .throughput ? "# / s" : "#"
5858
} else {
59-
scoreUnit = "μs" // result.timeUnits.description
59+
scoreUnit = "μs" // result.timeUnits.description
6060
}
6161
rawData = [recordedValues]
6262
}
@@ -66,7 +66,7 @@ extension BenchmarkTool {
6666
func convertToJMH(_ baseline: BenchmarkBaseline) throws -> String {
6767
var resultString = ""
6868
var jmhElements: [JMHElement] = []
69-
var secondaryMetrics: [String: JMHPrimaryMetric] = [:] // could move to OrderedDictionary for consistent output
69+
var secondaryMetrics: [String: JMHPrimaryMetric] = [:] // could move to OrderedDictionary for consistent output
7070

7171
baseline.targets.forEach { benchmarkTarget in
7272

Plugins/BenchmarkTool/BenchmarkTool+Machine.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import Glibc
2323
extension BenchmarkTool {
2424
func benchmarkMachine() -> BenchmarkMachine {
2525
let processors = sysconf(Int32(_SC_NPROCESSORS_ONLN))
26-
let memory = sysconf(Int32(_SC_PHYS_PAGES)) / 1_024 * sysconf(Int32(_SC_PAGESIZE)) / (1_024 * 1_024) // avoid overflow
26+
let memory = sysconf(Int32(_SC_PHYS_PAGES)) / 1_024 * sysconf(Int32(_SC_PAGESIZE)) / (1_024 * 1_024) // avoid overflow
2727

2828
var uuname = utsname()
2929
_ = uname(&uuname)

Plugins/BenchmarkTool/BenchmarkTool+Operations.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension BenchmarkTool {
2929
let benchmarkReply = try read()
3030

3131
switch benchmarkReply {
32-
case let .list(benchmark):
32+
case .list(let benchmark):
3333
benchmark.executablePath = benchmarkPath
3434
benchmark.target = FilePath(benchmarkPath).lastComponent!.description
3535
if metrics.isEmpty == false {
@@ -38,7 +38,7 @@ extension BenchmarkTool {
3838
benchmarks.append(benchmark)
3939
case .end:
4040
break outerloop
41-
case let .error(description):
41+
case .error(let description):
4242
failBenchmark(description)
4343
break outerloop
4444
default:
@@ -55,12 +55,12 @@ extension BenchmarkTool {
5555
let benchmarkReply = try read()
5656

5757
switch benchmarkReply {
58-
case let .result(benchmark: benchmark, results: results):
58+
case .result(benchmark: let benchmark, results: let results):
5959
let filteredResults = results.filter { benchmark.configuration.metrics.contains($0.metric) }
6060
benchmarkResults[BenchmarkIdentifier(target: target, name: benchmark.name)] = filteredResults
6161
case .end:
6262
break outerloop
63-
case let .error(description):
63+
case .error(let description):
6464
failBenchmark(description, exitCode: .benchmarkJobFailed, "\(target)/\(benchmark.name)")
6565

6666
benchmarkResults[BenchmarkIdentifier(target: target, name: benchmark.name)] = []
@@ -134,7 +134,7 @@ extension BenchmarkTool {
134134
return
135135
}
136136

137-
if benchmarks.isEmpty { // if we read from baseline and didn't run them, we put in some fake entries for the compare
137+
if benchmarks.isEmpty { // if we read from baseline and didn't run them, we put in some fake entries for the compare
138138
currentBaseline.results.keys.forEach { baselineKey in
139139
if let benchmark: Benchmark = .init(baselineKey.name, closure: { _ in }) {
140140
benchmark.target = baselineKey.target
@@ -287,7 +287,7 @@ extension BenchmarkTool {
287287
return
288288
}
289289

290-
if benchmarks.isEmpty { // if we read from baseline and didn't run them, we put in some fake entries for the compare
290+
if benchmarks.isEmpty { // if we read from baseline and didn't run them, we put in some fake entries for the compare
291291
currentBaseline.results.keys.forEach { baselineKey in
292292
if let benchmark: Benchmark = .init(baselineKey.name, closure: { _ in }) {
293293
benchmark.target = baselineKey.target
@@ -307,7 +307,7 @@ extension BenchmarkTool {
307307
var p90Thresholds: [BenchmarkIdentifier: [BenchmarkMetric: BenchmarkThreshold]] =
308308
[:]
309309

310-
if let benchmarkPath = checkAbsolutePath { // load statically defined thresholds for .p90
310+
if let benchmarkPath = checkAbsolutePath { // load statically defined thresholds for .p90
311311
benchmarks.forEach { benchmark in
312312
if let thresholds = BenchmarkTool.makeBenchmarkThresholds(
313313
path: benchmarkPath,

Plugins/BenchmarkTool/BenchmarkTool+ReadP90AbsoluteThresholds.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ extension BenchmarkTool {
9696
print("Failed to close fd for \(path) after reading.")
9797
}
9898
} catch {
99-
if errno != ENOENT { // file not found is ok, e.g. no thresholds found, then silently return nil
99+
if errno != ENOENT { // file not found is ok, e.g. no thresholds found, then silently return nil
100100
print("Failed to open file \(path), errno = [\(errno)] \(Errno(rawValue: errno).description)")
101101
}
102102
}

0 commit comments

Comments
 (0)