refactor(project): 清理闲置展示链路与重复采样状态

This commit is contained in:
2026-11-09 00:41:09 +08:00
parent 7b3abe37c5
commit b73d51c953
57 changed files with 210 additions and 2822 deletions
+1 -13
View File
@@ -6,9 +6,6 @@ nonisolated struct GPUMetrics: Sendable {
let coreCount: Int?
var renderer: Double? = nil
var tiler: Double? = nil
// Driver accounting, not dedicated VRAM or a capacity denominator.
var inUseMemory: UInt64? = nil
var allocatedMemory: UInt64? = nil
// Independent per-core counters have not been obtained. Never split total usage.
}
@@ -27,21 +24,12 @@ nonisolated enum GPUMonitor {
let cores = (IORegistryEntryCreateCFProperty(service, "gpu-core-count" as CFString, kCFAllocatorDefault, 0)?.takeRetainedValue() as? NSNumber)?.intValue
devices.append(GPUMetrics(usage: normalized(raw), coreCount: cores.flatMap { $0 > 0 ? $0 : nil },
renderer: normalized((stats?["Renderer Utilization %"] as? NSNumber)?.doubleValue),
tiler: normalized((stats?["Tiler Utilization %"] as? NSNumber)?.doubleValue),
inUseMemory: memoryBytes(stats?["In use system memory"]),
allocatedMemory: memoryBytes(stats?["Alloc system memory"])))
tiler: normalized((stats?["Tiler Utilization %"] as? NSNumber)?.doubleValue)))
}
// Do not average incompatible utilization counters on multi-GPU machines.
return devices.count == 1 ? devices[0] : nil
}
static func memoryBytes(_ raw: Any?) -> UInt64? {
guard let number = raw as? NSNumber else { return nil }
let value = number.doubleValue
guard value.isFinite, value >= 0, value < Double(UInt64.max) else { return nil }
return UInt64(value)
}
static func normalized(_ value: Double?) -> Double? {
value.flatMap { $0.isFinite && (0...100).contains($0) ? $0 / 100 : nil }
}