
Performance is absolutely critical to your application's success on
Mac OS X. The latest 64-bit Intel Macs are incredibly powerful, but if your software
doesn't launch quickly or isn't responsive, users will perceive your
product as slow. To make your application run its best on Mac OS X and
to take advantage of the power of the latest hardware, you can optimize your code using Apple's
optimization tools, particularly Shark and Instruments, as well as the other Xcode
tools, technologies, and programming interfaces. Through performance tuning, your application can be more responsive to user input. And less waiting translates into more productive users.
Shark helps you discover what code to optimize. It identifies performance bottlenecks by measuring and analyzing what your program is doing, and gives hints on how to optimize. Shark is a great performance tool solution not only because of its easy-to-learn user interface and graphical analysis displays, but also because it is powerful, with many different profiling and analysis techniques, including analysis of CPU-bound jobs, system and I/O-bound jobs, memory allocation, direct analysis of Java applications, and more. Shark is highly configurable, and works with 32-bit and 64-bit applications.
Instruments is a powerful performance tool that is new in Mac OS X v10.5 Leopard. Designed for easy use plus extensibility, Instruments provides a holistic view of your application's performance in real-time. For example, you can watch memory, network, and disk usage statistics side-by-side while your application executes. You can drill down to view details, save the results, and compare multiple runs using a single window. Even better, you can save an Instruments document as a double-clickable "template" that can be run on demand. This allows you to gather the debugging information that you need from users who report problems with your application.
Instruments is based on DTrace, the dynamic tracing framework new to
Mac OS X in Leopard. DTrace is open source software from OpenSolaris
that has been ported to Mac OS X. DTrace has a zero disabled cost, meaning it incurs no overhead when not in use. DTrace is always available on a system-wide basis, plus it's scriptable, so you can create customizable instrumentation
to monitor specific problems.
During the development cycle you may find a need for specialized tools in the Xcode Tools suite, such as QuartzDebug and OpenGL Profiler
to assist in analyzing your application's slow or inefficient drawing. Xcode also includes the Computer Hardware Understanding
Development (CHUD) tools, which are applications and tools for measuring
and optimizing software performance on Mac OS X as well as for hardware
bringup and system benchmarking.
Whether you are writing your application from scratch or porting
existing code, you can follow Apple's standard guidelines to create a
well-behaved Mac OS X application. For example, you should replace
polling with event-driven behavior, reduce your application's memory
footprint, and use the Accelerate framework if your application performs a lot of
mathematical computations on scalar data. The Reference Library document Performance
Fundamentals describes these guidelines in detail.
Mac OS X provides the full breadth of the POSIX threading API, but if
you don't need the low level control of pthreads, you can take advantage
of NSThread and NSOperation.
NSThread offers a high-level abstraction
to threading, letting you easily introduce concurrency into your Cocoa
application. NSOperation makes threaded programming even
easier, allowing you to define discrete tasks that can be easily queued,
prioritized, and run concurrently or serially within your
application—all without manually managing threads on your own.
Regardless of your threaded programming expertise, Apple has a solution
to help maximize your application's performance.
How you architect, implement, and tune your application has profound
implications for the user experience. Games, of course, can always use more performance. And for any application, improved performance makes possible additional features. Apple's free and flexible
performance tools help you create applications that are quick to load,
easy to use, and elegant to operate—the kind that Apple love.
For news, updates and links to other ADC content related to Performance on Mac OS X,
return to the Performance topic page.
Updated: 2007-10-26
|