@@ -35,50 +35,14 @@ public let IndexPathTest = [
35
35
} ,
36
36
tags: tags,
37
37
setUpFunction: { blackHole ( increasingIndexPath) } ) ,
38
-
39
- BenchmarkInfo (
40
- name: " IndexPath.Max.Beginning " ,
41
- runFunction: { n in
42
- run_IndexPathMaxBeginning ( n * 25 , decreasingIndexPath)
43
- } ,
44
- tags: tags,
45
- setUpFunction: { blackHole ( decreasingIndexPath) } ) ,
46
- BenchmarkInfo (
47
- name: " IndexPath.Max.Middle " ,
48
- runFunction: { n in
49
- run_IndexPathMaxMiddle ( n * 25 , increasingMaxMiddleIndexPath)
50
- } ,
51
- tags: tags,
52
- setUpFunction: { blackHole ( increasingMaxMiddleIndexPath) } ) ,
53
38
BenchmarkInfo (
54
- name: " IndexPath.Max.End " ,
55
- runFunction: { n in
56
- run_IndexPathMaxEnd ( n * 25 , increasingIndexPath)
57
- } ,
58
- tags: tags,
59
- setUpFunction: { blackHole ( increasingIndexPath) } ) ,
60
-
39
+ name: " IndexPath.Max " ,
40
+ runFunction: { n in run_IndexPathMax ( n * 10 ) } ,
41
+ tags: tags) ,
61
42
BenchmarkInfo (
62
- name: " IndexPath.Min.Beginning " ,
63
- runFunction: { n in
64
- run_IndexPathMinBeginning ( n * 25 , increasingIndexPath)
65
- } ,
66
- tags: tags,
67
- setUpFunction: { blackHole ( increasingIndexPath) } ) ,
68
- BenchmarkInfo (
69
- name: " IndexPath.Min.Middle " ,
70
- runFunction: { n in
71
- run_IndexPathMinMiddle ( n * 25 , increasingMinMiddleIndexPath)
72
- } ,
73
- tags: tags,
74
- setUpFunction: { blackHole ( increasingMinMiddleIndexPath) } ) ,
75
- BenchmarkInfo (
76
- name: " IndexPath.Min.End " ,
77
- runFunction: { n in
78
- run_IndexPathMinEnd ( n * 25 , decreasingIndexPath)
79
- } ,
80
- tags: tags,
81
- setUpFunction: { blackHole ( decreasingIndexPath) } ) ,
43
+ name: " IndexPath.Min " ,
44
+ runFunction: { n in run_IndexPathMin ( n * 10 ) } ,
45
+ tags: tags) ,
82
46
]
83
47
84
48
@inline ( __always)
@@ -133,81 +97,34 @@ public func run_IndexPathSubscriptRangeMutation(
133
97
} )
134
98
}
135
99
136
- // Max, Min
137
-
138
- @inline ( __always)
139
- func maxMin(
140
- n: Int ,
141
- indexPath: IndexPath ,
142
- maxMinFunc: ( inout IndexPath ) -> Int ?
143
- ) {
144
- for _ in 0 ..< n {
145
- var ip = indexPath
146
- let found = maxMinFunc ( & ip) != nil
147
- blackHole ( found)
148
- }
149
- }
150
-
151
100
// Max
152
101
153
102
@inline ( never)
154
- public func run_IndexPathMaxBeginning( _ n: Int , _ indexPath: IndexPath ) {
155
- maxMin (
156
- n: n,
157
- indexPath: indexPath,
158
- maxMinFunc: { ip in
159
- ip. max ( )
160
- } )
161
- }
162
-
163
- @inline ( never)
164
- public func run_IndexPathMaxMiddle( _ n: Int , _ indexPath: IndexPath ) {
165
- maxMin (
166
- n: n,
167
- indexPath: indexPath,
168
- maxMinFunc: { ip in
169
- ip. max ( )
170
- } )
171
- }
172
-
173
- @inline ( never)
174
- public func run_IndexPathMaxEnd( _ n: Int , _ indexPath: IndexPath ) {
175
- maxMin (
176
- n: n,
177
- indexPath: indexPath,
178
- maxMinFunc: { ip in
179
- ip. max ( )
180
- } )
103
+ public func run_IndexPathMax( _ n: Int ) {
104
+ for _ in 0 ..< n {
105
+ var val : Int ?
106
+ // Beginning max
107
+ val = decreasingIndexPath. max ( )
108
+ // Middle max
109
+ val = increasingMaxMiddleIndexPath. max ( )
110
+ // End max
111
+ val = increasingIndexPath. max ( )
112
+ blackHole ( val)
113
+ }
181
114
}
182
115
183
116
// Min
184
117
185
118
@inline ( never)
186
- public func run_IndexPathMinBeginning( _ n: Int , _ indexPath: IndexPath ) {
187
- maxMin (
188
- n: n,
189
- indexPath: indexPath,
190
- maxMinFunc: { ip in
191
- ip. min ( )
192
- } )
193
- }
194
-
195
- @inline ( never)
196
- public func run_IndexPathMinMiddle( _ n: Int , _ indexPath: IndexPath ) {
197
- maxMin (
198
- n: n,
199
- indexPath: indexPath,
200
- maxMinFunc: { ip in
201
- ip. min ( )
202
- } )
203
- }
204
-
205
- @inline ( never)
206
- public func run_IndexPathMinEnd( _ n: Int , _ indexPath: IndexPath ) {
207
- maxMin (
208
- n: n,
209
- indexPath: indexPath,
210
- maxMinFunc: { ip in
211
- ip. min ( )
212
- } )
119
+ public func run_IndexPathMin( _ n: Int ) {
120
+ for _ in 0 ..< n {
121
+ var val : Int ?
122
+ // Beginning min
123
+ val = increasingIndexPath. min ( )
124
+ // Middle min
125
+ val = increasingMinMiddleIndexPath. min ( )
126
+ // End min
127
+ val = decreasingIndexPath. min ( )
128
+ blackHole ( val)
129
+ }
213
130
}
0 commit comments