Shark
Shark
is a performance-analysis application that creates a time-based profile
of your program’s execution; over a given period it traces function
calls and graphs memory allocations. You can use Shark to track
information for a single program or for the entire system, which on Mac
OS X includes kernel components such as drivers and kernel extensions.
Shark also monitors file-system calls, traces system calls and memory
allocations, performs static analyses of your code, and gathers
information about cache misses, page faults, and other system metrics.
Shark supports the analysis of code written in C, Objective-C, C++, and
other languages.
Other Performance Applications (Mac OS X)
Many applications are used in measuring and analyzing aspects of a Mac OS X program’s performance. They are located in <Xcode>/Applications/Performance Tools
.
Thread Viewer
displays activity among a process’s threads. It shows time lines of
activity on each thread, which is color-coded with the action. By
clicking a time line, you can get a sample backtrace of activity at that
point.
BigTop graphs performance trends over time, providing a real-time display of memory usage, page faults, CPU usage, and other data.
Spin Control
automatically samples unresponsive applications. You leave Spin Control
running in the background while you launch and test your applications.
If applications become unresponsive to the point where the spinning
cursor appears, Spin Control automatically samples your application to
gather information about what your application was doing during that
time.
MallocDebug
shows all currently allocated blocks of memory in your program,
organized by the call stack at the time of allocation. At a glance you
can see how much allocated memory your application consumes, where that
memory was allocated from, and which functions allocated large amounts
of memory. MallocDebug can also find allocated memory that is not
referenced elsewhere in the program, thus helping you find leaks and
track down exactly where the memory was allocated.
QuartzDebug
is a tool to help you debug how your application displays itself. It is
especially useful for applications that do significant amounts of
drawing and imaging. QuartzDebug has several debugging options,
including the following:
Auto-flush drawing, which flushes the contents of graphics contexts after each drawing operation)
A mode that paints regions of the screen in yellow just before they’re updated
An
option that takes a static snapshot of the system-wide window list,
giving the owner of each window and how much memory each window
consumes.
For performance analysis, you can also use command-line tools such as:
top
, which shows a periodically sampled set of statistics on currently running processes
gprof
, which produces an execution profile of a program
fs_usage
, which displays file-system access statistics
Many other command-line tools for performance analysis and other development tasks are available. Some are located in /usr/bin
and /usr/sbin
, and some Apple-developed command-line tools are installed in <Xcode>/Tools
.
For many of these tools you can consult their manual page for usage
information. (To do this, either choose Help > Open man page in Xcode
or type man
followed by the name of the tool in a Terminal shell.)
Further Reading: For
more on the performance tools and applications you can use in Cocoa
application development, as well as information on concepts, techniques,
guidelines, and strategy related to performance, see
Performance Overview.
Cocoa Performance Guidelines