Mac OS X comes with tools for gathering several different types of performance metrics for your application. Some of these tools can be launched from the Finder and some must be run from the command line. The following sections introduce the available tools and tell you when you might use them.
Installing the Apple Tools
Analysis Tools
Monitoring Tools
Hardware Analysis Tools
Additional Command-Line Tools
The Apple performance tools are installed as part of the Xcode Tools package. This package ships on a CD that comes with retail copies of Mac OS X. You can also download it for free or order a CD from the Apple Developer Connection section of the Apple website.
To install Xcode Tools, double-click the installer package found on the Xcode Tools CD or that you downloaded from the web. The installer creates a /Developer
directory on the boot volume of your hard drive. Inside this directory are subdirectories containing the applications, documentation, examples, and other files.
The primary performance tools are located in the /Developer/Applications/Performance Tools
directory but some tools are located in other subdirectories of /Developer/Applications
. Several command-line performance tools are also installed in the /usr/bin
directory and are available from Terminal.
Most of the applications with a graphical user interface have online help available through the Help menu. All of the command-line tools have man pages, accessed on the command line by typing “man
toolname”.
Analysis tools let you actively gather data about the performance of your program. You can view these tools in a way similar to debugging tools. You use them to investigate problems and gather information needed to go back and revise your code. Unlike debugging tools, most analysis tools provide a way to save data from a session so that you can view it later, which is very useful for charting the progress of your application.
With the exception of Shark, most of the analysis tools are geared towards finding specific types of performance problems. While any one tool might give you useful information, it is important to run several tools on the same code to view problems from several different angles. For example, using ObjectAlloc, you might find that your program creates a number of objects, but running MallocDebug you might find that many of those objects are actually being leaked. Shark provides many ways to gather and view information and is indispensable for finding performance problems in your code.
Table 3-1 lists the analysis tools installed with the Xcode Tools. Applications such as Shark are installed in the /Developer/Applications/Performance Tools
directory. 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. Applications such as BigTop and Spin Control are installed in the /Developer/Applications/Performance Tools
directory hierarchy. 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. 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 i 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. | |
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. The graphical applications are installed in /Developer/Applications/Performance Tools/CHUD
and the command-line tools are installed in /usr/bin
. All of the tools are included with the Xcode Tools. Table 3-3 lists the tools that are part of this package and provides a brief overview of their purpose.
For information about using the CHUD tools, see online help for a particular tool. Documentation for some CHUD tools is also installed in /Developer/ADC Reference Library/CHUD
.
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 located in the /usr/bin/
directory and must be run from a command-line prompt. Most are installed along with the Xcode Tools.
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. | |
Displays kernel trace data. | |
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. |
© 2004, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-10-03)