Skip to content

Commit 85831df

Browse files
authored
Merge pull request #9298 from apple/only-benchmark-interpolation-when-you-mean-to
2 parents 86620aa + e32fb8b commit 85831df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+214
-345
lines changed

benchmark/single-source/Ackermann.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,5 @@ public func run_Ackermann(_ N: Int) {
4242
break
4343
}
4444
}
45-
CheckResults(result == ref_result[n],
46-
"IncorrectResults in Ackermann: \(result) != \(ref_result[n]).")
45+
CheckResults(result == ref_result[n])
4746
}

benchmark/single-source/ArrayLiteral.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public func run_ArrayValueProp(_ N: Int) {
4040
res += addLiteralArray()
4141
res -= addLiteralArray()
4242
}
43-
CheckResults(res == 123, "Wrong result in ArrayValueProp 123 != \(res)")
43+
CheckResults(res == 123)
4444
}
4545

4646

@@ -81,7 +81,7 @@ public func run_ArrayValueProp2(_ N: Int) {
8181
res += addLiteralArray2()
8282
res -= addLiteralArray2()
8383
}
84-
CheckResults(res == 123, "Wrong result in ArrayValueProp 123 != \(res)")
84+
CheckResults(res == 123)
8585
}
8686

8787
@inline(never)
@@ -91,7 +91,7 @@ public func run_ArrayValueProp3(_ N: Int) {
9191
res += addLiteralArray3()
9292
res -= addLiteralArray3()
9393
}
94-
CheckResults(res == 123, "Wrong result in ArrayValueProp 123 != \(res)")
94+
CheckResults(res == 123)
9595
}
9696

9797
@inline(never)
@@ -101,5 +101,5 @@ public func run_ArrayValueProp4(_ N: Int) {
101101
res += addLiteralArray4()
102102
res -= addLiteralArray4()
103103
}
104-
CheckResults(res == 123, "Wrong result in ArrayValueProp 123 != \(res)")
104+
CheckResults(res == 123)
105105
}

benchmark/single-source/ArraySubscript.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,5 @@ public func run_ArraySubscript(_ N: Int) {
3434
arrays[i][bound(i)] =
3535
max(arrays[i-1][bound(i-1)], arrays[i][bound(i)])
3636
}
37-
CheckResults(arrays[0][0] <= arrays[numArrays-1][bound(numArrays-1)],
38-
"Incorrect results in QuickSort.")
37+
CheckResults(arrays[0][0] <= arrays[numArrays-1][bound(numArrays-1)])
3938
}

benchmark/single-source/BitCount.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ func countBitSet(_ num: Int) -> Int {
3333
public func run_BitCount(_ N: Int) {
3434
for _ in 1...100*N {
3535
// Check some results.
36-
CheckResults(countBitSet(1) == 1, "Incorrect results in BitCount.")
37-
CheckResults(countBitSet(2) == 1, "Incorrect results in BitCount.")
38-
CheckResults(countBitSet(2457) == 6, "Incorrect results in BitCount.")
36+
CheckResults(countBitSet(1) == 1)
37+
CheckResults(countBitSet(2) == 1)
38+
CheckResults(countBitSet(2457) == 6)
3939
}
4040
}

benchmark/single-source/ByteSwap.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ func byteswap_logn(_ a: UInt64) -> UInt64 {
4242
public func run_ByteSwap(_ N: Int) {
4343
for _ in 1...100*N {
4444
// Check some results.
45-
CheckResults(byteswap_logn(byteswap_n(2457)) == 2457, "Incorrect results in ByteSwap.")
46-
CheckResults(byteswap_logn(byteswap_n(9129)) == 9129, "Incorrect results in ByteSwap.")
47-
CheckResults(byteswap_logn(byteswap_n(3333)) == 3333, "Incorrect results in ByteSwap.")
45+
CheckResults(byteswap_logn(byteswap_n(2457)) == 2457)
46+
CheckResults(byteswap_logn(byteswap_n(9129)) == 9129)
47+
CheckResults(byteswap_logn(byteswap_n(3333)) == 3333)
4848
}
4949
}

benchmark/single-source/CString.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public func run_CStringLongAscii(_ N: Int) {
3636
// static string to c -> from c to String -> implicit conversion
3737
res &= strlen(ascii.withCString(String.init(cString:)))
3838
}
39-
CheckResults(res == 0, "IncorrectResults in run_CStringLongAscii: \(res) != \(refResult)")
39+
CheckResults(res == 0)
4040
}
4141

4242
@inline(never)
@@ -46,7 +46,7 @@ public func run_CStringLongNonAscii(_ N: Int) {
4646
for _ in 1...N*500 {
4747
res &= strlen(japanese.withCString(String.init(cString:)))
4848
}
49-
CheckResults(res == 0, "IncorrectResults in run_CStringLongAscii: \(res) != \(refResult)")
49+
CheckResults(res == 0)
5050
}
5151

5252

@@ -84,6 +84,6 @@ public func run_CStringShortAscii(_ N: Int) {
8484
}
8585
res = res & DoOneIter(strings)
8686
}
87-
assert(res == reference, "IncorrectResults in StrToInt: \(res) != \(reference)")
87+
assert(res == reference)
8888
}
8989

