Skip to content

Commit 311ddce

Browse files
committed
[benchmark] DictionaryCompactMapValues tweeks
Extracted run functions and added setUpFunctions.
1 parent 2704a3e commit 311ddce

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

benchmark/single-source/DictionaryCompactMapValues.swift

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,23 @@ let t: [BenchmarkCategory] = [.validation, .api, .Dictionary]
2525

2626
public let DictionaryCompactMapValues = [
2727
BenchmarkInfo(name: "DictionaryCompactMapValuesOfNilValue",
28-
runFunction: { for _ in 1...$0*20 {
29-
CheckResults(smallOddNumMap.compactMapValues({$0}) == compactOddNums) }},
30-
tags: t, legacyFactor: 50),
28+
runFunction: compactMapValues, tags: t,
29+
setUpFunction: { blackHole(smallOddNumMap); blackHole(compactOddNums)},
30+
legacyFactor: 50),
3131
BenchmarkInfo(name: "DictionaryCompactMapValuesOfCastValue",
32-
runFunction: { for _ in 1...$0*20 {
33-
CheckResults(oddStringMap.compactMapValues(Int.init) == compactOddNums) }
34-
}, tags: t, legacyFactor: 54),
32+
runFunction: compactMapValuesInt, tags: t,
33+
setUpFunction: { blackHole(oddStringMap); blackHole(compactOddNums)},
34+
legacyFactor: 54),
3535
]
36+
37+
func compactMapValues(N: Int) {
38+
for _ in 1...20*N {
39+
CheckResults(smallOddNumMap.compactMapValues({$0}) == compactOddNums)
40+
}
41+
}
42+
43+
func compactMapValuesInt(N: Int) {
44+
for _ in 1...20*N {
45+
CheckResults(oddStringMap.compactMapValues(Int.init) == compactOddNums)
46+
}
47+
}

0 commit comments

Comments
 (0)