Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Performance improvement and reduction in memory allocation when dealing with Formatted cells#2674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jafin wants to merge4 commits intoClosedXML:develop
base:develop
Choose a base branch
Loading
fromjafin:feat/performance

Conversation

@jafin
Copy link

@jafinjafin commentedMay 3, 2025
edited
Loading

This PR adds a performance benchmarking and some performance gains and reduction in memory dealing with formatted cells (and cell cloning).

Performance Benchmarking and Testing

  • Added benchmark.net test project. With benchmark to validate performance change. Is marked excluded to avoid running with standard test suite.

Code refactoring.

Focused around some hotpaths dealing with formatted cells. As we use the Sister project ClosedXML.Reports and experience performance issues there. (Note: A lot of time for me is seen inFormatCell SetOutsideBorder , maybe there are some future savings there.

The changes primarily aim to reduce memory allocation and tweak performance.
In broad strokes they are:

  • reduce use of ToArray/ToList when not required to avoid allocation and GC perf.
  • changeXLRepositoryBase to take in aWeakReference<Value> and reduce calls viaTryGet,GetEnumerator also now yields.
  • CollectChildrenRecursively(XLStylizedBase parent) should be faster than the HashSet, reduces recursion and uses the Stack

Other

minor style changes - feel free to ignore. (Prefer modern language features, use keyword over type name) etc.

Testing results

Before changes

MethodMeanErrorStdDevGen0Gen1Gen2Allocated
CellFillAndCopy53.68 ms1.067 ms1.783 ms2222.2222888.8889222.222232.74 MB

image

After changes

MethodMeanErrorStdDevGen0Gen1Allocated
CellFillAndCopy46.76 ms0.931 ms1.393 ms1727.2727818.181828.53 MB

image

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@jafin

[8]ページ先頭

©2009-2025 Movatter.jp