You are on page 1of 14

Instruments

Dynamic tracing and profiling iOS code Hang Chen

The Instruments application includes the ability to:


Examine the behavior of one or more processes Record a sequence of user actions and replay them, reliably reproducing those events and collecting data over multiple runs Create your own custom DTrace instruments to analyze aspects of system and application behavior Save user interface recordings and instrument configurations as templates, accessible from Xcode.

Using Instruments, you can:


Track down difficult-to-reproduce problems in your code Do performance analysis on your program Automate testing of your code Stress-test parts of your application Perform general system-level troubleshooting. Gain a deeper understanding of how your code works.

Instruments starting templates

The Instruments window

Recording Trace Data


Choosing Which Process to Trace
All Processes Attach to Process Choose Target Instrument Specific

Collecting Data
Immediate display Deferred display

Running Instruments from Xcode

How to see logs when using Instruments?


Simulator
Use System Console instead of Instruments Console.

Device
Organizer -> Device -> Console.

Viewing and Analyzing Trace Data


Same data, three different views
Track Pane: Graphical nature. Detail Pane: The detail information within a range. Extended Detail Pane: As the name suggests.

Viewing Data for a Range of Time

Three useful instruments


Allocations: Leaks: Time Profiler/Sampler:

Instruments: Allocations
Analyzes the memory life-cycle of process' allocated blocks; can record reference counting events. Demo

Instruments: Leaks
Use with Allocations instrument to give memory address histories. Demo

Instruments: Time Profiler


Profiles running threads on all cores at regular intervals for one or all processes. Demo

Automation Test
Demo

Thanks!

You might also like