perf(efficiency): 落实首批采样减负与发行包瘦身
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import Foundation
|
||||
|
||||
@main struct SensorScheduleChecks {
|
||||
static func main() {
|
||||
var cpu = SensorSchedule()
|
||||
var gpu = SensorSchedule()
|
||||
precondition(cpu.isDue(at: 0) && gpu.isDue(at: 0))
|
||||
cpu.complete(available: true, at: 0)
|
||||
gpu.complete(available: false, at: 0)
|
||||
precondition(!cpu.isDue(at: 9) && cpu.isDue(at: 10))
|
||||
for now in stride(from: 10.0, through: 60, by: 10) {
|
||||
cpu.complete(available: true, at: now)
|
||||
if now < 60 { precondition(!gpu.isDue(at: now)) }
|
||||
}
|
||||
precondition(gpu.isDue(at: 60))
|
||||
gpu.complete(available: false, at: 60)
|
||||
precondition(!gpu.isDue(at: 179) && gpu.isDue(at: 180))
|
||||
var now = 180.0
|
||||
for delay in [240.0, 480, 600, 600, 600] {
|
||||
gpu.complete(available: false, at: now)
|
||||
precondition(gpu.deadline == now + delay)
|
||||
now += delay
|
||||
}
|
||||
gpu.complete(available: true, at: now)
|
||||
precondition(gpu.deadline == now + 10)
|
||||
gpu.complete(available: false, at: now + 10)
|
||||
precondition(gpu.deadline == now + 70)
|
||||
print("PASS: independent sensor cadences, exponential failure backoff, cap and recovery")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user