feat(menubar): 拆分紧凑双页面板并按页采样
This commit is contained in:
@@ -39,6 +39,22 @@ import Foundation
|
||||
precondition(unsupported.state == .unsupported && unsupported.rows.isEmpty)
|
||||
let unverified = monitor.update(processes: processes, readings: [reading(0, at: 25)], capability: .unverified)
|
||||
precondition(unverified.rows.isEmpty && unverified.readable == 0)
|
||||
// Keep more than three measured processes and join by full identity, never PID alone.
|
||||
let manyRows = (0..<12).map { row(ProcessIdentity(pid: Int32(100 + $0), seconds: 1, microseconds: 0), 0) }
|
||||
let many = ProcessSnapshot(date: Date(), enumerated: 12, readable: 12, rows: manyRows, failed: false)
|
||||
_ = monitor.update(processes: many, readings: manyRows.map { reading(0, at: 10, id: $0.id) }, capability: .verifiedCPU)
|
||||
let all = monitor.update(processes: many, readings: manyRows.enumerated().map {
|
||||
reading(UInt64($0.offset) * 1_000_000_000, at: 15, id: $0.element.id)
|
||||
}, capability: .verifiedCPU)
|
||||
precondition(all.rows.count == 12 && all.measured == 12 && all.state == .available)
|
||||
let joined = many.withEnergy(all)
|
||||
precondition(joined.rows[0].cpuPower == 0 && joined.rows[11].cpuPower == 2.2)
|
||||
precondition(joined.rows[1].formattedPower == "200.0 mW" && joined.rows[11].formattedPower == "2.20 W")
|
||||
var reused = manyRows[0]
|
||||
reused = row(ProcessIdentity(pid: reused.id.pid, seconds: 2, microseconds: 0), 0)
|
||||
let replacement = ProcessSnapshot(date: Date(), enumerated: 1, readable: 1, rows: [reused], failed: false)
|
||||
precondition(replacement.withEnergy(all).rows[0].cpuPower == nil)
|
||||
precondition(joined.withEnergy(nil).rows.allSatisfy { $0.cpuPower == nil && $0.powerWindow == nil })
|
||||
print("PASS: exact large-integer deltas, first/zero/reset/reuse/gap/error/time boundaries, energy-vs-CPU ranking, partial coverage and no CPU fallback")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user