feat(memory): 增加内存分类历史趋势曲线
This commit is contained in:
@@ -6,6 +6,16 @@ import Foundation
|
||||
precondition(MetricFormat.memory(nil) == "--")
|
||||
guard let m = MemoryMonitor.sample() else { fatalError("No sample") }
|
||||
precondition(m.app + m.wired + m.compressed + m.available == m.total)
|
||||
var snapshot = MetricsSnapshot()
|
||||
snapshot.memory = m
|
||||
var history = MetricHistory()
|
||||
history.append(snapshot)
|
||||
precondition(history.samples.last?.memoryApp == Double(m.app))
|
||||
precondition(history.samples.last?.memoryWired == Double(m.wired))
|
||||
precondition(history.samples.last?.memoryCompressed == Double(m.compressed))
|
||||
snapshot.memory = nil
|
||||
history.append(snapshot)
|
||||
precondition(history.samples.last?.memoryApp == nil)
|
||||
print("Memory checks passed: total=\(MetricFormat.memory(m.total)), used=\(MetricFormat.memory(m.used)), cached=\(MetricFormat.memory(m.cached)), pressure=\(String(describing: m.pressure))")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user