feat(memory): 重设计内存卡片并统一二进制容量单位

This commit is contained in:
2026-11-03 16:51:14 +08:00
parent cc38066de2
commit 90ed18e6ac
11 changed files with 186 additions and 17 deletions
+11
View File
@@ -0,0 +1,11 @@
import Foundation
@main struct Check {
static func main() {
precondition(MetricFormat.memory(51_539_607_552) == "48.0 GiB")
precondition(MetricFormat.memory(0) == "0 B")
precondition(MetricFormat.memory(nil) == "--")
guard let m = MemoryMonitor.sample() else { fatalError("No sample") }
precondition(m.app + m.wired + m.compressed + m.available == m.total)
print("Memory checks passed: total=\(MetricFormat.memory(m.total)), used=\(MetricFormat.memory(m.used)), cached=\(MetricFormat.memory(m.cached)), pressure=\(String(describing: m.pressure))")
}
}