@@ -66,12 +66,6 @@ public let benchmarks = [
66
66
tags: [ . validation, . api] ,
67
67
setUpFunction: setupKeyPathNestedStructs
68
68
) ,
69
- BenchmarkInfo (
70
- name: " KeyPathClassStructs " ,
71
- runFunction: run_KeyPathClassStructs,
72
- tags: [ . validation, . api] ,
73
- setUpFunction: setupKeyPathNestedStructs
74
- ) ,
75
69
]
76
70
77
71
/**
@@ -103,7 +97,6 @@ class FixedSizeArrayHolder {
103
97
var fixedSizeArray100 : FixedSizeArray100 < ElementType >
104
98
var fixedSizeArray10 : FixedSizeArray10 < ElementType >
105
99
var mainArrayForNestedStructs : [ A ]
106
- var mainArrayForClassStructs : [ D1 ]
107
100
var arrayForMutatingGetset : [ MutatingGetsetNested1 ]
108
101
var arrayForGet : [ GetNested1 ]
109
102
var arrayForOptionals : [ Optional1 ]
@@ -114,7 +107,6 @@ class FixedSizeArrayHolder {
114
107
var keypathForOptional : KeyPath < Optional1 , Int ? >
115
108
var keypathForNestedClasses : KeyPath < C1 , Int >
116
109
var keypathForNonMutatingGetset : WritableKeyPath < M , Int >
117
- var keypathForClassStructs : WritableKeyPath < D1 , Int >
118
110
119
111
// Same order as in KeyPathWritePerformance
120
112
var kp46 : WritableKeyPath < FixedSizeArray100 < ElementType > , ElementType >
@@ -184,7 +176,6 @@ class FixedSizeArrayHolder {
184
176
fixedSizeArray100 = initializeFixedSizeArray100 ( )
185
177
fixedSizeArray10 = initializeFixedSizeArray10 ( )
186
178
mainArrayForNestedStructs = [ A] ( )
187
- mainArrayForClassStructs = [ D1] ( )
188
179
arrayForMutatingGetset = [ MutatingGetsetNested1] ( )
189
180
arrayForGet = [ GetNested1] ( )
190
181
arrayForOptionals = [ Optional1] ( )
@@ -261,7 +252,6 @@ class FixedSizeArrayHolder {
261
252
. _nestedItemStorage?! . _nestedItemStorage?! . _storage)
262
253
keypathForNestedClasses = identity ( \C1 . r. r. r. r. a)
263
254
keypathForNonMutatingGetset = identity ( \M . n. o. p. q. q)
264
- keypathForClassStructs = identity ( \D1 . b. c. d. e. e)
265
255
}
266
256
}
267
257
@@ -272,10 +262,6 @@ public func setupKeyPathNestedStructs() {
272
262
let instance = A ( a: 0 , b: B ( b: 0 , c: C ( c: 0 , d: D ( d: 0 , e: E ( e: expectedIntForNestedItems) ) ) ) )
273
263
holder. mainArrayForNestedStructs. append ( instance)
274
264
275
- let classStructInstance = D1 ( b: D2 ( b: 0 , c: D3 ( c: 0 , d: D4 ( d: 0 ,
276
- e: D5 ( e: expectedIntForNestedItems) ) ) ) )
277
- holder. mainArrayForClassStructs. append ( classStructInstance)
278
-
279
265
var mutatingGetsetInstance = MutatingGetsetNested1 ( )
280
266
mutatingGetsetInstance. nestedItem. nestedItem. nestedItem. nestedItem
281
267
. storage = expectedIntForNestedItems
@@ -347,36 +333,6 @@ struct E {
347
333
var e : Int
348
334
}
349
335
350
- // Used for run_KeyPathClassStruct().
351
- class D1 {
352
- var a : Int
353
- var b : D2
354
- init ( b: D2 )
355
- {
356
- a = 0
357
- self . b = b
358
- }
359
- }
360
-
361
- struct D2 {
362
- var b : Int
363
- var c : D3
364
- }
365
-
366
- struct D3 {
367
- var c : Int
368
- var d : D4
369
- }
370
-
371
- struct D4 {
372
- var d : Int
373
- var e : D5
374
- }
375
-
376
- struct D5 {
377
- var e : Int
378
- }
379
-
380
336
// Used for run_KeyPathNestedClasses()
381
337
class C1 {
382
338
let a : Int = 0
@@ -1370,36 +1326,6 @@ public func run_KeyPathNestedStructs(n: Int) {
1370
1326
check ( sum == iterationMultipier * n * expectedIntForNestedItems)
1371
1327
}
1372
1328
1373
- // This measures the performance of keypath reads where a block of
1374
- // trivially-typed memory is preceded by something else (optionals, reference
1375
- // types, etc.)
1376
- @inline ( never)
1377
- public func run_KeyPathClassStructs( n: Int ) {
1378
- var sum = 0
1379
- var index = 0
1380
- let iterationMultipier = 2000
1381
-
1382
- let singleHopKeyPath0 : WritableKeyPath < D1 , D2 > = \D1 . b
1383
- let singleHopKeyPath1 : WritableKeyPath < D2 , D3 > = \D2 . c
1384
- let singleHopKeyPath2 : WritableKeyPath < D3 , D4 > = \D3 . d
1385
- let singleHopKeyPath3 : WritableKeyPath < D4 , D5 > = \D4 . e
1386
- let singleHopKeyPath4 : WritableKeyPath < D5 , Int > = \D5 . e
1387
-
1388
- let appendedKeyPath = identity ( singleHopKeyPath0. appending ( path: singleHopKeyPath1)
1389
- . appending ( path: singleHopKeyPath2) . appending ( path: singleHopKeyPath3)
1390
- . appending ( path: singleHopKeyPath4) )
1391
-
1392
- let elementCount = FixedSizeArrayHolder . shared. mainArrayForClassStructs. count
1393
- for _ in 1 ... iterationMultipier * n {
1394
- let element = FixedSizeArrayHolder . shared. mainArrayForClassStructs [ index]
1395
- sum += element [ keyPath: appendedKeyPath]
1396
- index = ( index + 1 ) % elementCount
1397
- }
1398
- check ( sum == iterationMultipier * n * expectedIntForNestedItems)
1399
- }
1400
-
1401
-
1402
-
1403
1329
// This is meant as a baseline, from a timing perspective,
1404
1330
// for run_testKeyPathReadPerformance() and run_testKeyPathWritePerformance().
1405
1331
// It's currently set to ".skip", but is useful for comparing the performance between keypath operations and direct dot-notation.
0 commit comments