From 8e413b728b6a08af10f754c5b83534b45d06e984 Mon Sep 17 00:00:00 2001 From: Khan Winter <35942988+thecoolwinter@users.noreply.github.com> Date: Fri, 18 Jul 2025 14:58:01 -0500 Subject: [PATCH] Log Layout Time Less Religiously --- .../TextLayoutManager/TextLayoutManager.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sources/CodeEditTextView/TextLayoutManager/TextLayoutManager.swift b/Sources/CodeEditTextView/TextLayoutManager/TextLayoutManager.swift index 503c334c7..0a8b57ffd 100644 --- a/Sources/CodeEditTextView/TextLayoutManager/TextLayoutManager.swift +++ b/Sources/CodeEditTextView/TextLayoutManager/TextLayoutManager.swift @@ -168,8 +168,13 @@ public class TextLayoutManager: NSObject { let end = mach_absolute_time() let elapsed = end - start let nanos = elapsed * UInt64(info.numer) / UInt64(info.denom) - let msec = TimeInterval(nanos) / TimeInterval(NSEC_PER_MSEC) - logger.info("TextLayoutManager built in: \(msec, privacy: .public)ms") + let sec = TimeInterval(nanos) / TimeInterval(NSEC_PER_SEC) + // This used to be logged every time. However we're now confident enough in the performance of this method + // that it's not useful to log it anymore unless it's an odd number. Taking ~500ms for a >500k loc file + // is normal. More than 1s for any document is not normal. + if sec >= 1 { + logger.warning("TextLayoutManager built in: \(sec, privacy: .public)s") + } #endif }