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