Skip to content

Commit 9171f79

Browse files
Reverted a change that should have gone into another branch.
1 parent dd8fb4a commit 9171f79

File tree

1 file changed

+0
-74
lines changed

1 file changed

+0
-74
lines changed

benchmark/single-source/KeyPathPerformanceTests.swift

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ public let benchmarks = [
6666
tags: [.validation, .api],
6767
setUpFunction: setupKeyPathNestedStructs
6868
),
69-
BenchmarkInfo(
70-
name: "KeyPathClassStructs",
71-
runFunction: run_KeyPathClassStructs,
72-
tags: [.validation, .api],
73-
setUpFunction: setupKeyPathNestedStructs
74-
),
7569
]
7670

7771
/**
@@ -103,7 +97,6 @@ class FixedSizeArrayHolder {
10397
var fixedSizeArray100: FixedSizeArray100<ElementType>
10498
var fixedSizeArray10: FixedSizeArray10<ElementType>
10599
var mainArrayForNestedStructs: [A]
106-
var mainArrayForClassStructs: [D1]
107100
var arrayForMutatingGetset: [MutatingGetsetNested1]
108101
var arrayForGet: [GetNested1]
109102
var arrayForOptionals: [Optional1]
@@ -114,7 +107,6 @@ class FixedSizeArrayHolder {
114107
var keypathForOptional: KeyPath<Optional1, Int?>
115108
var keypathForNestedClasses: KeyPath<C1, Int>
116109
var keypathForNonMutatingGetset: WritableKeyPath<M, Int>
117-
var keypathForClassStructs: WritableKeyPath<D1, Int>
118110

119111
// Same order as in KeyPathWritePerformance
120112
var kp46: WritableKeyPath<FixedSizeArray100<ElementType>, ElementType>
@@ -184,7 +176,6 @@ class FixedSizeArrayHolder {
184176
fixedSizeArray100 = initializeFixedSizeArray100()
185177
fixedSizeArray10 = initializeFixedSizeArray10()
186178
mainArrayForNestedStructs = [A]()
187-
mainArrayForClassStructs = [D1]()
188179
arrayForMutatingGetset = [MutatingGetsetNested1]()
189180
arrayForGet = [GetNested1]()
190181
arrayForOptionals = [Optional1]()
@@ -261,7 +252,6 @@ class FixedSizeArrayHolder {
261252
._nestedItemStorage?!._nestedItemStorage?!._storage)
262253
keypathForNestedClasses = identity(\C1.r.r.r.r.a)
263254
keypathForNonMutatingGetset = identity(\M.n.o.p.q.q)
264-
keypathForClassStructs = identity(\D1.b.c.d.e.e)
265255
}
266256
}
267257

@@ -272,10 +262,6 @@ public func setupKeyPathNestedStructs() {
272262
let instance = A(a: 0, b: B(b: 0, c: C(c: 0, d: D(d: 0, e: E(e: expectedIntForNestedItems)))))
273263
holder.mainArrayForNestedStructs.append(instance)
274264

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-
279265
var mutatingGetsetInstance = MutatingGetsetNested1()
280266
mutatingGetsetInstance.nestedItem.nestedItem.nestedItem.nestedItem
281267
.storage = expectedIntForNestedItems
@@ -347,36 +333,6 @@ struct E {
347333
var e: Int
348334
}
349335

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-
380336
// Used for run_KeyPathNestedClasses()
381337
class C1 {
382338
let a: Int = 0
@@ -1370,36 +1326,6 @@ public func run_KeyPathNestedStructs(n: Int) {
13701326
check(sum == iterationMultipier * n * expectedIntForNestedItems)
13711327
}
13721328

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-
14031329
// This is meant as a baseline, from a timing perspective,
14041330
// for run_testKeyPathReadPerformance() and run_testKeyPathWritePerformance().
14051331
// It's currently set to ".skip", but is useful for comparing the performance between keypath operations and direct dot-notation.

0 commit comments

Comments
 (0)