Skip to content

Commit f54b402

Browse files
committed
[benchmark] StringEdits Legacy Factor
1 parent 7ed9ddb commit f54b402

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

benchmark/single-source/StringEdits.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import Darwin
2020
public let StringEdits = BenchmarkInfo(
2121
name: "StringEdits",
2222
runFunction: run_StringEdits,
23-
tags: [.validation, .api, .String])
23+
tags: [.validation, .api, .String],
24+
legacyFactor: 100)
2425

2526
var editWords: [String] = [
2627
"woodshed",
@@ -34,42 +35,41 @@ func edits(_ word: String) -> Set<String> {
3435
let splits = word.indices.map {
3536
(String(word[..<$0]), String(word[$0...]))
3637
}
37-
38+
3839
var result: Array<String> = []
39-
40+
4041
for (left, right) in splits {
4142
// drop a character
4243
result.append(left + right.dropFirst())
43-
44+
4445
// transpose two characters
4546
if let fst = right.first {
4647
let drop1 = right.dropFirst()
4748
if let snd = drop1.first {
4849
result.append(left + [snd,fst] + drop1.dropFirst())
4950
}
5051
}
51-
52+
5253
// replace each character with another
5354
for letter in alphabet {
5455
result.append(left + [letter] + right.dropFirst())
5556
}
56-
57+
5758
// insert rogue characters
5859
for letter in alphabet {
5960
result.append(left + [letter] + right)
6061
}
6162
}
62-
63+
6364
// have to map back to strings right at the end
6465
return Set(result)
6566
}
6667

6768
@inline(never)
6869
public func run_StringEdits(_ N: Int) {
69-
for _ in 1...N*100 {
70+
for _ in 1...N {
7071
for word in editWords {
71-
_ = edits(word)
72+
_ = edits(word)
7273
}
7374
}
7475
}
75-

0 commit comments

Comments
 (0)