05.11.2014 Views

Xcode Instruments

Xcode Instruments

Xcode Instruments

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Xcode</strong> <strong>Instruments</strong><br />

James Paul Mason<br />

Mobile App Development Final Presentation<br />

December 17, 2012


What is it?<br />

• Set of tools to measure app performance<br />

– CPU, memory, network, hard disk, battery, etc<br />

• Can be run on iOS Simulator, any process<br />

running in Mac, or a tethered iOS device<br />

2012/12/17 <strong>Xcode</strong> <strong>Instruments</strong> 2


Why would you?<br />

• Automate a series of events leading to a bug<br />

• Find leaking memory or over-released<br />

objects (zombies)<br />

• See how resource hungry your app is<br />

– Find where you should focus your optimization<br />

efforts<br />

2012/12/17 <strong>Xcode</strong> <strong>Instruments</strong> 3


How to:<br />

• Add/edit<br />

Scheme in<br />

<strong>Xcode</strong><br />

• Select Profile<br />

appname<br />

• Choose<br />

Instrument<br />

• Cmd-i or<br />

Product ><br />

Profile<br />

2012/12/17 <strong>Xcode</strong> <strong>Instruments</strong> 4


Instrument Options<br />

2012/12/17 <strong>Xcode</strong> <strong>Instruments</strong> 5


<strong>Instruments</strong> Orientation<br />

From Apple <strong>Instruments</strong> User Guide<br />

2012/12/17 <strong>Xcode</strong> <strong>Instruments</strong> 6


Allocations and Leaks<br />

Expect to see allocations<br />

skyrocket on app launch<br />

Leaks: Increasing memory<br />

allocation due to bad<br />

memory deallocation -><br />

eating up all system memory<br />

Quickly see which object category is allocating the most and when<br />

2012/12/17 <strong>Xcode</strong> <strong>Instruments</strong> 7


Energy Diagnostics<br />

Power hungry operations<br />

• Accessing network<br />

• Using GPS<br />

• Heavy CPU usage<br />

• Disk access<br />

• Using accelerometers<br />

Track how hard you’re hitting the battery<br />

iOS Programming Guide has<br />

recommendations for<br />

optimizing usage of these<br />

• Consolidate processing to<br />

maximize CPU idle time<br />

• Transmit in bursts<br />

• Don’t poll servers<br />

• Wi-fi uses less power than<br />

data network<br />

2012/12/17 <strong>Xcode</strong> <strong>Instruments</strong> 8


Network<br />

See when the network is<br />

being accessed<br />

Compare to CPU usage<br />

and energy usage<br />

Balance burden of<br />

network on CPU and<br />

battery<br />

2012/12/17 <strong>Xcode</strong> <strong>Instruments</strong> 9


Best Practices<br />

• Apple recommends integrating instruments<br />

early in development of an app to catch<br />

problems early<br />

• At a minimum, should characterize app<br />

performance on your device(s) with<br />

<strong>Instruments</strong> before App Store submission<br />

• Powerful free tool to help you, so might as<br />

well use it<br />

2012/12/17 <strong>Xcode</strong> <strong>Instruments</strong> 10


Thank You<br />

Questions?<br />

jmason86@gmail.com<br />

2012/12/17 <strong>Xcode</strong> <strong>Instruments</strong> 11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!