Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Performance tuning from the trenches

Performance tuning from the trenches

Session description as announced:

"Mobile phones are becoming more and more powerful. The amount of computing power people carry in their pockets nowadays is mind boggling. But still, mobile devices are very much constrained by their battery capacity. So it is important to be frugal about the amount of processor cycles a mobile App uses. It is also important to achieve 60 frames per second, even if you are just creating yet another weather app. (The example will not be a weather app.)

In this session Jeroen will show how you can analyse and improve processor usage on your iOS app. The principals are general and applicable to any other platform, but Jeroen will demonstrate these principles with Xcode and iOS."

More Decks by Jeroen Leenarts (AppForce1)

Other Decks in Programming

Transcript

  1. Links • https://github.com/jeroenleenarts/FibonacciTest • https://github.com/jeroenleenarts/PerformanceFunHouse • http://www.raywenderlich.com/31166/25-ios-app- performance-tips-tricks • WWDC

    2012 session 712
 https://developer.apple.com/videos/wwdc/2012/ • https://developer.apple.com/library/mac/documentation/ DeveloperTools/Conceptual/InstrumentsUserGuide/ Introduction/Introduction.html
  2. 5 JUNI 2014 15:00 - 21:00 ! Thema: Full speed

    ahead! Met keynote speakers: ANDRÉ KUIPERS & NALDEN ! Unieke locatie: SS ROTTERDAM http://xebicon.nl
  3. "We should forget about small efficiencies, say about 97% of

    the time: premature optimization is the root of all evil. ! Yet we should not pass up our opportunities in that critical 3%. A good programmer will not be lulled into complacency by such reasoning, he will be wise to look carefully at the critical code; but only after that code has been identified"
  4. iOS Performance tuning • Why does it matter? • What

    uses energy? • It’s all about the tools • Obvious things to do?
  5. Apple says… • Be absolutely idle when app is not

    in use • Eliminate nonuser-driven work • Wait quietly for user input • Be efficient when user requests action • Performance = power • Efficient, multithreaded algorithms win (use GCD) • Then race back to idle
  6. Obvious things to do? • Use ARC • Use a

    Reuseidentifier • Don’t be transparant, be opaque • Don’t block the main thread • Size image resource appropriately • Enable GZip Compression • Set the shadow path http://www.raywenderlich.com/31166/25-ios-app-performance-tips-tricks
  7. Set the shadow path view.layer.shadowOffset = CGSizeMake(-1.0f, 1.0f); view.layer.shadowRadius =

    5.0f; view.layer.shadowOpacity = 0.6; ! view.layer.shadowPath = [[UIBezierPath bezierPathWithRect:view.bounds] CGPath]; http://www.raywenderlich.com/31166/25-ios-app-performance-tips-tricks#shadowpath
  8. Obvious things to do? • Reuse and lazy load when

    appropriate • Cache • Re-use expensive objects (DateFormatters) • Let someone else do the work
  9. Always a trade-off • Using CPU is usually is better

    compared to network I/O • Using memory is usually better compared to CPU