When you need help debugging, Xcode 3.0 offers an extraordinary new program: Instruments. Taking interface cues from timeline editors such as GarageBand, Instruments lets you visualize application performance like never before.
Tracks that track.
Now you can visually compare many analysis instruments side by side over time. That’s because Instruments creates a time-based record of your entire application run, storing information such as CPU load, network and file activity, and memory allocations as separate “tracks” of data. These tracks are displayed synchronized over time, allowing you to quickly identify application events — like what was happening with the disk just before the CPU usage spiked. Instruments gives you a complete picture of your application, so you can better understand cause-and-effect relationships and make changes to improve performance.
Record, replay, repeat.
Instruments works with new Universal Access features in Leopard to record a user-interactive run of your application, making it easy to replay the same behavior over and over. That way, you can create ad hoc application tests anytime you like. Record the application’s behavior in Instruments, change your code, and rerun the tests to see the effect of your changes. Run your application in a template and Instruments visually compares the runs side by side, making it clear where your code changes affect performance or memory consumption.
DTrace, the systemwide analysis tool in Leopard, provides full access to system activity — from high-level application behavior to the operating system kernel. Many Instruments tools are implemented using DTrace, and Instruments provides you with the same power: Using Instrument Builder, you can create your own powerful, custom analysis instruments.
Instruments of change.
Instruments includes analysis instruments in six main categories:
- User events. Tracks the exact time of user interactions, such as mouse clicks.
- CPU and processes. Monitors activity, sampling, load graphs, and threads.
- Memory. Tracks garbage collection, object allocations, and leaks.
- File activity. Monitors disk activity, reads and writes, and file locks.
- Network activity. Measures and records network traffic.
- Graphics. Interprets the inner workings of the OpenGL driver.