fix(processes): 对齐活动监视器内存口径与显示单位
This commit is contained in:
@@ -4,7 +4,7 @@ import Foundation
|
||||
static func main() {
|
||||
let id = ProcessIdentity(pid: 42, seconds: 100, microseconds: 0)
|
||||
let row = ProcessMetrics(id: id, name: "worker", path: "/test/worker", cpu: 0.2,
|
||||
residentBytes: 10, threads: 1, restricted: false)
|
||||
footprintBytes: 10, threads: 1, restricted: false)
|
||||
let live = ProcessSnapshot(date: Date(), enumerated: 1, readable: 1, rows: [row], failed: false)
|
||||
let filtered = ProcessTableProjection.rows(live.rows, query: "does-not-match", sorting: [], order: [])
|
||||
precondition(filtered.isEmpty)
|
||||
@@ -17,10 +17,17 @@ import Foundation
|
||||
precondition(ProcessTableProjection.exitedSelection(id, in: exited) == id)
|
||||
let reused = ProcessIdentity(pid: 42, seconds: 101, microseconds: 0)
|
||||
let replacement = ProcessMetrics(id: reused, name: row.name, path: row.path, cpu: nil,
|
||||
residentBytes: nil, threads: nil, restricted: true)
|
||||
footprintBytes: nil, threads: nil, restricted: true)
|
||||
let recycled = ProcessSnapshot(date: Date(), enumerated: 1, readable: 0, rows: [replacement], failed: false)
|
||||
precondition(ProcessTableProjection.exitedSelection(id, in: recycled) == id, "PID reuse cannot keep the previous process alive")
|
||||
precondition(ProcessTableProjection.exitedSelection(reused, in: recycled) == nil)
|
||||
let large = ProcessMetrics(id: ProcessIdentity(pid: 43, seconds: 1, microseconds: 0), name: "large", path: nil,
|
||||
cpu: nil, footprintBytes: 1_000, threads: nil, restricted: false)
|
||||
for direction in [SortOrder.forward, .reverse] {
|
||||
let sorted = ProcessTableProjection.rows([replacement, row, large], query: "", sorting: [ProcessSort(key: .memory, order: direction)], order: [])
|
||||
precondition(sorted.last?.id == replacement.id, "Missing footprint sorts last in both directions")
|
||||
precondition(sorted.first?.id == (direction == .forward ? row.id : large.id))
|
||||
}
|
||||
print("PASS: filtered/live selection, absent selection/snapshot, failed enumeration, actual exit and PID reuse")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user