From e4818c4cd776601c40b80a2024d4dee4248042ba Mon Sep 17 00:00:00 2001 From: Feror Date: Sat, 30 May 2026 17:59:41 +0200 Subject: [PATCH] perf(editor): align benchmark with render skipping --- .../EditorPerformanceProfiling.swift | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Sources/SaplingEditor/EditorPerformanceProfiling.swift b/Sources/SaplingEditor/EditorPerformanceProfiling.swift index 138e199..cdf2bf4 100644 --- a/Sources/SaplingEditor/EditorPerformanceProfiling.swift +++ b/Sources/SaplingEditor/EditorPerformanceProfiling.swift @@ -437,22 +437,27 @@ public enum EditorBenchmarkProfiler { )) let clickRenderResult = measure { - MarkdownTextStyler.apply( - to: textStorage, - invalidationPlan: dirtyClickPlan, - activeLineIndex: changedActiveLineIndex, - backgroundColor: .textBackgroundColor, - activeLineBackgroundColor: .controlAccentColor.withAlphaComponent(0.10), - textColor: .labelColor, - secondaryTextColor: .secondaryLabelColor, - accentColor: .controlAccentColor - ) + if dirtyClickPlan.requiresStyling { + return MarkdownTextStyler.apply( + to: textStorage, + invalidationPlan: dirtyClickPlan, + activeLineIndex: changedActiveLineIndex, + backgroundColor: .textBackgroundColor, + activeLineBackgroundColor: .controlAccentColor.withAlphaComponent(0.10), + textColor: .labelColor, + secondaryTextColor: .secondaryLabelColor, + accentColor: .controlAccentColor + ) + } + return MarkdownTextStylingResult.empty } measurements.append(EditorBenchmarkMeasurement( name: "render_update_click_dirty", category: .interaction, durationMilliseconds: clickRenderResult.durationMilliseconds, - notes: "\(clickRenderResult.value.styledLineCount) styled lines" + notes: dirtyClickPlan.requiresStyling + ? "\(clickRenderResult.value.styledLineCount) styled lines" + : "skipped; dirty plan did not require styling" )) let typingStorageResult = measure {