12
12
13
13
import TestsUtils
14
14
15
- var contiguous : [ UInt8 ] ?
15
+ var contiguous : [ UInt8 ] = [ ]
16
16
17
17
public let benchmarks = [
18
- BenchmarkInfo ( name: " NaiveRRC.append.largeContiguous " ,
19
- runFunction: runAppendLargeContiguous,
20
- setUpFunction : { contiguous = [ UInt8 ] ( repeating : 7 , count : 1_000_000 ) } ,
21
- tags : [ . validation , . api ] ) ,
22
- BenchmarkInfo ( name: " NaiveRRC.append.smallContiguousRepeatedly " ,
23
- runFunction: runAppendLargeContiguous,
24
- setUpFunction : { contiguous = [ UInt8 ] ( repeating : 7 , count : 1 ) } ,
25
- tags : [ . validation , . api ] ) ,
26
- BenchmarkInfo ( name: " NaiveRRC.init.largeContiguous " ,
27
- runFunction: runInitContiguous ,
28
- setUpFunction : { contiguous = [ UInt8 ] ( repeating : 7 , count : 1_000_000 ) } ,
29
- tags : [ . validation , . api ] ) ,
18
+ BenchmarkInfo ( name: " NaiveRRC.append.largeContiguous " ,
19
+ runFunction: runAppendLargeContiguous,
20
+ tags : [ . validation , . api ] ,
21
+ setUpFunction : { contiguous = [ UInt8 ] ( repeating : 7 , count : 1_000_000 ) } ) ,
22
+ BenchmarkInfo ( name: " NaiveRRC.append.smallContiguousRepeatedly " ,
23
+ runFunction: runAppendLargeContiguous,
24
+ tags : [ . validation , . api ] ,
25
+ setUpFunction : { contiguous = [ UInt8 ] ( repeating : 7 , count : 1 ) } ) ,
26
+ BenchmarkInfo ( name: " NaiveRRC.init.largeContiguous " ,
27
+ runFunction: runInitLargeContiguous ,
28
+ tags : [ . validation , . api ] ,
29
+ setUpFunction : { contiguous = [ UInt8 ] ( repeating : 7 , count : 1_000_000 ) } )
30
30
]
31
31
32
32
struct NaiveRRC : RangeReplaceableCollection {
@@ -78,7 +78,7 @@ public func runAppendLargeContiguous(N: Int) {
78
78
for _ in 1 ... N {
79
79
var rrc = NaiveRRC ( )
80
80
rrc. append ( contentsOf: contiguous)
81
- blackHole ( rrc. count + rrc. last )
81
+ blackHole ( rrc. count + rrc[ 0 ] )
82
82
}
83
83
}
84
84
@@ -89,14 +89,14 @@ public func runAppendSmallContiguousRepeatedly(N: Int) {
89
89
for _ in 1 ... 1_000_000 {
90
90
rrc. append ( contentsOf: contiguous)
91
91
}
92
- blackHole ( rrc. count + rrc. last )
92
+ blackHole ( rrc. count + rrc[ 0 ] )
93
93
}
94
94
}
95
95
96
96
@inline ( never)
97
97
public func runInitLargeContiguous( N: Int ) {
98
98
for _ in 1 ... N {
99
99
var rrc = NaiveRRC ( contiguous)
100
- blackHole ( rrc. count + rrc. last )
100
+ blackHole ( rrc. count + rrc[ 0 ] )
101
101
}
102
102
}
0 commit comments