Performance & Profiling
Measure frame rate, re-renders, memory and CPU with profilers, then fix the usual causes of jank in lists, images and state updates.
Advanced · about 8 hours · difficulty 4/5
Learn first: Lists, Scrolling & User Input, App-wide State Tools
Users do not read performance numbers; they feel them. Dropped frames while scrolling, a slow tap response or a warm phone all make an app feel cheap. The discipline is measure first, fix second, measure again, always on a real mid-range device with a release build.
What to measure
- Frame rate and frame time: are frames finishing inside 16 ms?
- Responsiveness: time from tap to visible feedback.
- Memory: steady growth while navigating signals a leak.
- CPU, network and battery: work you do in the background still costs.
Profilers by stack
- React Native: the Perf Monitor overlay, React DevTools Profiler to find components that re-render too often, and Hermes sampling profiles. Native tools (Android Studio, Xcode Instruments) still apply underneath.
- Flutter: DevTools performance view shows UI and raster thread timings; always profile in
--profilemode. - Android: Android Studio Profiler, Perfetto system traces and Macrobenchmark.
- iOS: Instruments templates such as Time Profiler, Allocations, Leaks and Hitches.
Common fixes
- Lists: virtualise (FlashList or FlatList,
ListView.builder,LazyColumn,List), give items stable keys, keep row components cheap and memoised. - Re-renders: split state so a keystroke does not re-render the whole screen; use
React.memo, selectors,constwidgets or stable Compose parameters. - Images: request thumbnails sized for the view, cache them (expo-image, cached_network_image, Coil, Kingfisher).
- Main thread: move JSON parsing, crypto and heavy loops off it (workers, isolates, coroutines on
Dispatchers.Default, Swift tasks).
Good enough to move on: you can record a profile of a janky screen, point to the cause in the trace, fix it and show the before and after numbers.
Key concepts
- Frame time and jank
- Profiling release builds on real devices
- React DevTools Profiler: React Native
- Flutter DevTools, Android Profiler, Instruments: per stack
- List virtualisation and FlashList
- Avoiding unnecessary re-renders
- Image sizing and caching
- Memory leaks
- Offloading work from the main thread
Mini project
Take a feed screen with 1,000 image rows, record a baseline profile, then apply virtualisation, memoisation and image caching and document the frame time improvement.
Check yourself
Why is profiling a debug build on an emulator misleading, and what would you do instead?
Free resources
- React Native: Performance overview (React Native)
- Flutter: Performance (Flutter)
- Android: App performance (Android Developers)