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) == [9, 9]) precondition(CPUCoreGridLayout.rowCounts(count: 32, width: 430) == [16, 16]) precondition(CPUCoreGridLayout.rowCounts(count: 48, width: 430) == [16, 16, 16]) for count in [0, 1, 4, 8, 14, 18, 24, 32, 48, 128] { let kinds = Dictionary(uniqueKeysWithValues: (0..= 0 && $0.isFinite }) precondition(widths.reduce(0, +) <= width + 0.001) for (group, groupWidth) in zip(groups, widths) { let rows = CPUCoreGridLayout.rowCounts(count: group.count, width: groupWidth) precondition(rows.count <= 3 && rows.reduce(0, +) == group.count) } } } precondition(CPUCoreGrid.groups(count: 3, kinds: [0: .efficiency]).count == 2) print("PASS: balanced core rows at multiple widths and counts") } }