1. Instruments
Instruments is the tool of choice for investigating almost all performance and memory issues on OS X and iOS — including Core Data issues. The other tools in this list offer a lot of automation and convenience, but Instruments will typically be your first stop when investigating any issues or doing any performance tuning.
The Time Profiler and Core Data templates, shown below, are the most useful for Core Data profiling:
The default Core Data template, with the optional Faults Instrument feature added in, provides the following features to help you tune and monitor your app’s performance:
-
Core Data Fetches Instrument — Captures fetch count and duration of fetch operations.
-
Core Data Cache Misses Instrument — Captures information about fault events that result in cache misses.
-
Core Data Saves Instrument — Captures information on managed object context save events.
-
Core Data Faults Instrument — Captures information on fault events that occur during lazy initialization of
NSManagedObject
s or relationships.
Here is a typical instruments profile from a Core Data app. You can see when fetch requests are occurring and how long they take, when and how often save operations happen and whenever faults are being fired:
For more information about Instruments, check out our tutorial on How to Use Instruments in Xcode.
Where To Go From Here?
Core Data is a powerful framework, but it comes with a lot of development overhead. However, the tools and libraries in this article give you some methods to help you efficiently and effectively tackle that overhead.
Again, if you want to learn about how to use Core Data with Swift, check out our upcoming book Core Data by Tutorials, which is fully updated for iOS 8 and Swift.
In the meantime, if you have any other Core Data tools or libraries you really would like to recommend to others, please join the forum discussion below!