2
2
import TestsUtils
3
3
4
4
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 ) ,
7
13
]
8
14
9
15
@inline ( never)
@@ -27,7 +33,7 @@ public func run_DictionaryCompactMapValuesOfNilValue(_ N: Int) {
27
33
}
28
34
29
35
var newDict = [ Int: Int] ( )
30
- for _ in 1 ... 1000 * N {
36
+ for _ in 1 ... 20 * N {
31
37
newDict = dict. compactMapValues ( { $0} )
32
38
if newDict != refDict {
33
39
break
@@ -41,7 +47,7 @@ public func run_DictionaryCompactMapValuesOfNilValue(_ N: Int) {
41
47
public func run_DictionaryCompactMapValuesOfCastValue( _ N: Int ) {
42
48
let size = 100
43
49
var dict = [ Int: String] ( minimumCapacity: size)
44
-
50
+
45
51
// Fill Dictionary
46
52
for i in 1 ... size {
47
53
if i % 2 == 0 {
@@ -50,7 +56,7 @@ public func run_DictionaryCompactMapValuesOfCastValue(_ N: Int) {
50
56
dict [ i] = " \( i) "
51
57
}
52
58
}
53
-
59
+
54
60
CheckResults ( dict. count == size)
55
61
56
62
var refDict = [ Int: Int] ( )
@@ -59,13 +65,12 @@ public func run_DictionaryCompactMapValuesOfCastValue(_ N: Int) {
59
65
}
60
66
61
67
var newDict = [ Int: Int] ( )
62
- for _ in 1 ... 1000 * N {
68
+ for _ in 1 ... 20 * N {
63
69
newDict = dict. compactMapValues ( Int . init)
64
70
if newDict != refDict {
65
71
break
66
72
}
67
73
}
68
-
74
+
69
75
CheckResults ( newDict == refDict)
70
76
}
71
-
0 commit comments