File tree Expand file tree Collapse file tree 1 file changed +16
-25
lines changed Expand file tree Collapse file tree 1 file changed +16
-25
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ public let benchmarks = [
18
18
)
19
19
]
20
20
21
+ class Slow {
22
+ public var num : Int
23
+
24
+ init ( num: Int ) {
25
+ self . num = num
26
+ }
27
+ }
28
+
21
29
let size_Int = 1_000_000
22
30
let size_Class = 100_000
23
31
@@ -39,44 +47,27 @@ var inputArray_Class: [Slow]! = {
39
47
return a
40
48
} ( )
41
49
42
- class Slow {
43
- public var num : Int
44
-
45
- init ( num: Int ) {
46
- self . num = num
47
- }
48
- }
49
-
50
-
51
- @inline ( never)
52
- func verifyCapacity< T> ( _ new: [ T ] , orig: [ T ] ) -> Bool {
53
- return new. capacity == orig. capacity
54
- }
55
-
56
50
@inline ( never)
57
51
func removeAll< T> ( _ arr: [ T ] ) -> [ T ] {
58
52
var copy = arr
59
53
copy. removeAll ( keepingCapacity: true )
60
54
return copy
61
55
}
62
56
63
- @inline ( never)
64
- func copyItem< T> ( _ item: T ) -> T {
65
- return item
66
- }
67
-
68
57
@inline ( never)
69
58
func run_ArrayRemoveAll_Class( _ n: Int ) {
70
- for _ in 1 ... n {
71
- let copy = removeAll ( inputArray_Class )
72
- check ( verifyCapacity ( copy, orig : inputArray_Class) )
59
+ var copy = removeAll ( inputArray_Class ) ;
60
+ for _ in 1 ..< n {
61
+ copy = removeAll ( inputArray_Class)
73
62
}
63
+ check ( copy. capacity == inputArray_Class. capacity)
74
64
}
75
65
76
66
@inline ( never)
77
67
func run_ArrayRemoveAll_Int( _ n: Int ) {
78
- for _ in 1 ... n {
79
- let copy = removeAll ( inputArray_Int )
80
- check ( verifyCapacity ( copy, orig : inputArray_Int) )
68
+ var copy = removeAll ( inputArray_Int ) ;
69
+ for _ in 1 ..< n {
70
+ copy = removeAll ( inputArray_Int)
81
71
}
72
+ check ( copy. capacity == inputArray_Int. capacity)
82
73
}
You can’t perform that action at this time.
0 commit comments