Upload
chris-xu
View
52
Download
4
Tags:
Embed Size (px)
DESCRIPTION
Principles from WWDC 2014 Session 710 and 712 in iOS development. To save your battery life is major concern since user could check the battery usage in iOS8. Those battery master will be deleted forever, and you are no longer be able to blame the reason of draining on other apps (Map/Facebook).
Citation preview
Writing Energy Efficient Code
2014 Session 710 & 712
What Uses Energy?
Concept
Coalesce work
Cut down wakes
“To sleep is the prepare for the longer journey ahead”
Preview
Do It Never
Do it never
• Avoid unneeded work
Respond to changes in active state
Do it neverLocation
“Stop Location Updates”
Do it at better time
• NSURLSession Background Session
• Understand requirements
• Overhead cost
Let the system schedule work
Do it at better timeNSURLSession - Discretionary Tasks
Do It at Better Time
• Network conditions Throughput
• Reduce data sizes Quality, Compress
• Avoid redundant transfers Caching, Resumable
• Handle errors Timeout, Retry
Do it at better timeNetworking
Do It More Efficiently
Do it more efficiently
Quality of Service NSOperation and NSOperationQueue
Specify QoS classes on your work
• Specify the responsiveness and energy requirements of work.
• Classify long-running or resource-intensive operations in your existing code.
• Aim for >90% of time at Utility or below when the user is inactive.
Do it more efficientlyQuality of Service
Do It Less
Do it less
• Reduce CPU Use minimize timers• Performance Unit Test (Prince)
• Limit Screen Updates• Visual effects avoid placing over updates elements
• Minimize your I/O
Optimize and improve your resource use
Do it less
• Device will wake for notifications
• Set Push notification priority
Notifications
Summary
“Be a considerate background app”
Related
2013 Session 712 Energy Best Practices