mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[interop] benchmark: add run_CxxVectorOfU32_Sum_Swift_RawIteratorLoop that doesn't use C++ inline helpers
This commit is contained in:
@@ -30,6 +30,10 @@ public let benchmarks = [
|
|||||||
name: "CxxVectorOfU32.Sum.Swift.RawIteratorLoop",
|
name: "CxxVectorOfU32.Sum.Swift.RawIteratorLoop",
|
||||||
runFunction: run_CxxVectorOfU32_Sum_Swift_RawIteratorLoop,
|
runFunction: run_CxxVectorOfU32_Sum_Swift_RawIteratorLoop,
|
||||||
tags: [.validation, .bridging, .cxxInterop]),
|
tags: [.validation, .bridging, .cxxInterop]),
|
||||||
|
BenchmarkInfo(
|
||||||
|
name: "CxxVectorOfU32.Sum.Swift.RawIteratorLoop.WithCxxInlineHelpers",
|
||||||
|
runFunction: run_CxxVectorOfU32_Sum_Swift_RawIteratorLoop_WithCxxInlineHelpers,
|
||||||
|
tags: [.validation, .bridging, .cxxInterop]),
|
||||||
BenchmarkInfo(
|
BenchmarkInfo(
|
||||||
name: "CxxVectorOfU32.Sum.Swift.IndexAndSubscriptLoop",
|
name: "CxxVectorOfU32.Sum.Swift.IndexAndSubscriptLoop",
|
||||||
runFunction: run_CxxVectorOfU32_Sum_Swift_IndexAndSubscriptLoop,
|
runFunction: run_CxxVectorOfU32_Sum_Swift_IndexAndSubscriptLoop,
|
||||||
@@ -68,7 +72,7 @@ public func run_CxxVectorOfU32_Sum_Swift_ForInLoop(_ n: Int) {
|
|||||||
// This function should have comparable performance to
|
// This function should have comparable performance to
|
||||||
// `run_CxxVectorOfU32_Sum_Cxx_RangedForLoop`.
|
// `run_CxxVectorOfU32_Sum_Cxx_RangedForLoop`.
|
||||||
@inline(never)
|
@inline(never)
|
||||||
public func run_CxxVectorOfU32_Sum_Swift_RawIteratorLoop(_ n: Int) {
|
public func run_CxxVectorOfU32_Sum_Swift_RawIteratorLoop_WithCxxInlineHelpers(_ n: Int) {
|
||||||
let vectorOfU32 = makeVector32(vectorSize)
|
let vectorOfU32 = makeVector32(vectorSize)
|
||||||
var sum: UInt32 = 0
|
var sum: UInt32 = 0
|
||||||
for _ in 0..<(n * iterRepeatFactor) {
|
for _ in 0..<(n * iterRepeatFactor) {
|
||||||
@@ -82,6 +86,23 @@ public func run_CxxVectorOfU32_Sum_Swift_RawIteratorLoop(_ n: Int) {
|
|||||||
blackHole(sum)
|
blackHole(sum)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function should have comparable performance to
|
||||||
|
// `run_CxxVectorOfU32_Sum_Cxx_RangedForLoop`.
|
||||||
|
@inline(never)
|
||||||
|
public func run_CxxVectorOfU32_Sum_Swift_RawIteratorLoop(_ n: Int) {
|
||||||
|
let vectorOfU32 = makeVector32(vectorSize)
|
||||||
|
var sum: UInt32 = 0
|
||||||
|
for _ in 0..<(n * iterRepeatFactor) {
|
||||||
|
var b = vectorOfU32.__beginUnsafe()
|
||||||
|
let e = vectorOfU32.__endUnsafe()
|
||||||
|
while b != e {
|
||||||
|
sum = sum &+ b.pointee
|
||||||
|
b = b.successor()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
blackHole(sum)
|
||||||
|
}
|
||||||
|
|
||||||
@inline(never)
|
@inline(never)
|
||||||
public func run_CxxVectorOfU32_Sum_Swift_IndexAndSubscriptLoop(_ n: Int) {
|
public func run_CxxVectorOfU32_Sum_Swift_IndexAndSubscriptLoop(_ n: Int) {
|
||||||
let vectorOfU32 = makeVector32(vectorSize)
|
let vectorOfU32 = makeVector32(vectorSize)
|
||||||
|
|||||||
Reference in New Issue
Block a user