Skip to content

Commit 008ed2f

Browse files
committed
[benchmark] clean up setup for ArrayRemoveAll
1 parent d489ba2 commit 008ed2f

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

benchmark/single-source/ArrayRemoveAll.swift

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
// This test checks the performance of removeAll on a non-uniquely referenced array.
1+
// This test checks the performance of removeAll
2+
// on a non-uniquely referenced array.
3+
24
import TestsUtils
35

46
public let benchmarks = [
57
BenchmarkInfo(
68
name: "ArrayRemoveAll_Class",
79
runFunction: run_ArrayRemoveAll_Class,
810
tags: [.validation, .api, .Array],
9-
setUpFunction: { blackHole(inputArray_Class) },
10-
tearDownFunction: { inputArray_Class = nil }
11+
setUpFunction: { blackHole(inputArray_Class) }
1112
),
1213
BenchmarkInfo(
1314
name: "ArrayRemoveAll_Int",
1415
runFunction: run_ArrayRemoveAll_Int,
1516
tags: [.validation, .api, .Array],
16-
setUpFunction: { blackHole(inputArray_Int) },
17-
tearDownFunction: { inputArray_Int = nil }
17+
setUpFunction: { blackHole(inputArray_Int) }
1818
)
1919
]
2020

@@ -26,26 +26,8 @@ class Slow {
2626
}
2727
}
2828

29-
let size_Int = 1_000_000
30-
let size_Class = 100_000
31-
32-
var inputArray_Int: [Int]! = {
33-
var a: [Int] = []
34-
a.reserveCapacity(size_Int)
35-
for i in 0 ..< size_Int {
36-
a.append(i)
37-
}
38-
return a
39-
}()
40-
41-
var inputArray_Class: [Slow]! = {
42-
var a: [Slow] = []
43-
a.reserveCapacity(size_Class)
44-
for i in 0 ..< size_Class {
45-
a.append(Slow(num: i))
46-
}
47-
return a
48-
}()
29+
let inputArray_Int: [Int] = Array(0..<1_000_000)
30+
let inputArray_Class: [Slow] = (0..<100_000).map(Slow.init(num:))
4931

5032
@inline(never)
5133
func removeAll<T>(_ arr: [T]) -> [T] {

0 commit comments

Comments
 (0)