feat(menubar): 拆分紧凑双页面板并按页采样

This commit is contained in:
2026-11-08 10:42:55 +08:00
parent ac8b4a7e6a
commit 41dcc497b5
36 changed files with 465 additions and 288 deletions
+3
View File
@@ -26,6 +26,7 @@ import Observation
preferences.panelMilliseconds = 500
preferences.backgroundMilliseconds = 1_800_000
let store = MetricsStore(sampling: preferences)
store.setDetailDemand(processes: true, slowMetrics: false)
store.setPanelVisible(true)
try await until { store.processSnapshot != nil }
precondition(store.effectiveMilliseconds == 500)
@@ -74,6 +75,7 @@ import Observation
changing.panelMilliseconds = 500
changing.backgroundMilliseconds = 1_800_000
let changingStore = MetricsStore(sampling: changing, sampler: SystemSampler(processRead: { slowRead.read(&$0) }))
changingStore.setDetailDemand(processes: true, slowMetrics: false)
changingStore.setPanelVisible(true)
try await until { !changingStore.history.samples.isEmpty }
precondition(changingStore.processSnapshot == nil)
@@ -92,6 +94,7 @@ import Observation
try await Task.sleep(for: .milliseconds(650))
precondition(dormant.history.samples.isEmpty && dormant.snapshot.memory == nil,
"Hidden without a consumer must not perform even an initial full sample")
dormant.setDetailDemand(processes: true, slowMetrics: false)
dormant.setPanelVisible(true)
try await until { dormant.processSnapshot != nil }
dormant.setPanelVisible(false)