Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SA1028 memory optimizations #1160

Merged
merged 2 commits into from Aug 8, 2015
Merged

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented Aug 8, 2015

The primary target of this pull request is memory optimizations for SA1028.

  • Eliminate boxing of SyntaxTriviaList for calls to Contains (affects SA1025 and SA1515).
  • Use SyntaxTree.GetText instead of SyntaxNode.GetText, since the latter creates a new copy of the complete content.

Profiling Results

SA1028

Method: Instrumentation of StyleCopTester and StyleCop.Analyzers
Test arguments: /nostats /id:SA1028 StyleCopAnalyzers.sln

Commit Total Allocations Total Bytes Total Allocations (SA1028) Total Bytes (SA1028)
b242672 555894 28184120 552256 28007808
a084e22 345598 11075044 341964 10898724

SA1025

Method: Instrumentation of StyleCopTester and StyleCop.Analyzers
Test arguments: /nostats /id:SA1025 StyleCopAnalyzers.sln

No measurable gains for this project (affected code is only on code paths which result in a violation).

SA1515

Method: Instrumentation of StyleCopTester and StyleCop.Analyzers
Test arguments: /nostats /id:SA1515 StyleCopAnalyzers.sln

Commit Total Allocations Total Bytes Total Allocations (SA1515) Total Bytes (SA1515)
b242672 304243 8602176 300616 8426052
a084e22 303794 8584764 300158 8408212

SyntaxTree.GetText is efficient, but SyntaxNode.GetText uses a StringBuilder
to make a new copy of the tree contents.
@sharwell sharwell self-assigned this Aug 8, 2015
@sharwell sharwell added this to the 1.0.0 Beta 5 milestone Aug 8, 2015
@Noryoko
Copy link
Contributor

Noryoko commented Aug 8, 2015

👍

1 similar comment
@pdelvo
Copy link
Member

pdelvo commented Aug 8, 2015

👍

sharwell added a commit that referenced this pull request Aug 8, 2015
@sharwell sharwell merged commit e5ca4db into DotNetAnalyzers:master Aug 8, 2015
@sharwell sharwell deleted the sa1028-memory branch August 8, 2015 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants