Skip to content

Commit

Permalink
chore: Move to booleans instead of ints, fixes #114 (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
hassila authored Mar 21, 2023
1 parent 5f4d832 commit 6ea1365
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Plugins/BenchmarkTool/BenchmarkTool+Operations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ extension BenchmarkTool {
target: target)
}

if quiet == 0 {
if quiet == false {
print("")
print("Updated baseline '\(baselineName)'")
}
Expand Down
12 changes: 6 additions & 6 deletions Plugins/BenchmarkTool/BenchmarkTool+PrettyPrinting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ extension BenchmarkTool {

var adjustmentFunction: (Int) -> Int

if self.scale > 0, result.metrics.metric.useScalingFactor {
if self.scale, result.metrics.metric.useScalingFactor {
description = useGroupingDescription ? "\(result.description) \(result.metrics.scaledUnitDescriptionPretty)"
: "\(result.metrics.metric.description) \(result.metrics.scaledUnitDescriptionPretty)"
adjustmentFunction = result.metrics.scale
Expand Down Expand Up @@ -135,7 +135,7 @@ extension BenchmarkTool {
func prettyPrint(_ baseline: BenchmarkBaseline,
header: String, // = "Benchmark results",
hostIdentifier _: String? = nil) {
guard quiet == 0 else { return }
guard quiet == false else { return }

printMachine(baseline.machine, header)

Expand Down Expand Up @@ -268,7 +268,7 @@ extension BenchmarkTool {
var adjustmentFunction: (Int) -> Int
let samples = result.statistics.measurementCount - base.statistics.measurementCount

if self.scale > 0, base.metric.useScalingFactor {
if self.scale, base.metric.useScalingFactor {
adjustmentFunction = base.scale
} else {
adjustmentFunction = base.normalize
Expand All @@ -286,7 +286,7 @@ extension BenchmarkTool {
percentiles: basePercentiles,
samples: base.statistics.measurementCount))

if self.scale > 0, result.metric.useScalingFactor {
if self.scale, result.metric.useScalingFactor {
adjustmentFunction = result.scale
} else {
adjustmentFunction = result.normalize
Expand Down Expand Up @@ -369,7 +369,7 @@ extension BenchmarkTool {
func prettyPrintDeviation(baselineName: String,
comparingBaselineName: String,
deviationResults: [BenchmarkResult.ThresholdDeviation]) {
guard quiet == 0 else { return }
guard quiet == false else { return }

let metrics = deviationResults.map(\.metric).unique()
// Get a unique set of all name/target pairs that have threshold violations, sorted lexically:
Expand Down Expand Up @@ -433,7 +433,7 @@ extension BenchmarkTool {

func prettyPrintAbsoluteDeviation(baselineName: String,
deviationResults: [BenchmarkResult.ThresholdDeviation]) {
guard quiet == 0 else { return }
guard quiet == false else { return }

let metrics = deviationResults.map(\.metric).unique()
// Get a unique set of all name/target pairs that have threshold violations, sorted lexically:
Expand Down
12 changes: 6 additions & 6 deletions Plugins/BenchmarkTool/BenchmarkTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ struct BenchmarkTool: AsyncParsableCommand {
var baselineOperation: BaselineOperation?

@Flag(name: .long, help: "True if we should suppress output")
var quiet: Int
var quiet: Bool = false

@Flag(name: .long, help: "True if we should suppress progress in benchmark run")
var noProgress: Int
var noProgress: Bool = false

@Flag(name: .long, help: "True if we should scale time units, syscall rate, etc to scalingFactor")
var scale: Int
var scale: Bool = false

@Flag(name: .long, help:
"""
Expand Down Expand Up @@ -159,7 +159,7 @@ struct BenchmarkTool: AsyncParsableCommand {
if let baseline = try readBaseline(baselineName) {
benchmarkBaselines.append(baseline)
} else {
if quiet == 0 {
if quiet == false {
print("Warning: Failed to load specified baseline '\(baselineName)'.")
}
}
Expand Down Expand Up @@ -210,7 +210,7 @@ struct BenchmarkTool: AsyncParsableCommand {
fatalError("Query command should never be specified to the BenchmarkTool")
}

if quiet == 0, format == .text {
if quiet == false, format == .text {
"Running Benchmarks".printAsHeader()
}

Expand Down Expand Up @@ -265,7 +265,7 @@ struct BenchmarkTool: AsyncParsableCommand {
var args: [String] = [path.lastComponent!.description,
"--input-fd", toChild.readEnd.rawValue.description,
"--output-fd", fromChild.writeEnd.rawValue.description,
"--quiet", (noProgress > 0).description]
"--quiet", noProgress.description]

if checkAbsoluteThresholds {
args.append("--check-absolute")
Expand Down

0 comments on commit 6ea1365

Please sign in to comment.