Fix TextDiff layout parity and add performance baselines#4
Merged
iSapozhnik merged 8 commits intomainfrom Feb 23, 2026
Merged
Conversation
Enhance `measuredTextSize` to include a `linePrefix` parameter, improving text measurement accuracy, especially for wrapping cases. Introduce `measuredIncrementalWidth` to calculate text width incrementally. These changes ensure that text layout calculations account for prefix widths, making soft-wrap decisions more precise. This update addresses inconsistencies in text dimension calculations when different font attributes are applied.
Add baseline Performance tests for `TextDiffTests` to measure the layout performance for different word counts. This helps in tracking performance regressions over time. The baselines are configured for 1000, 500, and 200 words tests and are set for a local Apple M1 environment to standardize performance metrics.
Replace `measuredTextSize` with `measuredIncrementalTextWidth` to improve performance by calculating text width incrementally using an `NSMutableString`. This reduces redundant calculations and enhances efficiency in handling large text segments, particularly when soft-wrapping text. Additionally, store widths for reuse and keep track of combined line width to minimize repeated layout operations, resulting in smoother and faster text rendering.
Increase text size from 16 to 32 in the "Height diff" preview to enhance readability. Change "!" to "." for consistent punctuation in the "Punctuation Replacement" preview. These changes improve the design aesthetics and maintain consistency in visual presentations.
Add `DiffLayouterPerformanceTests.swift` to test text layout performance with varying word counts. Convert existing snapshot tests to use XCTest, enhancing compatibility and extendability. Introduce snapshot artifacts directory configuration to manage artifacts. Update tests to specify the snapshot test name explicitly. Modify `verticalInsetIsNonNegativeAndMonotonic` test to ensure non-negativity and check monotonicity of vertical insets, improving test rigor.
Owner
Author
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca10965e37
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
XCTestCaseand configure snapshot artifact outputXCTestperformance benchmarks for 200/500/1000-word layout casesNotes
.snapshot-artifacts/(gitignored)