#if COTTON_DEV// DevTimings.swift — DEVELOPER TOOL, compiled into Cotton Dev only.//// Which surface is on screen, how long it took to its first rows, and the// core reads it made on the way (`CottonKit/Developer/DevReads.swift`). The// timings overlay draws it (`DevCorner.swift`) and a report names the surface// (`Feedback/ShakeReport.swift`). Surfaces say `begin` when they appear and// `rowsShown` once rows are drawn; nothing else writes here.importCottonKitimportFoundationimportObservationimport os@MainActor@ObservablepublicfinalclassDevTimings {publicstaticlet shared = DevTimings()/// The table definition on screen, by id.publicprivate(set) var surface: String?/// From `begin` to the first rows; nil until they are drawn.publicprivate(set) var firstRowMillis: Double?privatevar opened: ContinuousClock.Instant?/// The overlay is drawn. A habit of this device, kept across launches.publicvar showing: Bool { didSet { UserDefaults.standard.set(showing, forKey: Self.showingKey) } }staticlet showingKey = "dev.timings.showing"init() { showing = UserDefaults.standard.bool(forKey: Self.showingKey) }publicfunc begin(_ surface: String) {self.surface = surface opened = .now firstRowMillis = nil }publicfunc rowsShown(_ surface: String) {guard surface == self.surface, firstRowMillis == nil, let opened else { return }let elapsed = ContinuousClock.now - openedlet millis = Double(elapsed.components.seconds) * 1000 + Double(elapsed.components.attoseconds) / 1e15 firstRowMillis = millis// Read off the device log by a walk that measures a list, so the// number is taken without querying the screen (an accessibility// query is itself main-thread work on every SwiftUI update).Self.log.notice("first rows \(surface, privacy: .public) \(Int(millis.rounded())) ms") }privatestaticlet log = Logger(subsystem: "com.cottondb.dev", category: "timings")/// The reads made since the surface appeared, oldest first.publicfunc reads() -> [DevReads.Call] {guardlet opened else { return [] }returnDevReads.since(opened) }}/// Which synthetic household a reseed founds — `small` (about 2 000 rows) or/// `large` (about 100 000), the generator's own names (ws-m5b-dev2).publicenumDevHouseholdSize: String, CaseIterable, Sendable {case small, largestaticlet key = "dev.household.size"publicstaticvar chosen: DevHouseholdSize { get { UserDefaults.standard.string(forKey: key).flatMap(DevHouseholdSize.init) ?? .small } set { UserDefaults.standard.set(newValue.rawValue, forKey: key) } }publicvar other: DevHouseholdSize { self == .small ? .large : .small }}#endif