SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Of Bytes, Cycles and Battery Life
Who am I?

[2]

[1]

@badlogicgames
http://www.badlogicgames.com
What i‘ll talk about
• How to reduce your APK size
• Memory Analysis Tools
• Performance Analysis Tools
How to reduce your APK size
• Reduce asset size
– pngcrush your PNGs [3]
– SVG (YMMV) [4]
– lower bit-rates for audio

• Reduce code size
– Remove unnecessary dependencies!
– Proguard, for Class files [5] [6]
– Dexguard, for Dex files [7]
„But i can‘t reduce my APK size“
• Multiple-APKs to the „rescue“ [8]
–
–
–
–

One APK per screen density
One APK per texture compression algorithm
Use Google Play filters
Easier with new Android Gradle build system

• APK Expansion files [9]
– hosted by Google

• Roll your own „Expansion files“
– Avoid if you can!
Memory Analysis Tools
• „But we have a Garbage Collector!“
– You can still „leak“ memory
– Nasty static vars referencing unused objects
– Hidden object references
– Native memory allocated by Java classes

• If you write games, GC kills your steady
framerate
DDMS [10] Heap View
DDMS Allocation Tracker
HPROF/Eclipse MAT [11]
•
•
•
•

Select the process
Click
Save to a location of your choice
Convert to „real“ HPROF file

• Open in Eclipse MAT [12]
HPROF/Eclipse MAT
HPROF/Eclipse MAT
HPROF/Eclipse MAT
Performance Analysis Tools
• Why do we want to analyse?
– Jerky animations
– Do less, conserve battery
– Better user Experience

• What do we want to analyse?
– Time spent in Java code
– Time spent in Native code
– Time spent drawing stuff
Before we start...
• Never use the emulator!
– Ever, think of the kittens

• Identify hotspots in your app, not in
microbenchmarks
• Only spend time if you have a real problem
Java Profilers
• DDMS
– Quite capable method level profiler
– Good enough for 99% of use cases
– Works with any Android version

• 4.1+ Profiling tools
– Systrace [13], More powerful, also tracks OS calls
• Needs root and Android 4.1+

– We‘ll check out the graphical parts later
DDMS
•
•
•
•

Start app
Navigate to problematic activity, hit
Wait a bit, hit
View profiling data
– Ignore absolute time, only care for relative timings
– Ignore trivial getters/setters, instrumentation messes
with timings
DDMS
Native Code Profilers
• Android NDK Profiler [14]
– Not an official NDK tool
– Setup a bit involved

• Device specific CPU profilers
– NVIDIA Nsight [15], ...

• Roll your own
– Instrument manually
– Track down hotspots
Graphics Profilers
• What do we analyse?
– Overdraw, your biggest enemy
– Draw calls, your second biggest enemy
• Use DDMS/systrace

– Related to memory
• Textures on VRAM (which is usually RAM)
• Bitmaps in RAM
Graphics Profilers
• 4.1+ Profiling tools
• GPU Vendor Specific
– NVIDIA [16], Qualcomm [17], Imagination
Technologies [18]
– Outside of scope of this talk
Visualize Overdraw [19]
Visualize Overdraw
•
•
•
•
•

Normal Color – 0 Overdraw
Blue – 1x Overdraw
Green – 2x Overdraw
Light Red – 3x Overdraw
Dark Red – +4x Overdraw
Visualize Overdraw
• Hierarchy View [20]
• Window -> Open Perspective -> Other...
Visualize Overdraw
Visualize Overdraw
•
•
•
•
•

