Introducing Xcode Instruments

In this recipe, we will learn how we can use Instruments to help gather important information about the performance of your application.

Getting ready

In this section, we will learn how to launch the Instruments application.

How to do it...

To begin, follow these simple steps as outlined below:

  1. Launch Xcode from the /Developer/Applications folder.
  2. Choose Instruments from the Xcode menu, located under the Open Developer Tool submenu as shown in the following screenshot:
    How to do it...
  3. Select the Activity Monitor option from the list of available templates.
    How to do it...
  4. Click on the Choose button to proceed to the next step in the wizard.
  5. Next, choose All Processes from the drop-down menu as highlighted by the rectangle in the following screenshot:
    How to do it...
  6. Click on the Record button to begin profiling and monitoring system processes.

How it works...

In this recipe, we learned how easy it is to launch the Instruments application to profile an application. We learned how to use the Activity Monitor option to show how we can use this Instrument to monitor the overall CPU, memory, disk, and network activity of the current computer system.

There's more…

Through the use of the Instruments application, you can gather information based on a variety of different types of data and view these side by side at the same time. This enables you to spot trends, which would be hard to spot otherwise, and this can be used to see code running by your program along with the corresponding memory usage.

The following table provides a brief description of each feature within the Instruments application:

Instruments feature

Description

Instruments pane

This pane lists all of the Instruments, which have been added for those that you want to profile against.

New Instruments can be added by selecting and then dragging each one from the Instruments library into this pane. Items within this pane can also be deleted.

Track pane

This pane displays a graphical summary of the data returned by the current Instruments. Each Instrument has its own track that provides a chart of the data that is collected by that Instrument. The information within this pane is read-only.

Detail pane

This pane shows the details of the data that has been collected by each of the Instruments. It displays the set of events gathered and used to create the graphical view within the track pane. Depending on the type of Instrument, information that is represented by this pane can be customized to represent the data differently.

Extended detail pane

This pane displays detailed information about the item that is currently selected in the detail pane. This pane displays the complete stack trace, timestamp, and other Instrument-specific data gathered for the given event.

Navigation bar

This pane shows you where you currently are and the steps you took to get there. It includes two menus: the active Instrument menu and the detail view menu. You can click on the entries within the navigation bar to select the active Instrument, and the level and type of information in the detail view.

The Instruments trace document toolbar allows you to add and control Instruments, open view, and configure the track pane as shown in the following screenshot:

There's more…

The following table provides an explanation for each of the different controls on the toolbar:

Toolbar item

Description

Pause / Resume button

This button pauses the gathering of trace data while a recording is in progress. When the pause button has been pressed within the track pane, it will show a gap in the trace data to highlight this.

The Record / Stop button

This button starts or stops the recording process. You use this button to begin gathering trace data for your application.

Loop button

This button enables you to set whether the recorder should loop during playback to repeat the recorded steps continuously. This can be useful if you want to gather multiple runs for a given set of steps.

Target

This button selects the trace target for the document. This is the process for which data is gathered.

Inspection Range

This enables you to select the time range in the track pane. When this has been set, the Instrument displays only the data collected within the specified time period. Using the buttons with this control enables you to set the start and end points of the inspection range, and to clear the current range.

Time / Run control

Shows the time elapsed by the current document trace. If the trace document contains multiple data runs associated with it, you can use the arrow controls to choose which run data you want to display in the track pane.

The View control

Hides or shows the Instruments pane, Detail pane, and Extended View pane. These controls make it easier to only focus on the area in which you are interested in.

Library

Hides or shows the Instruments library window.

Search

This option filters information within the Detail pane, based on a search term that you enter.

The Instruments application is now located inside the Xcode bundle located within the /Developer/Applications folder and can be launched through the Xcode development IDE.

Note

For more information about using Instruments application to debug your applications, you can refer to the Apple developer documentation located at:

https://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Introduction/Introduction.html

See also

  • The Tracing iOS applications recipe
  • The Running and profiling a project recipe
  • The Adding and customizing views recipe in Chapter 2, User Interfaces – Creating the App UI
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset