// The page walk (lane threadload, 16 Oct 2026): launched with// `-page-walk /messages/<id>,/people/person/<id>,…` the app opens each route// in turn, back to Home between, `-page-walk-rounds` times (default 5), so// `PageClock` logs each open from the push — the timing a tap gives, with no// system "Open in…?" between, which a deep link from outside raises.// `scripts/perf/pages.py run` launches it on a simulator over a synthetic// household and reads the clock's lines.importCottonKitimportFoundationimport OSLog@MainActorenumPageWalk {privatestaticvar arguments: [String] { ProcessInfo.processInfo.arguments }privatestaticlet log = Logger(subsystem: "com.cottondb.page", category: "open")/// The routes asked for, or none.staticvar routes: [Route] {guardlet at = arguments.firstIndex(of: "-page-walk"), at + 1 < arguments.count else { return [] }return arguments[at + 1].split(separator: ",").compactMap { Route.parse(String($0)) } }staticvar rounds: Int {guardlet at = arguments.firstIndex(of: "-page-walk-rounds"), at + 1 < arguments.count else { return5 }returnInt(arguments[at + 1]) ?? 5 }/// Opens each route, `rounds` times, from Home; logs `walk: done` at the end.staticfunc run(_ navigator: Navigator, settle: Duration = .seconds(3)) async {let routes = routesguard !routes.isEmpty else { return }try? awaitTask.sleep(for: .seconds(8)) // the first Home, arrangedfor _ in0..<rounds {for route in routes {let pushed = ContinuousClock.now navigator.push(route)try? awaitTask.sleep(for: settle) calls(since: pushed) navigator.popToRoot()try? awaitTask.sleep(for: .milliseconds(1500)) } } log.notice("walk: done") }/// Every core call the open made, from the push: when it started and how/// long it took (a development build's `DevReads`).privatestaticfunc calls(since pushed: ContinuousClock.Instant) { #if COTTON_DEVfor call inDevReads.since(pushed) {let offset = call.started - pushedlet at = Double(offset.components.seconds) * 1000 + Double(offset.components.attoseconds) / 1e15 log.notice("call: \(call.method, privacy: .public) at \(Int(at)) ms took \(Int(call.millis.rounded())) ms") } #endif }}