mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add benchmarks for withContiguousStorageIfAvailable on bridged NSArrays (#75215)
This commit is contained in:
@@ -91,6 +91,12 @@ public let benchmarks = [
|
||||
BenchmarkInfo(name: "NSArray.nonbridged.mutableCopy.objectAtIndex",
|
||||
runFunction: run_RealNSArrayMutableCopyObjectAtIndex, tags: t,
|
||||
setUpFunction: setup_bridgedArrays),
|
||||
BenchmarkInfo(name: "NSArray.bridged.bufferAccess",
|
||||
runFunction: run_BridgedNSArrayBufferAccess, tags: t,
|
||||
setUpFunction: setup_bridgedArrays),
|
||||
BenchmarkInfo(name: "NSArray.bridged.repeatedBufferAccess",
|
||||
runFunction: run_BridgedNSArrayRepeatedBufferAccess, tags: t,
|
||||
setUpFunction: setup_bridgedArrays),
|
||||
]
|
||||
|
||||
#if _runtime(_ObjC)
|
||||
@@ -814,6 +820,36 @@ public func run_BridgedNSArrayObjectAtIndex(_ n: Int) {
|
||||
#endif
|
||||
}
|
||||
|
||||
@inline(never)
|
||||
public func run_BridgedNSArrayBufferAccess(_ n: Int) {
|
||||
#if _runtime(_ObjC)
|
||||
for _ in 0 ..< n {
|
||||
for i in 0..<1000 {
|
||||
let tmp = nsArray as! [NSObject]
|
||||
blackHole(tmp)
|
||||
blackHole(tmp.withContiguousStorageIfAvailable {
|
||||
$0[0]
|
||||
})
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@inline(never)
|
||||
public func run_BridgedNSArrayRepeatedBufferAccess(_ n: Int) {
|
||||
#if _runtime(_ObjC)
|
||||
for _ in 0 ..< n {
|
||||
let tmp = nsArray as! [NSObject]
|
||||
blackHole(tmp)
|
||||
for i in 0..<1000 {
|
||||
blackHole(tmp.withContiguousStorageIfAvailable {
|
||||
$0[0]
|
||||
})
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@inline(never)
|
||||
public func run_BridgedNSArrayMutableCopyObjectAtIndex(_ n: Int) {
|
||||
#if _runtime(_ObjC)
|
||||
|
||||
Reference in New Issue
Block a user