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

Optimize TextAlignmentExtensionsGenerator #321

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft

Conversation

brminnick
Copy link
Collaborator

@brminnick brminnick commented Oct 4, 2024

Description of Change

This PR improves the performance of TextAlignmentExtensionsGenerator, optimizing for memory allocations and processing time.

This PR also adds Unit Tests + Benchmarks for CommunityToolkit.Maui.Markup.SourceGenerators to ensure no regressions between the previous implementation of TextAlignmentExtensionsGenerator and this updated/optimized implementation.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard

Additional information

@brminnick brminnick changed the title [Housekeeping] Optimize TextAlignmentExtensionsGenerator and Add CommunityToolkit.Maui.Markup.SourceGenerators.UnitTests [Housekeeping] Optimize TextAlignmentExtensionsGenerator Oct 4, 2024
@brminnick brminnick marked this pull request as ready for review October 6, 2024 19:52
@brminnick brminnick changed the title [Housekeeping] Optimize TextAlignmentExtensionsGenerator Optimize TextAlignmentExtensionsGenerator Oct 6, 2024
@brminnick brminnick removed the request for review from VladislavAntonyuk October 6, 2024 23:01
@brminnick brminnick marked this pull request as draft October 6, 2024 23:01
@brminnick
Copy link
Collaborator Author

brminnick commented Oct 6, 2024

Here's the current benchmark results. It looks like I still have some work to do to optimize the SourceGenerator to reduce memory allocations

Current / Previous TextAlignmentExtensionsGenerator

Method Mean Error StdDev Median Gen0 Allocated
VerifyGeneratedSource_WhenClassIsGeneric 70.92 ms 7.361 ms 20.15 ms 61.36 ms 333.3333 9.48 MB
VerifyGeneratedSource_WhenClassImplementsITextAlignmentInterface 67.18 ms 4.793 ms 12.96 ms 61.78 ms 333.3333 9.4 MB

Updated TextAlignmentExtensionsGenerator

Method Mean Error StdDev Median Gen0 Allocated
VerifyGeneratedSource_WhenClassIsGeneric 65.35 ms 5.100 ms 14.13 ms 59.63 ms 333.3333 10.49 MB
VerifyGeneratedSource_WhenClassImplementsITextAlignmentInterface 66.48 ms 6.051 ms 16.67 ms 58.66 ms 333.3333 10.42 MB

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.

1 participant