The Xcode tools includes several graphical applications and command-line tools for gathering performance metrics. The following sections introduce the available tools and tell you when you might use them.
The Apple performance tools are installed as part of the Xcode tools. This package ships on a CD that comes with retail copies of Mac OS X. You can also download the Xcode tools for free from the Apple Developer website.
To install Xcode Tools, double-click the installer package found on the Xcode Tools CD or that you downloaded from the web. By default, the installer creates a /Developer
directory on the boot volume of your hard drive and installs applications, documentation, examples, and other files in this directory. In Xcode 3.0 and later, the installer lets you specify a custom installation directory so that you can have multiple versions of the tools on your computer.
Most of the applications with a graphical user interface have online help available through the Help menu. For information about these tools, see Mac OS X Man Pages.
Although Xcode comes with numerous applications for gathering performance data, there are a few that you will use more frequently than others. These tools can be used to gather data for both Mac OS X applications and iPhone applications. The following sections describe these tools and the features they provide.
Introduced in Mac OS X v10.5, the Instruments application combines a set of powerful analysis tools with an easy-to-use graphical user interface. Instruments provides unprecedented information about the runtime behavior of your application. Rather than show only one aspect of your program at a time, you configure each analysis session with one or more “instruments”, each of which gathers information about a particular performance metric. The data from all instruments is shown side-by-side, making it easier to correlate the data from one instrument to another and detect trends in your application’s behavior.
Among the types of metrics you can gather with the Instruments application are the following:
The performance of Core Data–based applications
Information about file system reads, writes, and other operations
Statistics relating to garbage-collected code
Information about graphics operations and performance
Statistics about object and other memory-related allocations
Information about memory leaks
Statistical samples of your application at runtime
Information about process-specific and system-level activity
Information about Java thread activity
Information about events dispatched by Cocoa
For a quick example of how to use the Instruments application, see “Using Instruments.” For detailed information about the Instruments application, see Instruments User Guide.
Shark is an advanced tool for sampling or tracing a single application or all running applications. Like Instruments, Shark provides a set of powerful analysis tools with an easy-to-use interface to help you gather performance data. Shark helps you isolate problems quickly by providing a rich set of data-mining features and is an indispensable tool for finding performance bottlenecks. It provides optimization tips and help with analyzing assembly-level operations. Because it traces operations down at the kernel-level of the system, Shark can also provide you with tremendous insight about the behavior of your application relative to the rest of the system.
Among the types of operations you can perform in Shark are the following:
Statistical sampling of your application over a period of time
System-level tracing
Malloc tracing
Static analysis
L2 Cache profiling
Processor bandwidth analysis
Java code analysis
In addition to basic sampling, Shark also offers the windowed time facility feature for several of its sampling options. The windowed time facility tells Shark to record and process a finite buffer of the most recently acquired samples. This feature lets Shark record data continuously and for long periods of time in the background. You can then direct Shark to stop sampling only after something interesting occurs in your code and to display the samples related to that interesting behavior. Thus, you can use this feature to determine what part of your program’s execution is interesting after it occurs.
For a quick example of how to use Shark, see “Using Shark.” For detailed information about Shark, see Shark User Guide.
Instruments and Shark are not the only analysis tools that you can use to gather data about the performance of your program. Most of the analysis tools are geared towards finding specific types of performance problems.
Table 3-1 lists the analysis tools installed with the Xcode Tools. (These tools are not able to analyze applications running in iOS.) Applications such as MallocDebug are installed in the <Xcode>/Applications/Performance Tools
directory, where <Xcode> is the root directory of your Xcode installation. Command-line tools, such as heap
and leaks
, are installed in /usr/bin
.
Monitoring tools are passive tools that gather data automatically. To use these tools, leave them running while you exercise the features of your program. You can then analyze the data generated by these tools to gain a better understanding of your program’s performance characteristics. Some programs, like Spin Control, should be left running all the time. Most others can be launched and terminated as needed to gather performance information.
Table 3-2 lists the monitoring tools installed with the Xcode Tools in Mac OS X. (These tools are not able to monitor applications running in iOS.) Applications such as BigTop and Spin Control are installed in the <Xcode>/Applications/Performance Tools
directory hierarchy, where <Xcode> is the root directory of your Xcode installation. The Activity Monitor tool is installed in the /Applications/Utilities
directory. Command-line tools, such as fs_usage
and top
, are installed in /usr/bin
.
Tool | Description |
---|---|
Displays common usage statistics relating to memory and CPU usage for the currently running processes. You can also initiate the sampling of a process from this application. This tool provides information that is similar to that of the | |
Displays system statistics, such as CPU, disk, network and memory usage graphically over time. You can monitor a single process or all processes. This tool provides information that is similar to that of the | |
Shows screen updates in real time by briefly flashing the areas being redrawn. You can use this tool to analyze your application’s drawing behavior. | |
Samples programs that cause the spinning cursor to appear. Leave this program running in the background to catch unresponsive applications at critical moments. | |
Graphically displays activity across a range of threads. It provides color-coded timeline views of thread activity and can display backtraces of activity at specific points in time. (Available in Mac OS X v10.5 and earlier.) | |
Displays an ongoing list of file-system activity, as generated by page faults and calls to file-system functions. You can use this tool to understand the file access patterns of your program. | |
Displays an ongoing list of system call and page fault statistics. | |
Displays common system usage statistics relating to memory and CPU usage for the currently running processes. This tool updates the information dynamically so that you can see trends at runtime. |
The CHUD Tools include additional applications for doing hardware and low-level software analysis in Mac OS X. (These tools are not able to analyze hardware running iOS.) Table 3-3 lists the tools that are part of this package and provides a brief overview of their purpose. The graphical applications are installed in <Xcode>/Applications/Performance Tools/CHUD
directory, where <Xcode> is the root directory of your Xcode installation. The command-line tools are installed in the /usr/bin
directory. All of the tools are included with the Xcode Tools.
For information about using the CHUD tools, see online help for a particular tool. Documentation for some CHUD tools is also installed in the <Xcode>/Documentation/CHUD
directory, where <Xcode> is the root directory of your Xcode installation.
Table 3-4 lists some additional command-line tools that you can use to monitor and analyze performance in Mac OS X. (These tools are not able to monitor and analyze applications running in iOS.) These tools are located in the /usr/bin/
directory and must be run from a command-line prompt. Most are installed along with the Xcode Tools. For information about these tools, see Mac OS X Man Pages.
Name | Description |
---|---|
Converts back and forth between a symbol name and the numeric address of that symbol in a running executable. | |
Displays the C-structures from an object file along with their member offset values. | |
Produces execution profiles based on an execution analysis of a program. | |
Shows the | |
Displays the symbol table information for one or more object files. | |
Displays the contents of a Mach-O executable in a more human-readable form | |
Displays information about the logical pages of a Mach-O executable file. | |
Parses the C structures from an object file and displays them along with their member offset values. | |
Produces an execution profile based on the execution analysis of a program. | |
Displays Mach virtual memory statistics, including the number of active, inactive, wired, and free pages. This tool also displays page fault and other activity information. |
Last updated: 2010-05-14