Expert performance decisions for iOS/tvOS: when to optimize vs premature optimization, profiling tool selection, SwiftUI view identity trade-offs, and memory management strategies. Use when debugging performance issues, optimizing slow screens, or reducing memory usage. Trigger keywords: performance, Instruments, Time Profiler, Allocations, memory leak, view identity, lazy loading, @StateObject, retain cycle, image caching, faulting, batch operations
View on GitHubKaakati/rails-enterprise-dev
reactree-ios-dev
January 25, 2026
Select agents to install to:
npx add-skill https://github.com/Kaakati/rails-enterprise-dev/blob/main/plugins/reactree-ios-dev/skills/performance-optimization/SKILL.md -a claude-code --skill performance-optimizationInstallation paths:
.claude/skills/performance-optimization/# Performance Optimization — Expert Decisions
Expert decision frameworks for performance choices. Claude knows lazy loading and async basics — this skill provides judgment calls for when to optimize and which tool to use.
---
## Decision Trees
### Should You Optimize?
```
When should you invest in optimization?
├─ User-facing latency issue (visible stutter/delay)
│ └─ YES — Profile and fix
│ Measure first, optimize second
│
├─ Premature concern ("this might be slow")
│ └─ NO — Wait for evidence
│ Write clean code, profile later
│
├─ Battery drain complaints
│ └─ YES — Use Energy Diagnostics
│ Focus on background work, location, network
│
├─ Memory warnings / crashes
│ └─ YES — Use Allocations + Leaks
│ Find retain cycles, unbounded caches
│
└─ App store reviews mention slowness
└─ YES — Profile real scenarios
User perception matters
```
**The trap**: Optimizing based on assumptions. Always profile first. The bottleneck is rarely where you think.
### Profiling Tool Selection
```
What are you measuring?
├─ Slow UI / frame drops
│ └─ Time Profiler + View Debugger
│ Find expensive work on main thread
│
├─ Memory growth / leaks
│ └─ Allocations + Leaks instruments
│ Track object lifetimes, find cycles
│
├─ Network performance
│ └─ Network instrument + Charles/Proxyman
│ Latency, payload size, request count
│
├─ Disk I/O issues
│ └─ File Activity instrument
│ Excessive reads/writes
│
├─ Battery drain
│ └─ Energy Log instrument
│ CPU wake, location, networking
│
└─ GPU / rendering
└─ Core Animation instrument
Offscreen rendering, overdraw
```
### SwiftUI View Update Strategy
```
View is re-rendering too often?
├─ Caused by parent state changes
│ └─ Extract to separate view
│ Child doesn't depend on changing state
│
├─ Complex computed body
│ └─ Cache expensive computations
│ Use ViewModel or memoization
│
├─ List items all updating
│ └─ Check view identity
│ Use stable IDs, not indices