Godfrey Nolan







Some Web History
Android Performance Tips
Android SDK Tools
Other Tools
Resources
Program Optimization Rules:
Rule 1: Don't do it.
Rule 2 (for experts only!): Don’t do it yet


Web Metric
95% of pages returned in a second or less





Optimize the slowest, most visited pages
10x performance increases not unusual
Wash, rinse, repeat






No metric yet
No log files
No time-taken token
Ideally…
Good load testing tool with activity time
Continuous Integration plugin available
Avoid creating unnecessary objects or memory
allocations
Avoid internal getters/setters
i = mCount not i = getCount()

Use Static/Final where appropriate
static final int intVal = 42; not static int intVal = 42;

Use floats judiciously
NDK calls
Views are expensive, flatten layouts, don’t inflate
Use standard libraries, enhanced for loop







Streamline your UI
Shrink your APK
Identify memory leakage issues
Profile your code
Measure performance in the field
Calabash Timings
Run 1
Run 2
Run 3

LinearLayout
3m42s
3m10s
3m16s

RelativeLayout
3m16s
3m7s
3m8s
Calabash Timings
Run 1
Run 2
Run 3

No Proguard
4m15s
4m7s
3m56s

Proguard
4m13s
3m47s
3m40s
Calabash Timings
Run 1
Run 2
Run 3

Before heap
4m57s
5m39s
4m55s

After heap
4m15s
4m7s
3m56s


SQLite
Explain plan is your friend
Use Indexes
Carefully craft your SQL



Web Services
Use log files to identify issues


DDMS
System Info
Heap Usage w/MAT
Memory Allocation
Threads



Traceview

Method Profiling within DDMS
Precise profiling using trace API









Systrace
Lint
Hierarchy Viewer
StrictMode
Unix commands
ARO
Crittercism


Leverage Unix performance commands
top 10
dump meminfo <pid>
procrank
http://developer.android.com/training/articles/perf-tips.html
http://www.youtube.com/watch?v=UApv-ZMJ51g
http://android-developers.blogspot.com/2009/11/optimize-your-layouts.html
http://developer.android.com/tools/debugging/debugging-ui.html
http://www.javaperformancetuning.com/tips/rawtips.shtml
http://software.intel.com/en-us/articles/performance-debugging-of-androidapplications/
http://developer.android.com/tools/debugging/debugging-tracing.html
http://android-developers.blogspot.com/2009_02_01_archive.html
http://bon-app-etit.blogspot.com/2013/03/using-traceview-for-betterperformance.html
http://www.sqlite.org/eqp.html
http://www.eclipse.org/mat/downloads.php
http://imgoptim.com
http://developer.att.com/developer/forward.jsp?passedItemId=13800072
http://www.devahead.com/blog/2011/12/coding-for-performance-and-avoidinggarbage-collection-in-android/




godfrey@riis.com
@riisllc

Android performance