2. 2
Who?
• Developing for Android since 2008
• The first employee of DroidSecurity
– First company to release An antivirus to the Android
market (2009)
– Later acquired by AVG (2011)
• Mobile Architect @AVG
• B.Sc Information System Engineering from BGU
4. 4
Why Optimize?
• We want to be better
• Smaller footprint
• Better efficiency?
• Better user retention?
• Improvements!
5. 5
What to optimize?
• We have limited resources
• Value/Cost
• User request/comments/help
• Analytics!
• Internal app metrics
– See previous talks
6. 6
What needs to be optimized?
• Resources
• CPU
• RAM
• Storage – App size/local storage
• Network communications
• Battery
7. 7
What needs to be optimized? cont.
• Design
• Cure the Feature-itis and remove bloat
• Remove unused features
• KISS
• User eXperience - UX
8. 8
Optimize basics - the benchmark
• Create a metric
• Baseline
• Memory/CPU/Battery
• Devices
• OS matrix
• User comments/responses
9. 9
Optimize The CPU usage - tools
• How to measure?
• top –m 5 –d 1 (-t)
Pros Cons
Very easy to use Measures are cumulative
Thread level usage Observer effect
10. 10
Optimize The CPU usage - tools
• Identify the problem!
• MethodTracer
• Can be Collected from the Android Device
Monitor or from code
– Debug.StartMethodTrace()
12. 12
Optimize The CPU usage
Pros Cons
Best tool Confusing
Background Logic Animation
Observer effect
• MethodTracer
13. 13
Optimize The CPU usage
• Cross application interference
• ContentObserver
• System Service
• BroadcastReceiver
• Repeated events
14. 14
Optimize The CPU usage - tips
• Use the CPU in a smart way
• Avoid work if possible
• Postpone
• Outside power
• Batch it
• Use Schedule
15. 15
Optimize The Ram usage - tools
• How to measure?
• dumpsys meminfo [package name]
Pros Cons
Very easy to use Outside measure
No Observer effect
16. 16
Optimize The Ram usage - tools
• Better details
• Heap Dump (hprof)
• Use the Android Device monitor, and MAT
Pros Cons
Very easy to dump Single point in time
No Observer effect Hard to analyze
17. 17
Optimize The Ram usage - tools
• Allocation Tracer
• Use the Android Device monitor
Pros Cons
Identify allocations Confusing
Monitoring over time
18. 18
Optimize The Network usage - tools
• How to measure?
• dumpsys netstats detail
– cat /proc/[pid]/net/dev
Pros Cons
Good info Very simplistic
No Observer effect
19. 19
Optimize The Network usage - tools
• Better details
• TCPDUMP
– Or Fiddler
Pros Cons
Analyze using standard tool Unable to handle encryption
No Observer effect
20. 20
Optimize The Network usage - tools
• Android Monitor Tool
• Use the Android Device monitor, and MAT
21. 21
Optimize The Battery usage
• How to measure?
• dumpsys batterystats
– System settings
Pros Cons
General info Observer effect
Old OS issues
22. 22
Reduce Apk size
• How to measure?
• unzip –l
• github.com/oba2cat3/parse_apk_size
• Reduce size of PNGs
• Compress the resources.arsc
• Remove unused code - ProGuard
23. 23
Summary
• Do we need to optimize?
• What to optimize?
• What tools to use?
• Make Better Apps!