@@ -21,28 +21,25 @@ public let DictionarySubscriptDefault = [
21
21
tags: [ . validation, . api, . Dictionary] ) ,
22
22
BenchmarkInfo ( name: " DictionarySubscriptDefaultMutationOfObjects " ,
23
23
runFunction: run_DictionarySubscriptDefaultMutationOfObjects,
24
- tags: [ . validation, . api, . Dictionary] ) ,
24
+ tags: [ . validation, . api, . Dictionary] , legacyFactor : 20 ) ,
25
25
BenchmarkInfo ( name: " DictionarySubscriptDefaultMutationArrayOfObjects " ,
26
26
runFunction:
27
27
run_DictionarySubscriptDefaultMutationArrayOfObjects,
28
- tags: [ . validation, . api, . Dictionary] ) ,
28
+ tags: [ . validation, . api, . Dictionary] , legacyFactor : 20 ) ,
29
29
]
30
30
31
- let count = 10_000
32
- let result = count / 100
33
-
34
31
@inline ( never)
35
32
public func run_DictionarySubscriptDefaultMutation( _ N: Int ) {
36
33
for _ in 1 ... N {
37
34
38
35
var dict = [ Int: Int] ( )
39
36
40
- for i in 0 ..< count {
37
+ for i in 0 ..< 10_000 {
41
38
dict [ i % 100 , default: 0 ] += 1
42
39
}
43
40
44
41
CheckResults ( dict. count == 100 )
45
- CheckResults ( dict [ 0 ] ! == result )
42
+ CheckResults ( dict [ 0 ] ! == 100 )
46
43
}
47
44
}
48
45
@@ -52,12 +49,12 @@ public func run_DictionarySubscriptDefaultMutationArray(_ N: Int) {
52
49
53
50
var dict = [ Int: [ Int] ] ( )
54
51
55
- for i in 0 ..< count {
52
+ for i in 0 ..< 10_000 {
56
53
dict [ i % 100 , default: [ ] ] . append ( i)
57
54
}
58
55
59
56
CheckResults ( dict. count == 100 )
60
- CheckResults ( dict [ 0 ] !. count == result )
57
+ CheckResults ( dict [ 0 ] !. count == 100 )
61
58
}
62
59
}
63
60
@@ -99,26 +96,26 @@ public func run_DictionarySubscriptDefaultMutationOfObjects(_ N: Int) {
99
96
100
97
var dict = [ Box < Int > : Box < Int > ] ( )
101
98
102
- for i in 0 ..< count {
103
- dict [ Box ( i % 100 ) , default: Box ( 0 ) ] . mutateValue { $0 += 1 }
99
+ for i in 0 ..< 500 {
100
+ dict [ Box ( i % 5 ) , default: Box ( 0 ) ] . mutateValue { $0 += 1 }
104
101
}
105
102
106
- CheckResults ( dict. count == 100 )
107
- CheckResults ( dict [ Box ( 0 ) ] !. value == result )
103
+ CheckResults ( dict. count == 5 )
104
+ CheckResults ( dict [ Box ( 0 ) ] !. value == 100 )
108
105
}
109
106
}
110
107
111
108
@inline ( never)
112
109
public func run_DictionarySubscriptDefaultMutationArrayOfObjects( _ N: Int ) {
113
- for _ in 1 ... N {
110
+ for _ in 1 ... N {
114
111
115
112
var dict = [ Box < Int > : [ Box < Int > ] ] ( )
116
113
117
- for i in 0 ..< count {
118
- dict [ Box ( i % 100 ) , default: [ ] ] . append ( Box ( i) )
114
+ for i in 0 ..< 500 {
115
+ dict [ Box ( i % 5 ) , default: [ ] ] . append ( Box ( i) )
119
116
}
120
117
121
- CheckResults ( dict. count == 100 )
122
- CheckResults ( dict [ Box ( 0 ) ] !. count == result )
118
+ CheckResults ( dict. count == 5 )
119
+ CheckResults ( dict [ Box ( 0 ) ] !. count == 100 )
123
120
}
124
121
}
0 commit comments