fix(monitors): 修复短暂隐藏重开后的趋势误断层

This commit is contained in:
2026-11-07 14:53:41 +08:00
parent 80706fa52e
commit 050ee30f56
17 changed files with 160 additions and 12 deletions
+15
View File
@@ -49,6 +49,21 @@ import Foundation
extended.network = nil
precondition(extended.downloadRate == nil)
var scheduledHistory = MetricHistory()
scheduledHistory.recordScheduledInterval(30)
extended.network = [NetworkInterfaceMetrics(name: "en0", received: 100, sent: 50, download: 20, upload: 10)]
scheduledHistory.append(extended)
scheduledHistory.recordScheduledInterval(30)
scheduledHistory.recordScheduledInterval(2)
scheduledHistory.recordScheduledInterval(.nan)
scheduledHistory.recordScheduledInterval(-1)
precondition(scheduledHistory.samples.last?.expectedInterval == 30)
precondition(scheduledHistory.interfaces.values.allSatisfy { $0.last?.expectedInterval == 30 })
scheduledHistory.append(extended)
precondition(scheduledHistory.samples.map(\.expectedInterval) == [30, 2])
precondition(scheduledHistory.interfaces.values.allSatisfy { $0.map(\.expectedInterval) == [30, 2] },
"Every interface must preserve only the outgoing slow interval, then resume its normal cadence")
var history = MetricHistory()
for index in 0..<100 {
var item = MetricsSnapshot()