补充 GPU 渲染分块、内存与利用率统计,增加只读 SMC 温度及风扇信息和旋转动效。完善电池功率与耗电进程列表,统一首排布局并固定异步加载区域高度。同步验证用例、架构说明和 GPU 能力调研工具。
30 lines
1.0 KiB
Swift
30 lines
1.0 KiB
Swift
import Foundation
|
|
|
|
nonisolated enum MetricFormat {
|
|
static func percent(_ value: Double?) -> String {
|
|
guard let value, value.isFinite else { return "--" }
|
|
return "\(Int((min(1, max(0, value)) * 100).rounded()))%"
|
|
}
|
|
|
|
static func bytes(_ value: UInt64?) -> String {
|
|
guard let value else { return "--" }
|
|
return String(format: "%.1f GB", Double(value) / 1_000_000_000)
|
|
}
|
|
|
|
static func rate(_ value: Double?) -> String {
|
|
guard let value, value.isFinite, value >= 0 else { return "--" }
|
|
let units = ["B/s", "KB/s", "MB/s", "GB/s", "TB/s"]
|
|
var scaled = value
|
|
var index = 0
|
|
while scaled >= 1000 && index < units.count - 1 { scaled /= 1000; index += 1 }
|
|
return String(format: "%.1f %@", scaled, units[index])
|
|
}
|
|
|
|
static func watts(_ value: Double?) -> String {
|
|
guard let value, value.isFinite, value >= 0 else { return "--" }
|
|
return String(format: "%.1f W", value)
|
|
}
|
|
|
|
static func decimal(_ value: Double) -> String { String(format: "%.1f", value) }
|
|
}
|