Tracer for OpenGL [21]
Window -> Open Perspective -> Other ...
Click
Enter package name
Wait
Visualize Overdraw
Visualize Overdraw
Closing Words
• So much to tell, so little time
• See Dalvik Performance Tips [22]
• Read all references
– Your users will thank you for excellent battery life
and buttery smooth UIs
FIN
Thanks for Listening
Questions?
References
[1] http://www.amazon.com/Beginning-Android-Games-Mario-Zechner/dp/1430246774
[2] http://libgdx.badlogicgames.com/
[3] http://pmt.sourceforge.net/pngcrush/
[4] https://code.google.com/p/svg-android/
[5] http://developer.android.com/tools/help/proguard.html
[6] http://proguard.sourceforge.net/index.html
[7] http://www.saikoa.com/dexguard
[8] http://developer.android.com/google/play/publishing/multiple-apks.html
[9] http://developer.android.com/google/play/expansion-files.html
[10] http://developer.android.com/tools/debugging/ddms.html
[11] http://android-developers.blogspot.co.at/2011/03/memory-analysis-for-android.html
References
[12] http://www.eclipse.org/mat/
[13] http://developer.android.com/tools/help/systrace.html
[14] https://code.google.com/p/android-ndk-profiler/
[15] http://www.nvidia.com/object/nsight.html
[16] https://developer.nvidia.com/tegra-profiler
[17] https://developer.qualcomm.com/mobile-development/mobile-technologies/gaming-graphics-optimization-adreno/toolsand-resources
[18] http://www.imgtec.com/powervr/insider/sdkdownloads/
[19] http://www.curious-creature.org/2012/12/01/android-performance-case-study/
[20] http://developer.android.com/tools/debugging/debugging-ui.html
[21] http://developer.android.com/tools/help/gltracer.html
[22] http://developer.android.com/training/articles/perf-tips.html

Weitere ähnliche Inhalte

Ähnlich wie Of Bytes, Cycles and Battery Life

Thinking cpu & memory - DroidCon Paris 18 june 2013
Thinking cpu & memory - DroidCon Paris 18 june 2013Thinking cpu & memory - DroidCon Paris 18 june 2013
Thinking cpu & memory - DroidCon Paris 18 june 2013Paris Android User Group
 
Memory management in Andoid
Memory management in AndoidMemory management in Andoid
Memory management in AndoidMonkop Inc
 
PAC 2019 virtual Christoph NEUMÜLLER
PAC 2019 virtual Christoph NEUMÜLLERPAC 2019 virtual Christoph NEUMÜLLER
PAC 2019 virtual Christoph NEUMÜLLERNeotys
 
CNIT 128 6. Analyzing Android Applications (Part 1)
CNIT 128 6. Analyzing Android Applications (Part 1)CNIT 128 6. Analyzing Android Applications (Part 1)
CNIT 128 6. Analyzing Android Applications (Part 1)Sam Bowne
 
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class Chris Gates
 
"Automated Malware Analysis" de Gabriel Negreira Barbosa, Malware Research an...
"Automated Malware Analysis" de Gabriel Negreira Barbosa, Malware Research an..."Automated Malware Analysis" de Gabriel Negreira Barbosa, Malware Research an...
"Automated Malware Analysis" de Gabriel Negreira Barbosa, Malware Research an...SegInfo
 
Mobile operating systems - Application Benchmarking
Mobile operating systems - Application BenchmarkingMobile operating systems - Application Benchmarking
Mobile operating systems - Application BenchmarkingNicolas Demetriou
 
DevOpsCon 2015 - DevOps in Mobile Games
DevOpsCon 2015 - DevOps in Mobile GamesDevOpsCon 2015 - DevOps in Mobile Games
DevOpsCon 2015 - DevOps in Mobile GamesAndreas Katzig
 
Choosing your Game Engine (2009)
Choosing your Game Engine (2009)Choosing your Game Engine (2009)
Choosing your Game Engine (2009)Mark DeLoura
 
Solving the Database Problem
Solving the Database ProblemSolving the Database Problem
Solving the Database ProblemJay Gordon
 
Debugging a .NET program after crash (Post-mortem debugging)
Debugging a .NET program after crash (Post-mortem debugging)Debugging a .NET program after crash (Post-mortem debugging)
Debugging a .NET program after crash (Post-mortem debugging)Mirco Vanini
 
Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...
Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...
Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...Daniel Gallego Vico
 
Begining Android Development
Begining Android DevelopmentBegining Android Development
Begining Android DevelopmentHayi Nukman
 
Dev tools rendering & memory profiling
Dev tools rendering & memory profilingDev tools rendering & memory profiling
Dev tools rendering & memory profilingOpen Academy
 
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013Máté Nádasdi
 

