File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,12 @@ public let benchmarks = [
9191 BenchmarkInfo ( name: " NSArray.nonbridged.mutableCopy.objectAtIndex " ,
9292 runFunction: run_RealNSArrayMutableCopyObjectAtIndex, tags: t,
9393 setUpFunction: setup_bridgedArrays) ,
94+ BenchmarkInfo ( name: " NSArray.bridged.bufferAccess " ,
95+ runFunction: run_BridgedNSArrayBufferAccess, tags: t,
96+ setUpFunction: setup_bridgedArrays) ,
97+ BenchmarkInfo ( name: " NSArray.bridged.repeatedBufferAccess " ,
98+ runFunction: run_BridgedNSArrayRepeatedBufferAccess, tags: t,
99+ setUpFunction: setup_bridgedArrays) ,
94100]
95101
96102#if _runtime(_ObjC)
@@ -814,6 +820,36 @@ public func run_BridgedNSArrayObjectAtIndex(_ n: Int) {
814820 #endif
815821}
816822
823+ @inline ( never)
824+ public func run_BridgedNSArrayBufferAccess( _ n: Int ) {
825+ #if _runtime(_ObjC)
826+ for _ in 0 ..< n {
827+ for i in 0 ..< 1000 {
828+ let tmp = nsArray as! [ NSObject ]
829+ blackHole ( tmp)
830+ blackHole ( tmp. withContiguousStorageIfAvailable {
831+ $0 [ 0 ]
832+ } )
833+ }
834+ }
835+ #endif
836+ }
837+
838+ @inline ( never)
839+ public func run_BridgedNSArrayRepeatedBufferAccess( _ n: Int ) {
840+ #if _runtime(_ObjC)
841+ for _ in 0 ..< n {
842+ let tmp = nsArray as! [ NSObject ]
843+ blackHole ( tmp)
844+ for i in 0 ..< 1000 {
845+ blackHole ( tmp. withContiguousStorageIfAvailable {
846+ $0 [ 0 ]
847+ } )
848+ }
849+ }
850+ #endif
851+ }
852+
817853@inline ( never)
818854public func run_BridgedNSArrayMutableCopyObjectAtIndex( _ n: Int ) {
819855 #if _runtime(_ObjC)
You can’t perform that action at this time.
0 commit comments