Skip to content

Commit 779252a

Browse files
committed
[benchmark] Rework SuperChars
Rework SuperChars into something that: * Doesn't crash in asserts configurations (i.e. has valid Characters) * Actually runs (i.e. use blackHole on comparison result) * Runs in around 1ms (it's cubic complexity in payload size)
1 parent 3eb24d4 commit 779252a

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

benchmark/single-source/SuperChars.swift

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,18 @@
1414
import TestsUtils
1515

1616
public let SuperChars = BenchmarkInfo(
17-
name: "SuperChars",
17+
name: "SuperChars2",
1818
runFunction: run_SuperChars,
1919
tags: [.validation, .api, .String],
2020
setUpFunction: { blackHole(alphabetInput) })
2121

2222
// Permute some characters.
2323
let alphabetInput: [Character] = [
24-
"A", "B", "C", "D", "E", "F", "G",
25-
"«", // throw in some unicode to make it slower
26-
"H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
27-
"á", "",
28-
"S", "T", "U",
29-
"🇯🇵",
30-
"V", "W", "X", "Y", "Z", "/", "f", "Z", "z", "6", "7", "C", "j", "f", "9",
31-
"🇯🇵🇺🇸", "🇯🇵🇺🇸🇨🇳", "🇯🇵🇺🇸🇨🇳🇩🇪",
32-
"g", "g", "I", "J", "K", "c", "x", "i", ".",
33-
"🇯🇵🇺🇸🇨🇳🇩🇪", "🇯🇵🇺🇸", "🇯🇵🇺🇸🇨🇳",
34-
"2", "a", "t", "i", "o", "e", "q", "n", "X", "Y", "Z", "?", "m", "Z", ","
24+
"A", "B", "C", "D", "E", "F", "«",
25+
"H", "I", "J", "K", "L", "M", "N",
26+
"á", "", "S", "T", "U", "🇯🇵",
27+
"🧟‍♀️", "👩‍👦‍👦", "g", "g", "I",
28+
"🕴🏿", "2", "a", "t", "n", "?",
3529
]
3630

3731
@inline(never)
@@ -43,7 +37,7 @@ public func run_SuperChars(_ N: Int) {
4337
for firstChar in alphabet {
4438
for middleChar in alphabet {
4539
for lastChar in alphabet {
46-
_ = ((firstChar == middleChar) != (middleChar < lastChar))
40+
blackHole((firstChar == middleChar) != (middleChar < lastChar))
4741
}
4842
}
4943
}

0 commit comments

Comments
 (0)