Introduction
FlashList provides built-in benchmarking utilities to help you measure and optimize the performance of your lists. These tools allow you to track JavaScript thread FPS (frames per second), detect performance bottlenecks, and compare FlashList performance against FlatList.Available Tools
useBenchmark
The primary hook for benchmarking FlashList performance. It automatically scrolls through your list, measures JS thread FPS, and provides actionable suggestions for improvement.useFlatListBenchmark
A benchmarking hook specifically designed for FlatList, allowing you to compare performance between FlashList and FlatList implementations.JSFPSMonitor
A low-level utility class for monitoring JavaScript thread performance. Useful for custom benchmarking scenarios or integrating performance tracking into your own tools.Understanding Metrics
JS FPS (JavaScript Frames Per Second)
Measures how many frames per second the JavaScript thread can process. This metric is crucial because:- 60 FPS: Ideal performance, smooth animations
- 45-60 FPS: Good performance, minor stutters may occur
- 35-45 FPS: Moderate performance, noticeable stutters
- Below 35 FPS: Poor performance, significant lag
- averageFPS: Overall performance across the entire benchmark
- minFPS: Worst-case performance (indicates bottlenecks)
- maxFPS: Best-case performance
Benchmark Results
All benchmarking tools return aBenchmarkResult object:
Best Practices
Preparing for Benchmarks
-
Use Production Builds: Always benchmark in release mode, not debug builds
-
Use Realistic Data: Test with data sets that match production usage
- Close Other Apps: Ensure the device isn’t running background processes
- Test on Real Devices: Simulators don’t accurately represent performance
Running Benchmarks
Interpreting Results
-
Low Average FPS (< 35)
- Components may be doing too much work
- Check for unnecessary re-renders
- Optimize heavy computations
- Use React.memo for expensive components
-
Large FPS Variance (big difference between min and max)
- Inconsistent item rendering costs
- Some items may be more complex than others
- Consider optimizing outlier items
-
Gradual FPS Degradation
- Possible memory leak
- Check for accumulated listeners or subscriptions
- Review useEffect cleanup functions
Manual Benchmark Control
For controlled testing scenarios, you can trigger benchmarks manually:Comparing with FlatList
To compare FlashList and FlatList performance:Utility Hooks
useDataMultiplier
Multiplies your data to create larger test sets:keyExtractor prop as IDs may be duplicated.
Common Issues
”Data is empty, cannot run benchmark”
Ensure your list has data before the benchmark runs:Benchmark Doesn’t Start
Check that:- The ref is properly attached to FlashList
- Data is loaded before startDelayInMs expires
- Component hasn’t unmounted
Inconsistent Results
For more reliable results:- Run multiple iterations with
repeatCount - Test on multiple devices
- Clear app state between runs
- Use the same build configuration