perf(efficiency): 落实首批采样减负与发行包瘦身
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import AppKit
|
||||
|
||||
/// Explicit local measurement only. Never schedules work during normal launches.
|
||||
@MainActor enum PanelResourceAudit {
|
||||
static let enabled = ProcessInfo.processInfo.environment["KYMO_RESOURCE_AUDIT"] == "1"
|
||||
static let omitted = enabled ? ProcessInfo.processInfo.environment["KYMO_AUDIT_OMIT"] ?? "" : ""
|
||||
|
||||
static func run(controller: MenuPanelController, metrics: MetricsStore) {
|
||||
guard enabled else { return }
|
||||
Task { @MainActor in
|
||||
@MainActor func mark(_ event: String) { SamplingDiagnostics.record(metrics.snapshot, event: "audit." + event) }
|
||||
func wait(_ seconds: Int) async { try? await Task.sleep(for: .seconds(seconds)) }
|
||||
// Pin the test window so unrelated focus changes cannot invalidate a measurement.
|
||||
controller.presentation.isPinned = true
|
||||
mark("cold")
|
||||
await wait(10)
|
||||
mark("hidden10")
|
||||
for cycle in 1...3 {
|
||||
controller.show()
|
||||
mark("open\(cycle).0")
|
||||
await wait(1); mark("open\(cycle).1")
|
||||
await wait(9); mark("open\(cycle).10")
|
||||
await wait(20); mark("open\(cycle).30")
|
||||
if cycle == 1 {
|
||||
metrics.togglePause(); mark("paused.0")
|
||||
await wait(10); mark("paused.10")
|
||||
metrics.togglePause(); mark("resumed")
|
||||
}
|
||||
controller.hide()
|
||||
await wait(1); mark("closed\(cycle).1")
|
||||
await wait(9); mark("closed\(cycle).10")
|
||||
await wait(20); mark("closed\(cycle).30")
|
||||
}
|
||||
controller.shutdown()
|
||||
mark("complete")
|
||||
NSApp.terminate(nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user