perf(Charts): 10 performance improvements in Chart control#400
Open
PaulAndersonS wants to merge 1 commit into
Open
perf(Charts): 10 performance improvements in Chart control#400PaulAndersonS wants to merge 1 commit into
PaulAndersonS wants to merge 1 commit into
Conversation
1. CategoryAxis: Ensure uniqueness during insertion, eliminating redundant
Distinct().ToList() allocation and extra enumeration.
2. PolarAreaSegment: Replace multiple LINQ .Min()/.Max()/.Where() calls with
a single-pass loop for computing range bounds.
3. StackingAreaSegment: Replace LINQ .Where().Min() and separate .Min()/.Max()
calls with single-pass loop for range computation.
4. ChartTrackballBehavior: Use list swap pattern for PreviousPointInfos to
avoid Clear()+AddRange() copy on every pointer move.
5. ChartTrackballBehavior: Reuse _previousAxisPointInfos list with Clear()
instead of re-allocating on each trackball generation.
6. PolarSeries: Replace LINQ 'from..select..ToList()' with pre-allocated
List and simple for loop to avoid delegate and iterator allocations.
7. CartesianSeries: Replace .Where().ToList() with direct foreach loop in
UpdateSbsSeries() to eliminate intermediate list allocation.
8. CartesianChartArea: Pre-allocate List<double> with known capacity in
stacking calculation loop to avoid internal array resizes.
9. ChartAxis: Replace LINQ .Where() with direct foreach loop and early
return in GetCrossingAxis() to avoid delegate allocation.
10. ChartUtils: Add fast-path type checks in ConvertToDouble() to avoid
ToString() allocation for common numeric types (double, int, float,
long, DateTime). Pre-allocate List capacity in GetMidAngles().
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.
Summary
This PR consolidates 10 performance improvements to the Chart control, reducing allocations and eliminating hot-path inefficiencies.
Changes
Distinct().ToList()by ensuring uniqueness during insertion.Min()/.Max()/.Where()with single-pass loop.Where().Min()with single-pass loopfrom..select..ToList()with for loop.Where().ToList()with direct foreach.Where()with direct loop + early returnTesting