benchmark/single-source/Calculator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ public func run_Calculator(_ N: Int) {
3636
for _ in 1...N*5000 {
3737
c += my_atoi_impl("10")
3838
}
39-
CheckResults(c == 0, "IncorrectResults in run_Calculator")
39+
CheckResults(c == 0)
4040
}
4141

benchmark/single-source/DeadArray.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ public func run_DeadArray(_ N: Int) {
3535
Count = 0
3636
runLoop(0, var2: 0)
3737
}
38-
CheckResults(Count == 100_000, "Incorrect number of calls in loop")
38+
CheckResults(Count == 100_000)
3939
}

benchmark/single-source/DictTest.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ public func run_Dictionary(scale: Int) {
122122
Dict[word] = true
123123
}
124124
}
125-
CheckResults(Dict.count == 270,
126-
"IncorrectResults in DictTest: \(Dict.count) != 270.")
125+
CheckResults(Dict.count == 270)
127126

128127
// Check performance of searching in the dictionary:
129128
// Fill the dictionary with words from the first half of the text
@@ -142,8 +141,7 @@ public func run_Dictionary(scale: Int) {
142141
}
143142
}
144143
}
145-
CheckResults(count == N*541,
146-
"IncorrectResults in DictTest: \(count) != \(N*541).")
144+
CheckResults(count == N*541)
147145
}
148146

149147
class Box<T : Hashable> : Hashable {
@@ -272,8 +270,7 @@ public func run_DictionaryOfObjects(scale: Int) {
272270
Dict[Box(word)] = Box(true)
273271
}
274272
}
275-
CheckResults(Dict.count == 270,
276-
"IncorrectResults in DictTest: \(Dict.count) != 270.")
273+
CheckResults(Dict.count == 270)
277274

278275
// Check performance of searching in the dictionary:
279276
// Fill the dictionary with words from the first half of the text
@@ -292,6 +289,5 @@ public func run_DictionaryOfObjects(scale: Int) {
292289
}
293290
}
294291
}
295-
CheckResults(count == N*541,
296-
"IncorrectResults in DictTestAllObjects: \(count) != \(N*541).")
292+
CheckResults(count == N*541)
297293
}

benchmark/single-source/DictTest2.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public func run_Dictionary2(_ N: Int) {
3434
break
3535
}
3636
}
37-
CheckResults(res == ref_result, "Incorrect results in Dictionary2: \(res) != \(ref_result)")
37+
CheckResults(res == ref_result)
3838
}
3939

4040
class Box<T : Hashable> : Hashable {
@@ -75,5 +75,5 @@ public func run_Dictionary2OfObjects(_ N: Int) {
7575
break
7676
}
7777
}
78-
CheckResults(res == ref_result, "Incorrect results in Dictionary2AllObjects: \(res) != \(ref_result)")
78+
CheckResults(res == ref_result)
7979
}

benchmark/single-source/DictTest3.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public func run_Dictionary3(_ N: Int) {
4141
break
4242
}
4343
}
44-
CheckResults(res == ref_result, "Incorrect results in Dictionary3: \(res) != \(ref_result)")
44+
CheckResults(res == ref_result)
4545
}
4646

