Skip to content

Commit faf38d7

Browse files
committed
Sema: A few more type_checker_perf tests
1 parent ce9e7cc commit faf38d7

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed
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+
}

0 commit comments

Comments
 (0)