Skip to content

Commit cee593c

Browse files
committed
[benchmark] Add a small --help menu to the low level driver that just dumps the current valid options list.
We probably should have added this sooner...
1 parent fab1630 commit cee593c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

benchmark/utils/DriverUtils.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ enum TestAction {
9393
case run
9494
case listTests
9595
case fail(String)
96+
case help([String])
9697
}
9798

9899
struct TestConfig {
@@ -136,7 +137,7 @@ struct TestConfig {
136137
let validOptions = [
137138
"--iter-scale", "--num-samples", "--num-iters",
138139
"--verbose", "--delim", "--list", "--sleep",
139-
"--tags", "--skip-tags"
140+
"--tags", "--skip-tags", "--help"
140141
]
141142
let maybeBenchArgs: Arguments? = parseArgs(validOptions)
142143
if maybeBenchArgs == nil {
@@ -146,6 +147,10 @@ struct TestConfig {
146147

147148
filters = benchArgs.positionalArgs
148149

150+
if benchArgs.optionalArgsMap["--help"] == nil {
151+
return .help(validOptions)
152+
}
153+
149154
if let x = benchArgs.optionalArgsMap["--iter-scale"] {
150155
if x.isEmpty { return .fail("--iter-scale requires a value") }
151156
iterationScale = Int(x)!
@@ -478,6 +483,11 @@ public func main() {
478483
var config = TestConfig()
479484

480485
switch (config.processArguments()) {
486+
case let .help(validOptions):
487+
print("Valid options:")
488+
for v in validOptions {
489+
print(" \(v)")
490+
}
481491
case let .fail(msg):
482492
// We do this since we need an autoclosure...
483493
fatalError("\(msg)")

0 commit comments

Comments
 (0)