4747
class Box<T : Hashable> : Hashable {
@@ -89,5 +89,5 @@ public func run_Dictionary3OfObjects(_ N: Int) {
8989
break
9090
}
9191
}
92-
CheckResults(res == ref_result, "Incorrect results in Dictionary3OfObject: \(res) != \(ref_result)")
92+
CheckResults(res == ref_result)
9393
}

benchmark/single-source/DictionaryBridge.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Thing : NSObject {
2121

2222
required override init() {
2323
let c = type(of: self).col()
24-
CheckResults(c!.count == 10, "The rules of the universe apply")
24+
CheckResults(c!.count == 10)
2525
}
2626

2727
private class func col() -> [String : AnyObject]? {

benchmark/single-source/DictionaryRemove.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public func run_DictionaryRemove(_ N: Int) {
2323
for i in 1...size {
2424
dict[i] = i
2525
}
26-
CheckResults(dict.count == size,
27-
"Incorrect dict count: \(dict.count) != \(size).")
26+
CheckResults(dict.count == size)
2827

2928
var tmpDict = dict
3029
for _ in 1...1000*N {
@@ -38,8 +37,7 @@ public func run_DictionaryRemove(_ N: Int) {
3837
}
3938
}
4039

41-
CheckResults(tmpDict.isEmpty,
42-
"tmpDict should be empty: \(tmpDict.count) != 0.")
40+
CheckResults(tmpDict.isEmpty)
4341
}
4442

4543
class Box<T : Hashable> : Hashable {
@@ -67,8 +65,7 @@ public func run_DictionaryRemoveOfObjects(_ N: Int) {
6765
for i in 1...size {
6866
dict[Box(i)] = Box(i)
6967
}
70-
CheckResults(dict.count == size,
71-
"Incorrect dict count: \(dict.count) != \(size).")
68+
CheckResults(dict.count == size)
7269

7370
var tmpDict = dict
7471
for _ in 1...1000*N {
@@ -82,6 +79,5 @@ public func run_DictionaryRemoveOfObjects(_ N: Int) {
8279
}
8380
}
8481

85-
CheckResults(tmpDict.isEmpty,
86-
"tmpDict should be empty: \(tmpDict.count) != 0.")
82+
CheckResults(tmpDict.isEmpty)
8783
}

benchmark/single-source/DictionarySwap.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public func run_DictionarySwap(_ N: Int) {
2323
for i in 1...size {
2424
dict[i] = i
2525
}
26-
CheckResults(dict.count == size,
27-
"Incorrect dict count: \(dict.count) != \(size).")
26+
CheckResults(dict.count == size)
2827

2928
var swapped = false
3029
for _ in 1...10000*N {
@@ -35,8 +34,7 @@ public func run_DictionarySwap(_ N: Int) {
3534
}
3635
}
3736

38-
CheckResults(swappedCorrectly(swapped, dict[25]!, dict[75]!),
39-
"Dictionary value swap failed")
37+
CheckResults(swappedCorrectly(swapped, dict[25]!, dict[75]!))
4038
}
4139

4240
// Return true if correctly swapped, false otherwise
@@ -70,8 +68,7 @@ public func run_DictionarySwapOfObjects(_ N: Int) {
7068
for i in 1...size {
7169
dict[Box(i)] = Box(i)
7270
}
73-
CheckResults(dict.count == size,
74-
"Incorrect dict count: \(dict.count) != \(size).")
71+
CheckResults(dict.count == size)
7572

7673
var swapped = false
7774
for _ in 1...10000*N {
@@ -82,6 +79,5 @@ public func run_DictionarySwapOfObjects(_ N: Int) {
8279
}
8380
}
8481

85-
CheckResults(swappedCorrectly(swapped, dict[Box(25)]!.value, dict[Box(75)]!.value),
86-
"Dictionary value swap failed")
82+
CheckResults(swappedCorrectly(swapped, dict[Box(25)]!.value, dict[Box(75)]!.value))
8783
}

0 commit comments

Comments
 (0)