feat(cpu): 根据核心数量自适应排列进度条
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import SwiftUI
|
||||
|
||||
@main struct CPUCoreGridChecks {
|
||||
static func main() {
|
||||
for count in 0...128 {
|
||||
for width in [120.0, 280.0, 430.0, 800.0] {
|
||||
let rows = CPUCoreGridLayout.rowCounts(count: count, width: width)
|
||||
precondition(rows.reduce(0, +) == count && rows.count <= 3)
|
||||
if let first = rows.first, let last = rows.last {
|
||||
precondition(last > 0 && first - last <= 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
precondition(CPUCoreGridLayout.rowCounts(count: 18, width: 430) == [9, 9])
|
||||
precondition(CPUCoreGridLayout.rowCounts(count: 18, width: 280) == [6, 6, 6])
|
||||
precondition(CPUCoreGridLayout.rowCounts(count: 32, width: 430) == [11, 11, 10])
|
||||
print("PASS: balanced core rows at multiple widths and counts")
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,15 @@
|
||||
# kymoTests
|
||||
|
||||
CPU 核心布局检查(检查不同行宽、0–128 核的行数与均分边界;可视效果另看 `CPUCoreGrid` 的 Xcode 预览):
|
||||
|
||||
```bash
|
||||
swiftc -parse-as-library -module-cache-path /private/tmp/kymo-core-grid-cache \
|
||||
kymo/Features/MenuBar/CPUCoreGrid.swift kymo/Core/Services/CPUCoreTopology.swift \
|
||||
kymo/Core/Extensions/MetricFormat.swift kymo/UI/Components/MetricProgressBar.swift \
|
||||
kymoTests/CPUCoreGridChecks.swift -o /private/tmp/kymo-core-grid-checks
|
||||
/private/tmp/kymo-core-grid-checks
|
||||
```
|
||||
|
||||
单元测试目录。当前工程尚未创建测试 Target,添加步骤见
|
||||
[docs/development.md](../docs/development.md)「添加测试 Target」一节。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user