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 = [
1818 )
1919]
2020
21+ class Slow {
22+ public var num : Int
23+
24+ init ( num: Int ) {
25+ self . num = num
26+ }
27+ }
28+
2129let size_Int = 1_000_000
2230let size_Class = 100_000
2331
@@ -39,44 +47,27 @@ var inputArray_Class: [Slow]! = {
3947 return a
4048} ( )
4149
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-
5650@inline ( never)
5751func removeAll< T> ( _ arr: [ T ] ) -> [ T ] {
5852 var copy = arr
5953 copy. removeAll ( keepingCapacity: true )
6054 return copy
6155}
6256
63- @inline ( never)
64- func copyItem< T> ( _ item: T ) -> T {
65- return item
66- }
67-
6857@inline ( never)
6958func 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)
7362 }
63+ check ( copy. capacity == inputArray_Class. capacity)
7464}
7565
7666@inline ( never)
7767func 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)
8171 }
72+ check ( copy. capacity == inputArray_Int. capacity)
8273}
You can’t perform that action at this time.
0 commit comments