Skip to content

[benchmark] Add a small --help menu to the low level driver that just… #16881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion benchmark/utils/DriverUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ enum TestAction {
case run
case listTests
case fail(String)
case help([String])
}

struct TestConfig {
Expand Down Expand Up @@ -136,7 +137,7 @@ struct TestConfig {
let validOptions = [
"--iter-scale", "--num-samples", "--num-iters",
"--verbose", "--delim", "--list", "--sleep",
"--tags", "--skip-tags"
"--tags", "--skip-tags", "--help"
]
let maybeBenchArgs: Arguments? = parseArgs(validOptions)
if maybeBenchArgs == nil {
Expand All @@ -146,6 +147,10 @@ struct TestConfig {

filters = benchArgs.positionalArgs

if benchArgs.optionalArgsMap["--help"] == nil {
return .help(validOptions)
}

if let x = benchArgs.optionalArgsMap["--iter-scale"] {
if x.isEmpty { return .fail("--iter-scale requires a value") }
iterationScale = Int(x)!
Expand Down Expand Up @@ -478,6 +483,11 @@ public func main() {
var config = TestConfig()

switch (config.processArguments()) {
case let .help(validOptions):
print("Valid options:")
for v in validOptions {
print(" \(v)")
}
case let .fail(msg):
// We do this since we need an autoclosure...
fatalError("\(msg)")
Expand Down