Share
PERFMATTERS for Android
The slogan '#PERFMATTERS' by Colt McAnlis is one of the most important statements, which an Android developer should follow. A well performing application makes the difference between a nice looking application and one, which gets successful. You, as an Android developer, have the responsibility to delight your users, so they don't feel how much work your application has to burden to fulfill the user's needs. This session will show you some easy optimizations and how to avoid glitches in the application. A lot of developers would shout, that this is premature optimization. In contrary it is preventive. With a small amount of work while developing you can avoid a lot of pitfalls. You will hopefully have a better understanding of the underlying system afterwards. During the session some tools and frameworks will be presented for helping you to fulfill your mission.
Hasan Hosgel
Transcript
86 slides
-
Why we are developers? GDG DevFest Hamburg 6th November 2015
#PERFMATTERS for Android – Hasan Hosgel -
Why we are developers? ESPECIALLY ANDROID GDG DevFest Hamburg 6th
November 2015 #PERFMATTERS for Android – Hasan Hosgel -
We are smart! GDG DevFest Hamburg Image Source: https://www.flickr.com/photos/theinfamousgdub/1765952198 6th
November 2015 #PERFMATTERS for Android – Hasan Hosgel -
We Love Android GDG DevFest Hamburg 6th November 2015 #PERFMATTERS
for Android – Hasan Hosgel -
GDG DevFest Hamburg Photo by Sujaki-F 6th November 2015 #PERFMATTERS
for Android – Hasan Hosgel -
We have Passion GDG DevFest Hamburg Photo by Sujaki-F 6th
November 2015 #PERFMATTERS for Android – Hasan Hosgel -
We love challenges GDG DevFest Hamburg 6th November 2015 #PERFMATTERS
for Android – Hasan Hosgel -
We want Money GDG DevFest Hamburg Image Source: https://www.flickr.com/photos/68751915@N05/6793826885 6th
November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Delight our users GDG DevFest Hamburg Image Source: http://agenciabrasil.ebc.com.br/geral/foto/2014-07/cerimonia-de-premiacao-da-copa-do-mundo-no-brasil 6th
November 2015 #PERFMATTERS for Android – Hasan Hosgel -
User Expectations on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th
November 2015 #PERFMATTERS for Android – Hasan Hosgel -
User Expectations • Mobile App Users are impatient on applications
Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
User Expectations • Mobile App Users are impatient • 61%
app start < 4 s on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
User Expectations • Mobile App Users are impatient • 61%
app start < 4 s • 49% app start < 2 s on applications GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
User Expectations • Mobile App Users are impatient • 61%
app start < 4 s • 49% app start < 2 s • Users are intolerant of issues and are quick to uninstall mobile apps on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
User Expectations • Mobile App Users are impatient • 61%
app start < 4 s • 49% app start < 2 s • Users are intolerant of issues and are quick to uninstall mobile apps • 80% three attempts or less on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
User Expectations • Mobile App Users are impatient • 61%
app start < 4 s • 49% app start < 2 s • Users are intolerant of issues and are quick to uninstall mobile apps • 80% three attempts or less • 53% apps with severe issues like crashes, freezes or errors on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
User Expectations • Mobile App Users are impatient • 61%
app start < 4 s • 49% app start < 2 s • Users are intolerant of issues and are quick to uninstall mobile apps • 80% three attempts or less • 53% apps with severe issues like crashes, freezes or errors • 36% heavy battery usage on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
User Expectations • Mobile App Users are impatient • 61%
app start < 4 s • 49% app start < 2 s • Users are intolerant of issues and are quick to uninstall mobile apps • 80% three attempts or less • 53% apps with severe issues like crashes, freezes or errors • 36% heavy battery usage • Users blame the app and the company who made it on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
User Expectations • Mobile App Users are impatient • 61%
app start < 4 s • 49% app start < 2 s • Users are intolerant of issues and are quick to uninstall mobile apps • 80% three attempts or less • 53% apps with severe issues like crashes, freezes or errors • 36% heavy battery usage • Users blame the app and the company who made it • 55% app is responsible for performance issues on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
User Expectations • Mobile App Users are impatient • 61%
app start < 4 s • 49% app start < 2 s • Users are intolerant of issues and are quick to uninstall mobile apps • 80% three attempts or less • 53% apps with severe issues like crashes, freezes or errors • 36% heavy battery usage • Users blame the app and the company who made it • 55% app is responsible for performance issues • 37% Stated that app crashes or errors make them think less of a company’s brand on applications Source: https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Performance Impacts GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for
Android – Hasan Hosgel -
Performance Impacts • 500 ms delay • bounce rate -4.7%
• conversion rate -1.9% Source: http://www.mobilejoomla.com/media/press/responsive-vs-serverside/Responsive-Design-vs-Server-Side-Solutions-Infographic.jpg GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Performance Impacts • 500 ms delay • bounce rate -4.7%
• conversion rate -1.9% • 1,000 ms delay • bounce rate -8.3% • Conversion rate -3.5% Source: http://www.mobilejoomla.com/media/press/responsive-vs-serverside/Responsive-Design-vs-Server-Side-Solutions-Infographic.jpg GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Performance Impacts • 500 ms delay • bounce rate -4.7%
• conversion rate -1.9% • 1,000 ms delay • bounce rate -8.3% • Conversion rate -3.5% • 100ms delay mean for Amazon -1% revenue Source: http://www.mobilejoomla.com/media/press/responsive-vs-serverside/Responsive-Design-vs-Server-Side-Solutions-Infographic.jpg GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Performance Impacts • 500 ms delay • bounce rate -4.7%
• conversion rate -1.9% • 1,000 ms delay • bounce rate -8.3% • Conversion rate -3.5% • 100ms delay mean for Amazon -1% revenue • 11% scream at there device Source: http://www.mobilejoomla.com/media/press/responsive-vs-serverside/Responsive-Design-vs-Server-Side-Solutions-Infographic.jpg GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Performance Impacts • 500 ms delay • bounce rate -4.7%
• conversion rate -1.9% • 1,000 ms delay • bounce rate -8.3% • Conversion rate -3.5% • 100ms delay mean for Amazon -1% revenue • 11% scream at there device • 4 % throw their phones Source: http://www.mobilejoomla.com/media/press/responsive-vs-serverside/Responsive-Design-vs-Server-Side-Solutions-Infographic.jpg https://www.flickr.com/photos/9009139@N08/1263954439 GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Let‘s find some performance improvements GDG DevFest Hamburg 6th November
2015 #PERFMATTERS for Android – Hasan Hosgel -
Possible improvements CPU Memory I/O GDG DevFest Hamburg 6th November
2015 #PERFMATTERS for Android – Hasan Hosgel -
Possible improvements CPU Memory I/O • Keep the work of
the main thread à ANR GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Possible improvements CPU Memory I/O • Keep the work of
the main thread à ANR • Avoid GPU overdrawings • https://www.youtube.com/watch?v=T52v50r-JfE GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Possible improvements CPU Memory I/O • Keep the work of
the main thread à ANR • Avoid GPU overdrawings • https://www.youtube.com/watch?v=T52v50r-JfE • Avoid nested multi-pass layouts • http://goo.gl/Q5te24 GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Possible improvements CPU Memory I/O • Keep the work of
the main thread à ANR • Avoid GPU overdrawings • https://www.youtube.com/watch?v=T52v50r-JfE • Avoid nested multi-pass layouts • http://goo.gl/Q5te24 • Consider RenderScript for performance critical code GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Possible improvements CPU Memory I/O • Do not allocate memory
inside onDraw() GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Possible improvements CPU Memory I/O • Do not allocate memory
inside onDraw() • Check for leaks • LeakCanary à https://github.com/square/leakcanary GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
LeakCanary to the Rescue h"ps://github.com/square/leakcanary GDG DevFest Hamburg 6th November
2015 #PERFMATTERS for Android – Hasan Hosgel -
Setup LeakCanary GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for
Android – Hasan Hosgel -
Use Your Debug Build Normally GDG DevFest Hamburg 6th November
2015 #PERFMATTERS for Android – Hasan Hosgel -
Analysing Memory GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for
Android – Hasan Hosgel -
Analysing Heap Dump GDG DevFest Hamburg 6th November 2015 #PERFMATTERS
for Android – Hasan Hosgel -
Analysing Memory GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for
Android – Hasan Hosgel -
Possible improvements CPU Memory I/O • Do not allocate memory
inside onDraw() • Check for leaks • LeakCanary à https://github.com/square/leakcanary GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Possible improvements CPU Memory I/O • Do not allocate memory
inside onDraw() • Check for leaks • LeakCanary à https://github.com/square/leakcanary • Avoid listener à EventBus GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Possible improvements CPU Memory I/O • Do not allocate memory
inside onDraw() • Check for leaks • LeakCanary à https://github.com/square/leakcanary • Avoid listener à EventBus • Use SparseArray* family instead of JDK Collections/ Maps GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Possible improvements CPU Memory I/O • Do not allocate memory
inside onDraw() • Check for leaks • LeakCanary à https://github.com/square/leakcanary • Avoid listener à EventBus • Use SparseArray* family instead of JDK Collections/ Maps • Be aware that enums need more resource, but use them, if it will make sense for you GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Possible improvements CPU Memory I/O • Activate gzip compression on
incoming and outgoing network traffic or FlatBuffer à FlatBuffer: https://www.youtube.com/watch?v=iQTxMkSJ1dQ GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Analysing Network First Start GDG DevFest Hamburg 6th November 2015
#PERFMATTERS for Android – Hasan Hosgel -
Analysing Network Second Start GDG DevFest Hamburg 6th November 2015
#PERFMATTERS for Android – Hasan Hosgel -
Possible improvements CPU Memory I/O • Activate gzip compression on
incoming and outgoing network traffic or FlatBuffer à FlatBuffer: https://www.youtube.com/watch?v=iQTxMkSJ1dQ • Cache data on disk (image, http responses) with reasonable TTL • Reasonable TTL • Server side cache headers like ETag & Last-Modified GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Second Start With Caching GDG DevFest Hamburg 6th November 2015
#PERFMATTERS for Android – Hasan Hosgel -
Possible improvements CPU Memory I/O • Activate gzip compression on
incoming and outgoing network traffic or FlatBuffer à FlatBuffer: https://www.youtube.com/watch?v=iQTxMkSJ1dQ • Cache data on disk (image, http responses) with reasonable TTL • Reasonable TTL • Server side cache headers like ETag & Last-Modified • Use JobScheduler API to batch across system or better use push notifications for updateinformation GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Optimizing ArrayList GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for
Android – Hasan Hosgel -
Optimizing ArrayList GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for
Android – Hasan Hosgel -
Optimizing ArrayList GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for
Android – Hasan Hosgel -
Optimizing ArrayList GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for
Android – Hasan Hosgel -
Optimizing ArrayList GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for
Android – Hasan Hosgel -
Optimizing Bundle GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for
Android – Hasan Hosgel -
Optimizing StringBuilder GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for
Android – Hasan Hosgel -
Optimizing StringBuilder GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for
Android – Hasan Hosgel -
Optimizing StringBuilder GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for
Android – Hasan Hosgel -
Optimize Moar – The Loop GDG DevFest Hamburg 6th November
2015 #PERFMATTERS for Android – Hasan Hosgel -
Optimize Moar – The Loop GDG DevFest Hamburg 6th November
2015 #PERFMATTERS for Android – Hasan Hosgel -
Optimize Moar – The Loop GDG DevFest Hamburg 6th November
2015 #PERFMATTERS for Android – Hasan Hosgel -
Optimize Moar – The Loop GDG DevFest Hamburg 6th November
2015 #PERFMATTERS for Android – Hasan Hosgel -
GDG DevFest Hamburg https://speakerdeck.com/alosdev/perfmatters-for-android Contact: +HasanHosgel alosdev Thanks for your
Attention! We are hiring: http://www.kitchenstories.de/#jobs 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
GDG DevFest Hamburg https://speakerdeck.com/alosdev/perfmatters-for-android Contact: +HasanHosgel alosdev Thanks for your
Attention! We are hiring: http://www.kitchenstories.de/#jobs 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel -
Sources • https://ssl.www8.hp.com/ww/en/secure/pdf/4aa5-7696enw.pdf • http://www.mobilejoomla.com/media/press/responsive-vs-serverside/Responsive- Design-vs-Server-Side-Solutions-Infographic.jpg • https://speakerdeck.com/jakewharton/eliminating-code-overhead-square-hq-2015 • http://periplanisi.com/android/2013/11/multi-pass-viewgroup-and-performance/
• https://slideshare.net/dougsillars/android-app-performance-europe-2015 • https://www.youtube.com/playlist?list=PLWz5rJ2EKKc9CBxr3BVjPTPoDPLdPIFCE GDG DevFest Hamburg 6th November 2015 #PERFMATTERS for Android – Hasan Hosgel