perf: Chart control performance improvements#399
Open
PaulAndersonS wants to merge 1 commit into
Open
Conversation
… caching - Replace .Reverse() with reverse index loop in tooltip hit-testing - Remove unnecessary .Where().ToList() allocations - Replace .Cast<>() LINQ wrappers with pattern matching loops - Cache repeated string IndexOf calls - Replace string concatenation with interpolation - Cache .Count in loop conditions - Cache complex property path checks Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Root Cause of the Issue
The Chart control source code uses several LINQ patterns (.Reverse(), .Cast<>(), .Where().ToList()) and repeated string operations that cause unnecessary heap allocations and repeated work on every frame/update cycle.
Description of Change
This PR implements 10 targeted performance improvements in the Chart control source code:
.Reverse()with reverse index loop inChartBase.cs— avoids allocating a reversed collection during tooltip hit-testing.Where().ToList()allocation inCartesianSeries.cs— replaces filtered list with direct iteration.Cast<CartesianSeries>()with pattern matching inChartAxis.cs— eliminates LINQ enumerator overheadChartSeriesPartial.cs— avoids scanning the same string multiple timesChartSeries.cs— minor allocation improvement.Cast<CartesianSeries>()in group update inChartSeriesPartial.cs— pattern matching loop.Countin loop conditions inCartesianAxisRenderer.cs— avoids repeated property accessChartSeriesPartial.cs— introduces_isComplexXPropertyfield to avoid repeatedString.Containscalls.Cast<>()usages inCartesianSeries.cslegend item loops — pattern matching with indexed accessIssues Fixed
N/A — Performance improvement
Screenshots
N/A — No visual changes