Performance Starting Point for OS X
When writing software for OS X, optimizing code to minimize use of the processors and memory is crucial to the performance of your application and therefore to a good user experience.
Get Up and Running
Performance Overview helps you get familiar with the fundamentals of performance analysis.
The main tool for analyzing your code’s use of the CPU, GPU, and memory is the Instruments application. Each of the tools in Instruments is documented in Instruments User Guide.
There are several aspects to performance, including memory use, speed, and drawing performance.
To learn how to reduce your application’s memory footprint, read Code Size Performance Guidelines.
To find and improve bottlenecks in your code that affect its speed, see Code Speed Performance Guidelines.
To make your drawing code more efficient, see Drawing Performance Guidelines.
For details on management of memory resources, see Memory Usage Performance Guidelines.
If you are writing a Cocoa application, read Cocoa Performance Guidelines for tips on how to use the Cocoa frameworks more efficiently.
To learn how to improve the efficiency of your algorithms so your application doesn’t slow down with large data sets, read Code Speed Performance Guidelines.
If your application performs complex math or image calculations, read Taking Advantage of the Accelerate Framework to learn how to use the Accelerate framework to speed up operations using the available vector hardware.
Good Document Transfer Strategies Can Speed Up Networking
To improve the performance of your networking code, read TN2152: Document Transfer Strategies.
The Worm sample project illustrates several optimizations for
The OpenCL Hello World Example shows how to use OpenCL to leverage the GPU for general computations.
Here are some tips to maximize performance:
Avoid doing unnecessary work. Avoid computing anything until you are sure you actually need it.
Avoid spinlocks, polling, and other CPU-hogging techniques.
Use Core Animation and other GPU-intensive APIs sparingly. Use animation only if it provides a user benefit.
Reduce your memory footprint by minimizing the amount of data you keep in memory at any given time.
Consider memory-mapping large files instead of reading them into RAM. Doing so helps the system manage memory more efficiently.
Release or free any allocated memory as soon as you are done using it.
When practical, perform network requests in batches rather than one at a time.