Skip to content

[benchmark] SR-4780 Can not run performance tests that are not in precommit suite #9310

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
merged 1 commit into from
Jun 12, 2017
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion benchmark/scripts/Benchmark_Driver
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ def instrument_test(driver_path, test, num_samples):

def get_tests(driver_path, args):
"""Return a list of available performance tests"""
tests = subprocess.check_output([driver_path, '--list']).split()[2:]
driver = ([driver_path, '--list'])
if args.benchmarks or args.filters:
driver.append('--run-all')
tests = subprocess.check_output(driver).split()[2:]
if args.filters:
regexes = [re.compile(pattern) for pattern in args.filters]
return sorted(list(set([name for pattern in regexes
Expand Down
56 changes: 22 additions & 34 deletions benchmark/utils/DriverUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,7 @@ struct Test {
let name: String
let index: Int
let f: (Int) -> ()
var run: Bool
init(name: String, n: Int, f: @escaping (Int) -> ()) {
self.name = name
self.index = n
self.f = f
run = true
}
let run: Bool
}

public var precommitTests: [String : (Int) -> ()] = [:]
Expand Down Expand Up @@ -117,9 +111,7 @@ struct TestConfig {
}
let benchArgs = maybeBenchArgs!

if let _ = benchArgs.optionalArgsMap["--list"] {
return .ListTests
}
filters = benchArgs.positionalArgs

if let x = benchArgs.optionalArgsMap["--iter-scale"] {
if x.isEmpty { return .Fail("--iter-scale requires a value") }
Expand Down Expand Up @@ -161,34 +153,30 @@ struct TestConfig {
afterRunSleep = v!
}

filters = benchArgs.positionalArgs
if let _ = benchArgs.optionalArgsMap["--list"] {
return .ListTests
}

return .Run
}

mutating func findTestsToRun() {
var i = 1
for benchName in precommitTests.keys.sorted() {
tests.append(Test(name: benchName, n: i, f: precommitTests[benchName]!))
i += 1
}
for benchName in otherTests.keys.sorted() {
tests.append(Test(name: benchName, n: i, f: otherTests[benchName]!))
i += 1
}
for benchName in stringTests.keys.sorted() {
tests.append(Test(name: benchName, n: i, f: stringTests[benchName]!))
i += 1
}
for i in 0..<tests.count {
if onlyPrecommit && precommitTests[tests[i].name] == nil {
tests[i].run = false
}
if !filters.isEmpty &&
!filters.contains(String(tests[i].index)) &&
!filters.contains(tests[i].name) {
tests[i].run = false
}
let allTests = [precommitTests, otherTests, stringTests]
.map { dictionary -> [(key: String, value: (Int)-> ())] in
Array(dictionary).sorted { $0.key < $1.key } } // by name
.joined()

let included =
!filters.isEmpty ? Set(filters)
: onlyPrecommit ? Set(precommitTests.keys)
: Set(allTests.map { $0.key })

tests = zip(1...allTests.count, allTests).map {
t -> Test in
let (ordinal, (key: name, value: function)) = t
return Test(name: name, index: ordinal, f: function,
run: included.contains(name)
|| included.contains(String(ordinal)))
}
}
}
Expand Down Expand Up @@ -410,7 +398,7 @@ public func main() {
case .ListTests:
config.findTestsToRun()
print("Enabled Tests:")
for t in config.tests {
for t in config.tests where t.run == true {
print(" \(t.name)")
}
case .Run:
Expand Down