Suggestion to Add Performance Metrics for SwiftUI in XCTest

As SwiftUI adoption grows, developers face challenges in effectively measuring and optimizing SwiftUI app performance within automated tests.

Currently, the only viable approach to analyzing SwiftUI performance is through Profiling (Instruments), which, while powerful, lacks the ability to be incorporated into automated testing workflows. It would be incredibly valuable if XCTest could introduce new performance metrics specifically tailored for SwiftUI, allowing us to write tests against common performance bottlenecks.

Suggested Metrics:

  • View Body Evaluation Count – Tracks how often a SwiftUI body is recomputed to detect unnecessary re-renders.
  • Slow View Bodies – Flags SwiftUI views that take a significant amount of time to compute their body.

These metrics would help developers identify inefficiencies early, enforce performance best practices through CI/CD pipelines, and ensure a smooth user experience. I believe adding these performance metrics would be a game-changer for SwiftUI development.

Thank you for your time and consideration!

@mohammadrhemmati If you'd like us to consider adding these functionality, please file an enhancement request using Feedback Assistant. Once you file the request, please post the FB number here.

If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?

Suggestion to Add Performance Metrics for SwiftUI in XCTest
 
 
Q