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

Add Analyzer Benchmarks #2217

Merged

Conversation

MartyIX
Copy link
Contributor

@MartyIX MartyIX commented Sep 18, 2024

Follow-up to #1477

@brminnick Sorry for being slow. You merged the PR before I could reply (sorry for being slow again ;)). I created this PR to simply show what can be done. But if you don't like the changes, don't worry, all are optional, I think you got it right.

@TheCodeTraveler
Copy link
Collaborator

TheCodeTraveler commented Sep 18, 2024

Thanks @MartyIX! I added a quick + dirty Benchmark to ensure these changes improve performance + allocations. I basically just leveraged the CommunityToolkit.Maui.Analyzers.UnitTests I wrote in #1477 and ran them as benchmarks, which is why the Method name in the tables below matches the methods in CommunityToolkit.Maui.Analyzers.UnitTests.

It looks like the updates in this PR have slightly worse mean, plus an additional Gen2 allocation.

Current Analyzer Benchmarks (main branch)

Method Mean Error StdDev Median Gen0 Gen1 Gen2 Allocated
VerifyNoErrorsWhenUseMauiCommunityToolkit 5.623 ms 0.2329 ms 0.6529 ms 5.356 ms 250.0000 62.5000 - 1.54 MB
VerifyNoErrorsWhenUseMauiCommunityToolkitHasAdditonalWhitespace 4.721 ms 0.0942 ms 0.2499 ms 4.636 ms 265.6250 78.1250 15.6250 1.51 MB
VerifyErrorsWhenMissingUseMauiCommunityToolkit 7.079 ms 0.2126 ms 0.5855 ms 7.076 ms 406.2500 156.2500 31.2500 2.25 MB

Updated Analyzer Benchmarks (PR #2217)

Method Mean Error StdDev Median Gen0 Gen1 Gen2 Allocated
VerifyNoErrorsWhenUseMauiCommunityToolkit 6.171 ms 0.1589 ms 0.4403 ms 6.114 ms 281.2500 93.7500 31.2500 1.54 MB
VerifyNoErrorsWhenUseMauiCommunityToolkitHasAdditonalWhitespace 5.403 ms 0.2031 ms 0.5924 ms 5.340 ms 265.6250 109.3750 15.6250 1.51 MB
VerifyErrorsWhenMissingUseMauiCommunityToolkit 7.773 ms 0.3835 ms 1.1004 ms 7.448 ms 406.2500 125.0000 31.2500 2.23 MB

Next Steps

I'll revert the changes to the Analyzers in this PR, keeping the /* language=C#-test */ for syntax highlighting.

I'll then add CommunityToolkit.Maui.Analyzers.Benchmarks to this PR and update our CI/CD pipeline to include the results as artifacts.

Thanks again for all of your help!

@TheCodeTraveler TheCodeTraveler changed the title Analyzers - follow-up idea Add Analyzer Benchmarks Sep 18, 2024
@TheCodeTraveler TheCodeTraveler marked this pull request as ready for review September 18, 2024 22:29
@TheCodeTraveler TheCodeTraveler enabled auto-merge (squash) September 18, 2024 23:40
@TheCodeTraveler TheCodeTraveler merged commit b9c7854 into CommunityToolkit:main Sep 18, 2024
9 checks passed
@MartyIX MartyIX deleted the feature/2024-09-18-allocation-free branch September 19, 2024 06:15
@github-actions github-actions bot locked and limited conversation to collaborators Nov 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants