Skip to content

Commit 8e413b7

Browse files
committed
Log Layout Time Less Religiously
1 parent f576370 commit 8e413b7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Sources/CodeEditTextView/TextLayoutManager/TextLayoutManager.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,13 @@ public class TextLayoutManager: NSObject {
168168
let end = mach_absolute_time()
169169
let elapsed = end - start
170170
let nanos = elapsed * UInt64(info.numer) / UInt64(info.denom)
171-
let msec = TimeInterval(nanos) / TimeInterval(NSEC_PER_MSEC)
172-
logger.info("TextLayoutManager built in: \(msec, privacy: .public)ms")
171+
let sec = TimeInterval(nanos) / TimeInterval(NSEC_PER_SEC)
172+
// This used to be logged every time. However we're now confident enough in the performance of this method
173+
// that it's not useful to log it anymore unless it's an odd number. Taking ~500ms for a >500k loc file
174+
// is normal. More than 1s for any document is not normal.
175+
if sec >= 1 {
176+
logger.warning("TextLayoutManager built in: \(sec, privacy: .public)s")
177+
}
173178
#endif
174179
}
175180

0 commit comments

Comments
 (0)