← All repositories

crossmate

A collaborative crossword app for iPhone and iPad

git clone https://code.inqk.net/crossmate.git


commit 20ddc83686f6d7df296395263787f470652680bc
parent 5f2b38ccd525a3400a329ec1a29df68634c706c8
Author: Michael Camilleri <[email protected]>
Date:   Sat,  2 May 2026 08:14:36 +0900

Add more detail to performance logging

Diffstat

MCrossmate/Models/PlayerSession.swift | 25++++++++++++++++++++++---
MCrossmate/Services/DebuggingMonitors.swift | 9++++++++-

2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/Crossmate/Models/PlayerSession.swift b/Crossmate/Models/PlayerSession.swift

@@ -232,7 +232,11 @@ final class PlayerSession {
         if completionState != .solved {
             advance()
         }
-        recordInputDuration("input.enter", start: start, detail: "letter=\(letter)")
+        recordInputDuration(
+            "input.enter",
+            start: start,
+            detail: inputDetail(row: inputRow, col: inputCol, extra: "letter=\(letter)")
+        )
     }
 
     func deleteBackward() {
@@ -256,7 +260,11 @@ final class PlayerSession {
             expectedEntry: ""
         )
         mutator.clearLetter(atRow: selectedRow, atCol: selectedCol)
-        recordInputDuration("input.delete", start: start)
+        recordInputDuration(
+            "input.delete",
+            start: start,
+            detail: inputDetail(row: inputRow, col: inputCol)
+        )
     }
 
     // MARK: - Rebus
@@ -298,7 +306,11 @@ final class PlayerSession {
         if completionState != .solved {
             advance()
         }
-        recordInputDuration("input.rebusCommit", start: start, detail: "length=\(value.count)")
+        recordInputDuration(
+            "input.rebusCommit",
+            start: start,
+            detail: inputDetail(row: inputRow, col: inputCol, extra: "length=\(value.count)")
+        )
     }
 
     // MARK: - Word geometry
@@ -390,6 +402,13 @@ final class PlayerSession {
         )
     }
 
+    private func inputDetail(row: Int, col: Int, extra: String = "") -> String {
+        let probePrefix = renderProbeID.flatMap { performanceMonitor?.renderProbeDetailPrefix(for: $0) }
+            ?? "row=\(row) col=\(col)"
+        guard !extra.isEmpty else { return probePrefix }
+        return "\(probePrefix) \(extra)"
+    }
+
     private func advance() {
         let (dr, dc) = step(for: direction)
         let r = selectedRow + dr

diff --git a/Crossmate/Services/DebuggingMonitors.swift b/Crossmate/Services/DebuggingMonitors.swift

@@ -88,6 +88,11 @@ final class PerformanceMonitor {
         return id
     }
 
+    func renderProbeDetailPrefix(for id: Int) -> String? {
+        guard let probe = pendingRenderProbes[id] else { return nil }
+        return "probe=\(id) row=\(probe.position.row) col=\(probe.position.col)"
+    }
+
     func completeRenderProbe(id: Int, position: GridPosition, entry: String) {
         guard let probe = pendingRenderProbes[id],
               probe.position == position,
@@ -97,10 +102,12 @@ final class PerformanceMonitor {
         let duration = probe.startedAt.duration(to: .now)
         let milliseconds = Double(duration.components.seconds) * 1000
             + Double(duration.components.attoseconds) / 1_000_000_000_000_000
+        let baseDetail = "probe=\(id) row=\(probe.position.row) col=\(probe.position.col)"
+        let detail = probe.detail.isEmpty ? baseDetail : "\(baseDetail) \(probe.detail)"
         record(
             probe.name,
             durationMS: milliseconds,
-            detail: probe.detail,
+            detail: detail,
             thresholdMS: 6
         )
     }