Ähnlich wie Of Bytes, Cycles and Battery Life (20)

Android Overview
Android OverviewAndroid Overview
Android Overview
 
Thinking cpu & memory - DroidCon Paris 18 june 2013
Thinking cpu & memory - DroidCon Paris 18 june 2013Thinking cpu & memory - DroidCon Paris 18 june 2013
Thinking cpu & memory - DroidCon Paris 18 june 2013
 
From Web to Mobile with Stage 3D
From Web to Mobile with Stage 3DFrom Web to Mobile with Stage 3D
From Web to Mobile with Stage 3D
 
Ch 2
Ch 2Ch 2
Ch 2
 
Memory management in Andoid
Memory management in AndoidMemory management in Andoid
Memory management in Andoid
 
PAC 2019 virtual Christoph NEUMÜLLER
PAC 2019 virtual Christoph NEUMÜLLERPAC 2019 virtual Christoph NEUMÜLLER
PAC 2019 virtual Christoph NEUMÜLLER
 
CNIT 128 6. Analyzing Android Applications (Part 1)
CNIT 128 6. Analyzing Android Applications (Part 1)CNIT 128 6. Analyzing Android Applications (Part 1)
CNIT 128 6. Analyzing Android Applications (Part 1)
 
You suck at Memory Analysis
You suck at Memory AnalysisYou suck at Memory Analysis
You suck at Memory Analysis
 
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
 
Android : Deep dive into developing MobileApp using Android
Android : Deep dive into developing MobileApp using AndroidAndroid : Deep dive into developing MobileApp using Android
Android : Deep dive into developing MobileApp using Android
 
"Automated Malware Analysis" de Gabriel Negreira Barbosa, Malware Research an...
"Automated Malware Analysis" de Gabriel Negreira Barbosa, Malware Research an..."Automated Malware Analysis" de Gabriel Negreira Barbosa, Malware Research an...
"Automated Malware Analysis" de Gabriel Negreira Barbosa, Malware Research an...
 
Mobile operating systems - Application Benchmarking
Mobile operating systems - Application BenchmarkingMobile operating systems - Application Benchmarking
Mobile operating systems - Application Benchmarking
 
DevOpsCon 2015 - DevOps in Mobile Games
DevOpsCon 2015 - DevOps in Mobile GamesDevOpsCon 2015 - DevOps in Mobile Games
DevOpsCon 2015 - DevOps in Mobile Games
 
Choosing your Game Engine (2009)
Choosing your Game Engine (2009)Choosing your Game Engine (2009)
Choosing your Game Engine (2009)
 
Solving the Database Problem
Solving the Database ProblemSolving the Database Problem
Solving the Database Problem
 
Debugging a .NET program after crash (Post-mortem debugging)
Debugging a .NET program after crash (Post-mortem debugging)Debugging a .NET program after crash (Post-mortem debugging)
Debugging a .NET program after crash (Post-mortem debugging)
 
Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...
Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...
Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...
 
Begining Android Development
Begining Android DevelopmentBegining Android Development
Begining Android Development
 
Dev tools rendering & memory profiling
Dev tools rendering & memory profilingDev tools rendering & memory profiling
Dev tools rendering & memory profiling
 
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
 

