| index 5bc6112..058db91 100644 |
| --- a/native/benchmarks/realtime/ui-probe/Sources/UIProbe.swift |
| +++ b/native/benchmarks/realtime/ui-probe/Sources/UIProbe.swift |
| @@ -52,7 +52,10 @@ func counters(_ label: String, per count: Int) { |
| Double(DocsProbes.viewUpdates) / n, Double(DocsProbes.hostBodies) / n)) |
| } |
| |
| -@MainActor private enum Run { static var started = false } |
| +@MainActor private enum Run { |
| + static var started = false |
| + static var opened = ContinuousClock.now |
| +} |
| |
| @main struct RealtimeUIProbe: App { |
| var body: some Scene { |
| @@ -72,12 +75,13 @@ private struct Launcher: View { |
| Run.started = true |
| NSApp.setActivationPolicy(.regular) |
| openWindow(id: "document", value: connection.sqid) |
| - for _ in 0..<600 { |
| + Run.opened = .now |
| + for _ in 0..<6000 { |
| if let window = NSApp.windows.first(where: { $0.title == "Realtime audit" }), let editor = window.contentView.flatMap(findEditor), !editor.string.isEmpty { |
| await exercise(window, editor) |
| return |
| } |
| - try? await Task.sleep(for: .milliseconds(100)) |
| + try? await Task.sleep(for: .milliseconds(10)) |
| } |
| print("RTUI FAILED: document did not load") |
| exit(2) |
| @@ -91,15 +95,25 @@ private struct Launcher: View { |
| let env = ProcessInfo.processInfo.environment |
| let keys = Int(env["DOCS_RT_AUDIT_KEYS"] ?? "40") ?? 40 |
| let cadence = Double(env["DOCS_RT_AUDIT_CADENCE_MS"] ?? "125") ?? 125 |
| + // DOCS_RT_AUDIT_AT_OPEN=1: type at the start of the document as soon |
| + // as it shows, while the rest is still being measured (S1b). |
| + let atOpen = env["DOCS_RT_AUDIT_AT_OPEN"] == "1" |
| + let shown = Run.opened.duration(to: .now) |
| NSApp.activate(ignoringOtherApps: true) |
| window.makeKeyAndOrderFront(nil); window.makeFirstResponder(editor) |
| - try? await Task.sleep(for: .seconds(2)) |
| + if atOpen { |
| + print("RTUI open: document shown \(shown) after the window was asked for; measuring \(DocsProbes.measuring ? "still going" : "done")") |
| + Task { @MainActor in |
| + while DocsProbes.measuring { try? await Task.sleep(for: .milliseconds(2)) } |
| + print("RTUI open: measuring done \(Run.opened.duration(to: .now)) after the window was asked for") |
| + } |
| + } else { try? await Task.sleep(for: .seconds(2)) } |
| let ns = editor.string as NSString |
| - var at = ns.length / 3 |
| + var at = atOpen || env["DOCS_RT_AUDIT_AT"] == "top" ? ns.range(of: "\n").location : ns.length / 3 |
| while at < ns.length, ns.character(at: at) == 10 { at += 1 } |
| editor.setSelectedRange(NSRange(location: at, length: 0)) |
| editor.scrollRangeToVisible(editor.selectedRange()) |
| - try? await Task.sleep(for: .seconds(1)) |
| + if !atOpen { try? await Task.sleep(for: .seconds(1)) } |
| |
| // A. Typing. |
| DocsProbes.reset() |
| @@ -145,6 +159,7 @@ private struct Launcher: View { |
| lines.max() ?? 0, lines.sorted()[lines.count / 2], measureLines.max() ?? 0, measureLines.sorted()[measureLines.count / 2], |
| paginationSorted[paginationSorted.count / 2], paginationSorted.last ?? 0)) |
| print("RTUI typing per key line requests: \(lines.map(String.init).joined(separator: " "))") |
| + print("RTUI typing per key keyDown ms: \(keyDown.map { String(format: "%.1f", $0) }.joined(separator: " "))") |
| let displaySorted = display.sorted(), otherSorted = displayOther.sorted() |
| print(String(format: "RTUI typing display pass after the key: median %.2f ms p95 %.2f ms; not the text view's own layout and drawing: median %.2f ms p95 %.2f ms", |
| displaySorted[displaySorted.count / 2], displaySorted[min(displaySorted.count - 1, Int(Double(displaySorted.count) * 0.95))], |