Information Technology Reference
In-Depth Information
Profiling an app with Instruments
Loading a project into Instruments is known as profiling. The process is the same for OS X and iOS projects.
The simplest version has the following steps:
1. Make sure the project builds with no errors.
2. Select the Product Proile option in the main Xcode menu.
3. Wait while Xcode creates a special profiling build.
You see the usual Build Succeeded message at the end of this step.
4. Wait again while Xcode loads and launches Instruments automatically.
You don't need to launch Instruments manually when profiling.
5. Select a trace template.
A template includes one or more instruments with predefined settings, and it's designed to collect and dis-
play information about specific issues or runtime values.
6. Wait while Instruments initializes the instrument.
7. Optionally, authenticate with your standard OS X user password if asked to.
Not all instruments require this step.
8. Wait again while Instruments completes its initialization.
This can take a few seconds. Instruments appears to do nothing, and your Mac may become slow or unre-
sponsive until initialization completes.
9. Begin monitoring the app, using the instrument you selected.
The time line begins scrolling with a graphical display, and the details pane shows dynamic statistics.
Depending on the instrument, you can modify the display to zoom in or out, select or hide certain statistics,
reveal further details, and so on.
10. At the end of a run, select the Stop button at the top left.
You can now scroll through the time line to review the graph.
This process seems simple, but there are a few hidden complications. Not all templates are available on all plat-
forms. When Instruments launches, it offers a slightly different selection for OS X, iOS Simulator, and iOS hard-
ware projects.
Note also that the startup delay is variable and inconsistent. When you load Instruments for the first time, it can
take up to a minute before the time line displays useful information. iOS projects usually take longer than OS X
projects, because it can take a while for the Simulator or a device to load and run an app. Instruments needs ex-
tra initialization time on top of this delay. Generally, startup isn't an instant process, and there's an ambiguous
period after launch where it may not be clear if everything is running correctly. (It usually is.)
TIP
You can delay recording and time line updates by selecting File Record Options in the main Instruments menu.
The options dialog box includes a start delay option, a time limit option, and a deferred display check box that dis-
Search WWH ::




Custom Search