SlideShare a Scribd company logo
(Code for Responsiveness)
Thinking of CPU & Memory
Done!
The app works!
Why?
25% of people leave a web page if it takes more than 4
seconds to load
why?
● Amazon: +100ms = -1% sales
● Google: going from 0.4 seconds to 0.9 seconds loading
a page causes a 20% decrease of benefits
● I don't have data about smartphones, but IMHO is even
worse
The user is very
demanding
Mobile != Computer
The concept
Classic case:
1. Download some data
2. Parse
3. Download more data (images, audios, ...)
4. Load it on memory
5. Show it on screen
Don't be a Java Hero
It seems to me that Java is designed to make it
difficult for programmers to write bad code,
while Python is designed to make it easy to
write good code.” — Magnus Lycka, Aug. 18,
2005
How?
● Compile always with the latest SDK (hardware accel, ...)
● Splash-screens are evil
● Don't do work on UI Thread
● Don't block the UI (ProgressDialogs...)
● Efficient GetViews
● Don't download same data 2 times
● Fight for the 60fps
Speed
Strict Mode
.penaltyLog()
.penaltyDeath()
Network
(Public enemy #1)
DDMS (Network Statistics)
Red (Análisis)
12s -> 0.4s (bad network, good smartphone)
Network - cache downloaded data
(this code isn't complete)
Cache:
● Universal-Image-Loader
● Picasso
Bandwidth:
● don't send too big bitmaps
● WebP (~-30%)
Bitmaps
CPU
Not everybody have a Nexus 4
Traceview (code y DDMS)
CPU (Analyze)
Cache objects
7s -> 0.8s (bad smartphone)
Show old data
always
RAM
If you don't share you get kicked
$ adb shell procrank
Keep the app in memory (Analyze)
Other tools to analyze memory usage
● adb shell dumpsys meminfo
● Heap dump
○ capture it with DDMS
○ +HeapDumpOnOutOfMemoryError
● MAT (Memory Analyzer Tool)
○ analyzes your heap dump
○ hprof-conv package.hprof package-converted.hprof
○ It has a stand-alone version if you don't want to use Eclipse
Keep the app in memory
Smoothness*
The wanted 60fps
*(Section "stolen" from Romain Guy)
Smoothness
● Profile GPU rendering (4.1)
● GPU Overdraw (4.2)
● Systrace (4.1)
● Hierarchy Viewer
Profile GPU Rendering
● profile last frames rendered
● You need to enable it on device (dev.options)
● you need <16ms per frame to get 60fps
● ddms -> System Information -> Frame render time
Systrace
● Enable on device (dev. options)
● tools/systrace/systrace.py or ddms
GPU Overdraw
● As a general recommendation
we can paint every pixel a max
of 3 times
● 9-patch for backgrounds
● lint can warn you about layouts
with possible overdraw
Hierarchy Viewer
● PerfMon (memory, cpu, network on a floating window)
● Usage Timelines (cpu, memory)
Other tools
● Save a long with start time on Application and show a
diff with current time on a toast when you are end
"printing" screen
● Send through analytics performance data
● You can do it on all parts of your app
Detect regressions
"Donald Knuth"
"Premature optimization is the root of all
evil"
References
● Google I/O 2012 - Doing More With less: Being a Good
Android Citizen
● Designing for Performance (developer.android.com)
● "Displaying Bitmaps Efficiently" Android Developers
● http://www.curious-creature.org/docs/android-performance-
case-study-1.html
● http://www.curious-creature.org/2012/12/06/android-
performance-in-practice/
twitter: @oriolj
+Oriol Jiménez

More Related Content

PPTX
Saving a century a day: how the Fresco library works
PPTX
Presentation on Fresco
PPTX
Facebook tricks for image handling in Android
PPTX
Sergey Gonchar - Fast rendering with Starling
PPTX
GNU Backgammon vs eXtremeGammon - my favourite features
PDF
Adobe AIR for mobile games
PPTX
Photoshop cs4
PPT
Being a Software Engineer at Facebook
Saving a century a day: how the Fresco library works
Presentation on Fresco
Facebook tricks for image handling in Android
Sergey Gonchar - Fast rendering with Starling
GNU Backgammon vs eXtremeGammon - my favourite features
Adobe AIR for mobile games
Photoshop cs4
Being a Software Engineer at Facebook

What's hot (9)

PPTX
Why you should use react canvas
PPTX
Android performance
ODP
Java Performance: What developers must know
PPTX
Wp7 performance challenges
PPTX
Automating your mac farm for iOS build and automation
PDF
HTML5: New UI Library for Games - Chad Austin
ODP
Memory Efficient GNOME Architecture
 
PDF
Optimizing your Game for Low-end Devices
PDF
10 things I've learned when working with html5 canvas
Why you should use react canvas
Android performance
Java Performance: What developers must know
Wp7 performance challenges
Automating your mac farm for iOS build and automation
HTML5: New UI Library for Games - Chad Austin
Memory Efficient GNOME Architecture
 
Optimizing your Game for Low-end Devices
10 things I've learned when working with html5 canvas
Ad

Similar to Thinking cpu & memory - DroidCon Paris 18 june 2013 (20)

PDF
Big Trouble in Little Networks, new and improved
PDF
High Performance Android Apps Improve Ratings with Speed Optimizations and Te...
PDF
Profiling tools and Android Performance patterns
PDF
Droid con
PDF
Big Trouble in Little Networks
PPTX
Of Bytes, Cycles and Battery Life
PPTX
Optimizing Apps for Better Performance
PPTX
Сергей Жук "Android Performance Tips & Tricks"
PPTX
Android Performance Tips & Tricks
PPTX
Getting Intimate with Images on Android with James Halpern
PDF
HTML5 vs Native Android: Smart Enterprises for the Future
PDF
Sidiq Permana - Building For The Next Billion Users
PDF
Android performance
PDF
Pref Presentation (2)
PPTX
Presentation - Android App Development - Mr. Samrakchan
PDF
Velocity building a performance lab for mobile apps in a day - final
PDF
Android memory and performance optimization
PDF
Android memory and performance optimization
PDF
Android memory and performance optimization
PDF
Sensible scaling
Big Trouble in Little Networks, new and improved
High Performance Android Apps Improve Ratings with Speed Optimizations and Te...
Profiling tools and Android Performance patterns
Droid con
Big Trouble in Little Networks
Of Bytes, Cycles and Battery Life
Optimizing Apps for Better Performance
Сергей Жук "Android Performance Tips & Tricks"
Android Performance Tips & Tricks
Getting Intimate with Images on Android with James Halpern
HTML5 vs Native Android: Smart Enterprises for the Future
Sidiq Permana - Building For The Next Billion Users
Android performance
Pref Presentation (2)
Presentation - Android App Development - Mr. Samrakchan
Velocity building a performance lab for mobile apps in a day - final
Android memory and performance optimization
Android memory and performance optimization
Android memory and performance optimization
Sensible scaling
Ad

More from Paris Android User Group (20)

PDF
Workshop: building your mobile backend with Parse - Droidcon Paris2014
PDF
Workshop: Amazon developer ecosystem - DroidCon Paris2014
PDF
Extending your apps to wearables - DroidCon Paris 2014
PDF
Scaling android development - DroidCon Paris 2014
PDF
Ingredient of awesome app - DroidCon Paris 2014
PDF
Framing the canvas - DroidCon Paris 2014
PDF
Deep dive into android restoration - DroidCon Paris 2014
PDF
Archos Android based connected home solution - DroidCon Paris 2014
PDF
Porting VLC on Android - DroidCon Paris 2014
PDF
Robotium vs Espresso: Get ready to rumble ! - DroidCon Paris 2014
PDF
Buildsystem.mk - DroidCon Paris 2014
PDF
maximize app engagement and monetization - DroidCon Paris 2014
PPTX
Using the android ndk - DroidCon Paris 2014
PPTX
Holo material design transition - DroidCon Paris 2014
PPTX
Death to passwords - DroidCon Paris 2014
PPTX
Google glass droidcon - DroidCon Paris 2014
PPTX
Embedded webserver implementation and usage - DroidCon Paris 2014
PDF
Petit design Grande humanité par Geoffrey Dorne - DroidCon Paris 2014
PDF
What's new in android 4.4 - Romain Guy & Chet Haase
PDF
Efficient Image Processing - Nicolas Roard
Workshop: building your mobile backend with Parse - Droidcon Paris2014
Workshop: Amazon developer ecosystem - DroidCon Paris2014
Extending your apps to wearables - DroidCon Paris 2014
Scaling android development - DroidCon Paris 2014
Ingredient of awesome app - DroidCon Paris 2014
Framing the canvas - DroidCon Paris 2014
Deep dive into android restoration - DroidCon Paris 2014
Archos Android based connected home solution - DroidCon Paris 2014
Porting VLC on Android - DroidCon Paris 2014
Robotium vs Espresso: Get ready to rumble ! - DroidCon Paris 2014
Buildsystem.mk - DroidCon Paris 2014
maximize app engagement and monetization - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014
Holo material design transition - DroidCon Paris 2014
Death to passwords - DroidCon Paris 2014
Google glass droidcon - DroidCon Paris 2014
Embedded webserver implementation and usage - DroidCon Paris 2014
Petit design Grande humanité par Geoffrey Dorne - DroidCon Paris 2014
What's new in android 4.4 - Romain Guy & Chet Haase
Efficient Image Processing - Nicolas Roard

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
August Patch Tuesday
PDF
Mushroom cultivation and it's methods.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Hybrid model detection and classification of lung cancer
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PPTX
1. Introduction to Computer Programming.pptx
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Getting Started with Data Integration: FME Form 101
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
NewMind AI Weekly Chronicles - August'25-Week II
August Patch Tuesday
Mushroom cultivation and it's methods.pdf
Programs and apps: productivity, graphics, security and other tools
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
A comparative analysis of optical character recognition models for extracting...
1 - Historical Antecedents, Social Consideration.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Encapsulation_ Review paper, used for researhc scholars
Group 1 Presentation -Planning and Decision Making .pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Hybrid model detection and classification of lung cancer
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
1. Introduction to Computer Programming.pptx
A comparative study of natural language inference in Swahili using monolingua...
Chapter 5: Probability Theory and Statistics
Getting Started with Data Integration: FME Form 101
Profit Center Accounting in SAP S/4HANA, S4F28 Col11

Thinking cpu & memory - DroidCon Paris 18 june 2013