Skip to content

Commit 0a4b6f0

Browse files
authored
Merge pull request #84890 from slavapestov/even-more-type-checker-perf-tests
Even more type checker perf tests
2 parents e3c1a3b + faf38d7 commit 0a4b6f0

File tree

10 files changed

+109
-28
lines changed

10 files changed

+109
-28
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %target-typecheck-verify-swift -solver-scope-threshold=300
2+
3+
func slow(someOptionalString: String?) {
4+
print("\(someOptionalString ?? "")\(someOptionalString ?? "")\(someOptionalString ?? "")\(someOptionalString ?? "")\(someOptionalString ?? "")\(someOptionalString ?? "")\(someOptionalString ?? "")\(someOptionalString ?? "")\(someOptionalString ?? "")\(someOptionalString ?? "")\(someOptionalString ?? "")\(someOptionalString ?? "")\(someOptionalString ?? "")")
5+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %scale-test --begin 1 --end 6 --step 1 --select NumLeafScopes %s
2+
// REQUIRES: asserts,no_asan
3+
4+
extension String {
5+
func replacingOccurrences(of: String, with: String) -> String {
6+
return ""
7+
}
8+
}
9+
10+
func slow(something: String?) {
11+
var str = ""
12+
13+
[
14+
%for i in range(0, N):
15+
("${i}", something ?? ""),
16+
%end
17+
].forEach {
18+
str = str.replacingOccurrences(of: $0, with: $1)
19+
}
20+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %target-typecheck-verify-swift -solver-scope-threshold=300
2+
3+
enum DebugValue {
4+
case TupleValue([(name: String?, value: DebugValue)])
5+
6+
var stringRepresentation: String {
7+
switch self {
8+
case .TupleValue(let values):
9+
return "(\(values.map { ($0.name.flatMap { "\($0): " } ?? "") + $0.value.stringRepresentation }.joined(separator: ", ")))"
10+
}
11+
}
12+
}
13+
14+
extension DebugValue : Equatable { }
15+
16+
func == (lhs: DebugValue, rhs: DebugValue) -> Bool {
17+
switch (lhs, rhs) {
18+
case (DebugValue.TupleValue(let xs), DebugValue.TupleValue(let ys)) where xs.count == ys.count:
19+
return zip(xs, ys).reduce(true) { $0 ? $1.0.name == $1.1.name && $1.0.value == $1.1.value : false }
20+
default:
21+
return false
22+
}
23+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %target-typecheck-verify-swift -solver-scope-threshold=200
2+
3+
func slow(_ m: [[UInt32]]) {
4+
var n = m
5+
for i in 1 ..< 10 {
6+
for j in 1 ..< 10 {
7+
n[i][j] = min(n[i - 1][j - 1], n[i - 1][j], n[i][j - 1]) + 1
8+
}
9+
}
10+
}
11+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-typecheck-verify-swift -solver-scope-threshold=2000
2+
3+
func foo(_ string: String) -> Int {
4+
let bar = Array(string)
5+
.reversed()
6+
.enumerated()
7+
.map { ((1 << ($0 + 1)) % 11) * Int(String($1))! }
8+
.reduce(0) { $0 + $1 }
9+
return (12 - bar % 11) % 11
10+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %scale-test --begin 1 --end 6 --step 1 --select NumLeafScopes %s
2+
// REQUIRES: asserts,no_asan
3+
4+
enum A {
5+
case a
6+
}
7+
8+
enum B {
9+
case none
10+
11+
func encode() -> Int {
12+
return 0
13+
}
14+
}
15+
16+
extension Int {
17+
func print() {}
18+
}
19+
20+
func encode(settings: Dictionary<A, B>) {
21+
(
22+
%for i in range(0, N):
23+
(settings[.a] ?? .none).encode() |
24+
%end
25+
(settings[.a] ?? .none).encode()
26+
).print()
27+
}

validation-test/Sema/type_checker_perf/slow/rdar23327871.swift.gyb renamed to validation-test/Sema/type_checker_perf/fast/rdar23327871.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %scale-test --begin 8 --end 16 --step 1 --select NumLeafScopes %s -Xfrontend=-solver-expression-time-threshold=1
1+
// RUN: %scale-test --begin 8 --end 16 --step 1 --select NumLeafScopes %s
22
// REQUIRES: asserts,no_asan
33

44
let i = 1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: not %scale-test --begin 1 --end 5 --step 1 --select incrementScopeCounter %s
2+
// REQUIRES: OS=macosx
3+
// REQUIRES: asserts
4+
5+
func f() {
6+
% for i in range(N):
7+
let collection${i} = [String]()
8+
% end
9+
10+
_ = ${' + '.join("collection%s" % i for i in range(N))}
11+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
1+
// RUN: %target-typecheck-verify-swift -solver-scope-threshold=200
22
// REQUIRES: tools-release,no_asan
33

44
let _ = 1 | UInt32(0) << 0 | UInt32(1) << 1 | UInt32(2) << 2 | UInt32(3) << 3 | UInt32(4) << 4

validation-test/Sema/type_checker_perf/slow/rdar25866240.gyb

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)