Skip to content

Commit 8d0544d

Browse files
committed
[benchmark] DictionaryCompatMapValues legacyFactor
1 parent 64d610b commit 8d0544d

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

benchmark/single-source/DictionaryCompactMapValues.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
import TestsUtils
33

44
public let DictionaryCompactMapValues = [
5-
BenchmarkInfo(name: "DictionaryCompactMapValuesOfNilValue", runFunction: run_DictionaryCompactMapValuesOfNilValue, tags: [.validation, .api, .Dictionary]),
6-
BenchmarkInfo(name: "DictionaryCompactMapValuesOfCastValue", runFunction: run_DictionaryCompactMapValuesOfCastValue, tags: [.validation, .api, .Dictionary]),
5+
BenchmarkInfo(name: "DictionaryCompactMapValuesOfNilValue",
6+
runFunction: run_DictionaryCompactMapValuesOfNilValue,
7+
tags: [.validation, .api, .Dictionary],
8+
legacyFactor: 50),
9+
BenchmarkInfo(name: "DictionaryCompactMapValuesOfCastValue",
10+
runFunction: run_DictionaryCompactMapValuesOfCastValue,
11+
tags: [.validation, .api, .Dictionary],
12+
legacyFactor: 50),
713
]
814

915
@inline(never)
@@ -27,7 +33,7 @@ public func run_DictionaryCompactMapValuesOfNilValue(_ N: Int) {
2733
}
2834

2935
var newDict = [Int: Int]()
30-
for _ in 1...1000*N {
36+
for _ in 1...20*N {
3137
newDict = dict.compactMapValues({$0})
3238
if newDict != refDict {
3339
break
@@ -41,7 +47,7 @@ public func run_DictionaryCompactMapValuesOfNilValue(_ N: Int) {
4147
public func run_DictionaryCompactMapValuesOfCastValue(_ N: Int) {
4248
let size = 100
4349
var dict = [Int: String](minimumCapacity: size)
44-
50+
4551
// Fill Dictionary
4652
for i in 1...size {
4753
if i % 2 == 0 {
@@ -50,7 +56,7 @@ public func run_DictionaryCompactMapValuesOfCastValue(_ N: Int) {
5056
dict[i] = "\(i)"
5157
}
5258
}
53-
59+
5460
CheckResults(dict.count == size)
5561

5662
var refDict = [Int: Int]()
@@ -59,13 +65,12 @@ public func run_DictionaryCompactMapValuesOfCastValue(_ N: Int) {
5965
}
6066

6167
var newDict = [Int: Int]()
62-
for _ in 1...1000*N {
68+
for _ in 1...20*N {
6369
newDict = dict.compactMapValues(Int.init)
6470
if newDict != refDict {
6571
break
6672
}
6773
}
68-
74+
6975
CheckResults(newDict == refDict)
7076
}
71-

0 commit comments

Comments
 (0)