Kürzlich hochgeladen

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Kürzlich hochgeladen (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

Of Bytes, Cycles and Battery Life

  • 1. Of Bytes, Cycles and Battery Life
  • 3. What i‘ll talk about • How to reduce your APK size • Memory Analysis Tools • Performance Analysis Tools
  • 4. How to reduce your APK size • Reduce asset size – pngcrush your PNGs [3] – SVG (YMMV) [4] – lower bit-rates for audio • Reduce code size – Remove unnecessary dependencies! – Proguard, for Class files [5] [6] – Dexguard, for Dex files [7]
  • 5. „But i can‘t reduce my APK size“ • Multiple-APKs to the „rescue“ [8] – – – – One APK per screen density One APK per texture compression algorithm Use Google Play filters Easier with new Android Gradle build system • APK Expansion files [9] – hosted by Google • Roll your own „Expansion files“ – Avoid if you can!
  • 6. Memory Analysis Tools • „But we have a Garbage Collector!“ – You can still „leak“ memory – Nasty static vars referencing unused objects – Hidden object references – Native memory allocated by Java classes • If you write games, GC kills your steady framerate
  • 9. HPROF/Eclipse MAT [11] • • • • Select the process Click Save to a location of your choice Convert to „real“ HPROF file • Open in Eclipse MAT [12]
  • 13. Performance Analysis Tools • Why do we want to analyse? – Jerky animations – Do less, conserve battery – Better user Experience • What do we want to analyse? – Time spent in Java code – Time spent in Native code – Time spent drawing stuff
  • 14. Before we start... • Never use the emulator! – Ever, think of the kittens • Identify hotspots in your app, not in microbenchmarks • Only spend time if you have a real problem
  • 15. Java Profilers • DDMS – Quite capable method level profiler – Good enough for 99% of use cases – Works with any Android version • 4.1+ Profiling tools – Systrace [13], More powerful, also tracks OS calls • Needs root and Android 4.1+ – We‘ll check out the graphical parts later
  • 16. DDMS • • • • Start app Navigate to problematic activity, hit Wait a bit, hit View profiling data – Ignore absolute time, only care for relative timings – Ignore trivial getters/setters, instrumentation messes with timings
  • 17. DDMS
  • 18. Native Code Profilers • Android NDK Profiler [14] – Not an official NDK tool – Setup a bit involved • Device specific CPU profilers – NVIDIA Nsight [15], ... • Roll your own – Instrument manually – Track down hotspots
  • 19. Graphics Profilers • What do we analyse? – Overdraw, your biggest enemy – Draw calls, your second biggest enemy • Use DDMS/systrace – Related to memory • Textures on VRAM (which is usually RAM) • Bitmaps in RAM
  • 20. Graphics Profilers • 4.1+ Profiling tools • GPU Vendor Specific – NVIDIA [16], Qualcomm [17], Imagination Technologies [18] – Outside of scope of this talk
  • 22. Visualize Overdraw • • • • • Normal Color – 0 Overdraw Blue – 1x Overdraw Green – 2x Overdraw Light Red – 3x Overdraw Dark Red – +4x Overdraw
  • 23. Visualize Overdraw • Hierarchy View [20] • Window -> Open Perspective -> Other...
  • 25. Visualize Overdraw • • • • • Tracer for OpenGL [21] Window -> Open Perspective -> Other ... Click Enter package name Wait
  • 28. Closing Words • So much to tell, so little time • See Dalvik Performance Tips [22] • Read all references – Your users will thank you for excellent battery life and buttery smooth UIs
  • 30. References [1] http://www.amazon.com/Beginning-Android-Games-Mario-Zechner/dp/1430246774 [2] http://libgdx.badlogicgames.com/ [3] http://pmt.sourceforge.net/pngcrush/ [4] https://code.google.com/p/svg-android/ [5] http://developer.android.com/tools/help/proguard.html [6] http://proguard.sourceforge.net/index.html [7] http://www.saikoa.com/dexguard [8] http://developer.android.com/google/play/publishing/multiple-apks.html [9] http://developer.android.com/google/play/expansion-files.html [10] http://developer.android.com/tools/debugging/ddms.html [11] http://android-developers.blogspot.co.at/2011/03/memory-analysis-for-android.html
  • 31. References [12] http://www.eclipse.org/mat/ [13] http://developer.android.com/tools/help/systrace.html [14] https://code.google.com/p/android-ndk-profiler/ [15] http://www.nvidia.com/object/nsight.html [16] https://developer.nvidia.com/tegra-profiler [17] https://developer.qualcomm.com/mobile-development/mobile-technologies/gaming-graphics-optimization-adreno/toolsand-resources [18] http://www.imgtec.com/powervr/insider/sdkdownloads/ [19] http://www.curious-creature.org/2012/12/01/android-performance-case-study/ [20] http://developer.android.com/tools/debugging/debugging-ui.html [21] http://developer.android.com/tools/help/gltracer.html [22] http://developer.android.com/training/articles/perf-tips.html