mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[benchmark] PopFront Legacy Factor
This commit is contained in:
@@ -13,19 +13,23 @@
|
||||
import TestsUtils
|
||||
|
||||
public let PopFront = [
|
||||
BenchmarkInfo(name: "PopFrontArray", runFunction: run_PopFrontArray, tags: [.validation, .api, .Array]),
|
||||
BenchmarkInfo(name: "PopFrontUnsafePointer", runFunction: run_PopFrontUnsafePointer, tags: [.validation, .api]),
|
||||
BenchmarkInfo(name: "PopFrontArray",
|
||||
runFunction: run_PopFrontArray,
|
||||
tags: [.validation, .api, .Array],
|
||||
legacyFactor: 20),
|
||||
BenchmarkInfo(name: "PopFrontUnsafePointer",
|
||||
runFunction: run_PopFrontUnsafePointer,
|
||||
tags: [.validation, .api],
|
||||
legacyFactor: 100),
|
||||
]
|
||||
|
||||
let reps = 1
|
||||
let arrayCount = 1024
|
||||
|
||||
@inline(never)
|
||||
public func run_PopFrontArray(_ N: Int) {
|
||||
let orig = Array(repeating: 1, count: arrayCount)
|
||||
var a = [Int]()
|
||||
for _ in 1...20*N {
|
||||
for _ in 1...reps {
|
||||
for _ in 1...N {
|
||||
var result = 0
|
||||
a.append(contentsOf: orig)
|
||||
while a.count != 0 {
|
||||
@@ -33,7 +37,6 @@ public func run_PopFrontArray(_ N: Int) {
|
||||
a.remove(at: 0)
|
||||
}
|
||||
CheckResults(result == arrayCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +44,7 @@ public func run_PopFrontArray(_ N: Int) {
|
||||
public func run_PopFrontUnsafePointer(_ N: Int) {
|
||||
var orig = Array(repeating: 1, count: arrayCount)
|
||||
let a = UnsafeMutablePointer<Int>.allocate(capacity: arrayCount)
|
||||
for _ in 1...100*N {
|
||||
for _ in 1...reps {
|
||||
for _ in 1...N {
|
||||
for i in 0..<arrayCount {
|
||||
a[i] = orig[i]
|
||||
}
|
||||
@@ -54,8 +56,6 @@ public func run_PopFrontUnsafePointer(_ N: Int) {
|
||||
count -= 1
|
||||
}
|
||||
CheckResults(result == arrayCount)
|
||||
}
|
||||
}
|
||||
a.deallocate()
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ import TestsUtils
|
||||
public let PopFrontArrayGeneric = BenchmarkInfo(
|
||||
name: "PopFrontArrayGeneric",
|
||||
runFunction: run_PopFrontArrayGeneric,
|
||||
tags: [.validation, .api, .Array])
|
||||
tags: [.validation, .api, .Array],
|
||||
legacyFactor: 20)
|
||||
|
||||
let reps = 1
|
||||
let arrayCount = 1024
|
||||
|
||||
// This test case exposes rdar://17440222 which caused rdar://17974483 (popFront
|
||||
@@ -50,8 +50,7 @@ func myArrayReplace<
|
||||
public func run_PopFrontArrayGeneric(_ N: Int) {
|
||||
let orig = Array(repeating: 1, count: arrayCount)
|
||||
var a = [Int]()
|
||||
for _ in 1...20*N {
|
||||
for _ in 1...reps {
|
||||
for _ in 1...N {
|
||||
var result = 0
|
||||
a.append(contentsOf: orig)
|
||||
while a.count != 0 {
|
||||
@@ -59,6 +58,5 @@ public func run_PopFrontArrayGeneric(_ N: Int) {
|
||||
myArrayReplace(&a, 0..<1, EmptyCollection())
|
||||
}
|
||||
CheckResults(result == arrayCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user