Skip to content

Conversation

@TheCodeTraveler
Copy link
Collaborator

@TheCodeTraveler TheCodeTraveler 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

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

TheCodeTraveler 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