Upload
mobicode
View
59
Download
0
Embed Size (px)
Citation preview
But what is high performance?
• Strategies to create efficient software
Layout
Energy and battery
Security
Multithreading Programming patterns
Debugging techniques
ANR
• No response for input event in 5 seconds
• BroadCast receiver still executing after 10 seconds
Layouts
TV: 24fps(NTSC), 25fps(PAL)
New cam-coders / slow motion: 48fps+
Blur can occur!
Apps: 60fps!
every 16 ms!
Memory - Enumerations Summary
• Unnecessary allocations • AVOID USING THEM • Change as much as possible with static final integer values
Memory - Constants
Constants in the code should be static and final to take advantage of memory savings and to avoid initialization in Java compiler
Memory Leaks
“a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in such a way that memory which is no longer needed is not released.” Wikipedia
Threading
“is the smallest sequence of programmed instructions that can be managed independently by a scheduler”
Wikipedia
Threading - AsyncTask
Communicate Worker Thread with UI
Does not need to communicate UI? Does not need to notify user? DOES NOT NEED ASYNCTASK!
If the AsyncTask has all parameters Void, you are only implementing doInBackground() and you do not need an AsyncTask
Threading - AsyncTaskLoader
Use it to fetch data
Same features as AsyncTask…
…plus the Activity life-cycle independency and data caching
Threading - Services
• Not threads! • Executed in UI Thread by default • Never start a long running operation! • Lifecycle
Threading - IntentService
• Particular implementation of a Service • Execute sequential operations in background • Don’t need to handle the lifecycle
Networking - best practices
Pre-fetch
• Download as much as possible • (specially if idle connection)