iOS Performance Standards
Priority: P0
Implementation Guidelines
Diagnostic Tools
- Instruments: Regularly use Allocations and Leaks to detect memory issues.
- Time Profiler: Identify heavy CPU tasks and Main Thread stalls.
- Network instrument: Analyze request payload sizes and frequency.
Optimization
- Table/Collection Views: Always use
dequeueReusableCelland keepcellForRowAtlogic lightweight. - Image Caching: Use
SDWebImageorKingfisherfor remote assets to prevent redundant fetching and main-thread decoding. (Note:AsyncImagelacks built-in caching; prioritize third-party for lists). - Background threads: Offload expensive work (parsing, encryption) from the Main thread using GCD or Tasks.
Diagnostics
- Compiler Warnings: Enable
SWIFT_TREAT_WARNINGS_AS_ERRORSin Release builds. - Static Analyzer: Use Xcode's "Analyze" (Product > Analyze) to find logic errors.
Anti-Patterns
- No parsing/processing on Main: Use background thread.
- No redundant cache clears: Let system handle low-memory via AppDelegate.
- No undetected retain cycles: Use Leaks instrument frequently.
References
- Profiling & Optimization