SlideShare a Scribd company logo
Tuning Android
 Applications
    (part deux)


    Copyright © 2011 CommonsWare, LLC
What I'll Be Yammering About
●   You Missed It
    –   Traceview
    –   MAT
●   Now
    –   Battery and Bandwidth
    –   Top Ten Tuning Tips


                      Copyright © 2011 CommonsWare, LLC
Bandwidth &
  Battery
Measurement
   Copyright © 2011 CommonsWare, LLC
Bandwidth Issues
●   Too Much In General
    –   Users on metered plans pay through the nose
    –   Users on “unlimited” plans hit the, um, limits
●   Too Much At Poor Times
    –   While the user is trying to use bandwidth for
        other purposes (e.g., streaming video)
    –   When the user is on mobile data instead of WiFi

                       Copyright © 2011 CommonsWare, LLC
Measuring Bandwidth
●   Option #1: Find an App
    –   Bandwidth Monitor
    –   Traffic Monitor
    –   Network Traffic Detail
    –   Etc.




                      Copyright © 2011 CommonsWare, LLC
Measuring Bandwidth
●   Option #2: TrafficStats
    –   Static methods to report bandwidth
        consumption to date
         ●   Entire device, all networks
         ●   Entire device, by network (mobile data vs. WiFi)
         ●   Per UID (all, TCP vs. UDP)
    –   Transmit (Tx) vs. Receive (Rx)
    –   Bytes vs. Segments vs. Packets
                           Copyright © 2011 CommonsWare, LLC
Measuring Bandwidth
●   Option #1: TrafficStats
    –   Take snapshots at points in time
         ●   Delta between values = consumed bandwidth
    –   Two Integration Styles
         ●   In test suites, to determine if your mitigation
             strategies are working
         ●   In production, for traffic shaping


                           Copyright © 2011 CommonsWare, LLC
Measuring Bandwidth
●   Option #2: ICS Settings
    –   Chart of bandwidth consumed
    –   Ability to see per-application and set limits
    –   Downside: hardware only?




                       Copyright © 2011 CommonsWare, LLC
Measuring Bandwidth
●   Option #3: Wireshark
    –   Requires rooted device or integration at WiFi
        access point
    –   Gives you full logs of all activity
         ●   Determine not only how much bandwidth, but what
             it is being used for




                         Copyright © 2011 CommonsWare, LLC
Issues with Battery
●   You Get Blamed
    –   Your app shows up on the battery consumption
        Settings screen, users get irritated
●   You Want to be Friendly
    –   Dynamically adjust your behavior to deal with
        low battery conditions



                      Copyright © 2011 CommonsWare, LLC
Measuring Power Usage
●   Qualcomm MDP and Trepn
    –   Pros
         ●   Highly detailed information, down to the component
             and process
         ●   Graphs (on-device) and logs (for offline analysis)
    –   Cons
         ●   Trepn only works on Qualcomm MDP
         ●   MDP is frakkin' expensive (~$1,400)

                           Copyright © 2011 CommonsWare, LLC
Measuring Power Usage
●   PowerTutor
    –   Pros
         ●   Free!
    –   Cons
         ●   Accuracy so-so for Nexus One, worse for other
             modern devices
         ●   No logging


                          Copyright © 2011 CommonsWare, LLC
Measuring Power Usage
●   Settings' Battery “Blame Screen”
    –   If you don't show up here, how bad can it be?
●   adb shell dumpsys batteryinfo
    –   Tons of data
    –   Difficult to grok




                       Copyright © 2011 CommonsWare, LLC
Top Ten Tuning
     Tips
              (totally)




    Copyright © 2011 CommonsWare, LLC
Measure, Measure, Measure
●   Don't Start Hacking Away
    –   Example: randomly removing accessor methods
●   Identify Problem Area First
    –   What is too slow, or leaking, or whatever?
●   Cure What Ails Ya
    –   Premature optimization helps nobody


                      Copyright © 2011 CommonsWare, LLC
Recycling: It's Good for the “Urf!”
●   Adapter View Recycling
    –   Rows in lists
    –   Pages in ViewPager
●   Bitmaps
    –   If it has a recycle() method, use it!




                        Copyright © 2011 CommonsWare, LLC
Activities Stay Active
●   Activities Not Destroyed to Free Heap Space
    –   BACK button, finish(), configuration change
    –   Process termination (may not call
        onDestroy())
●   Mitigation Strategies
    –   Activity recycling
    –   Time-based belt-tightening

                       Copyright © 2011 CommonsWare, LLC
Threads: More Than a Panacea, But...
●   The Good
    –   Move stuff off the main application thread
●   The Bad
    –   Most devices in use still single core
    –   Threads consume more CPU time
●   The Ugly
    –   Thrashing among too many threads
                       Copyright © 2011 CommonsWare, LLC
Robbing Peter to Pay Paul
●   Threads
●   Caching
    –   Trading off RAM to save disk I/O, or CPU time, or
        bandwidth
    –   Trading off disk space to save bandwidth, or CPU
        time
    –   Ensure you don't trade too much (whack-a-mole)

                      Copyright © 2011 CommonsWare, LLC
Hardware Is Real. Really Real.
●   Emulator Is Slower At...
    –   CPU
●   Emulator Is Faster At...
    –   Disk I/O
    –   Network (usually, compared to wireless data)
●   Net: Test on Hardware Too


                      Copyright © 2011 CommonsWare, LLC
Globals, Processes, and Cavemen
●   Global Scope: Risk of Memory Leaks
    –   Tempting as central holding spot for data
    –   Reason why considered bad form in standard
        Java development
●   Extra Processes: Just Say No!
    –   Usually add no value
    –   Consume extra RAM, CPU time

                      Copyright © 2011 CommonsWare, LLC
YAGNI
●   You Ain't Gonna Need It
    –   Downloading and caching data that might not
        get used
    –   Fancy plug-in architecture for an app with no
        plug-ins
●   Constrained Devices Need Constrained Plans


                      Copyright © 2011 CommonsWare, LLC
Don't Be Chatty
●   JNI/NDK
    –   Each context switch from Java to C/C++ (and
        back) adds overhead
●   IPC
    –   Every call between processes adds overhead
    –   Includes sendBroadcast()!
●   Aim For Coarse-Grained Protocols

                      Copyright © 2011 CommonsWare, LLC
Lather. Rinse. Repeat.
●   Keep Testing and Tuning
    –   Major application releases
    –   Major OS releases
         ●   Example: rumored AsyncTask thread pool shrinkage
    –   Major device style releases
         ●   Example: multi-core



                          Copyright © 2011 CommonsWare, LLC

More Related Content

Viewers also liked

Predictions Sure To Go Wrong (droidcon UK 2011)
Predictions Sure To Go Wrong (droidcon UK 2011)Predictions Sure To Go Wrong (droidcon UK 2011)
Predictions Sure To Go Wrong (droidcon UK 2011)
CommonsWare
 
Tuning Android Applications (Part One)
Tuning Android Applications (Part One)Tuning Android Applications (Part One)
Tuning Android Applications (Part One)
CommonsWare
 
Mastering the Master Detail Pattern
Mastering the Master Detail PatternMastering the Master Detail Pattern
Mastering the Master Detail Pattern
CommonsWare
 
When Microwatts Are Precious: Battery Tips for Wearable Apps
When Microwatts Are Precious: Battery Tips for Wearable AppsWhen Microwatts Are Precious: Battery Tips for Wearable Apps
When Microwatts Are Precious: Battery Tips for Wearable Apps
CommonsWare
 
Getting Android Developers for Your Wearables
Getting Android Developers for Your WearablesGetting Android Developers for Your Wearables
Getting Android Developers for Your Wearables
CommonsWare
 
Gradle and Your Android Wearable Projects
Gradle and Your Android Wearable ProjectsGradle and Your Android Wearable Projects
Gradle and Your Android Wearable Projects
CommonsWare
 
Android Security: Defending Your Users
Android Security: Defending Your UsersAndroid Security: Defending Your Users
Android Security: Defending Your Users
CommonsWare
 

Viewers also liked (7)

Predictions Sure To Go Wrong (droidcon UK 2011)
Predictions Sure To Go Wrong (droidcon UK 2011)Predictions Sure To Go Wrong (droidcon UK 2011)
Predictions Sure To Go Wrong (droidcon UK 2011)
 
Tuning Android Applications (Part One)
Tuning Android Applications (Part One)Tuning Android Applications (Part One)
Tuning Android Applications (Part One)
 
Mastering the Master Detail Pattern
Mastering the Master Detail PatternMastering the Master Detail Pattern
Mastering the Master Detail Pattern
 
When Microwatts Are Precious: Battery Tips for Wearable Apps
When Microwatts Are Precious: Battery Tips for Wearable AppsWhen Microwatts Are Precious: Battery Tips for Wearable Apps
When Microwatts Are Precious: Battery Tips for Wearable Apps
 
Getting Android Developers for Your Wearables
Getting Android Developers for Your WearablesGetting Android Developers for Your Wearables
Getting Android Developers for Your Wearables
 
Gradle and Your Android Wearable Projects
Gradle and Your Android Wearable ProjectsGradle and Your Android Wearable Projects
Gradle and Your Android Wearable Projects
 
Android Security: Defending Your Users
Android Security: Defending Your UsersAndroid Security: Defending Your Users
Android Security: Defending Your Users
 

Similar to Tuning Android Applications (Part Deux)

Engg chapter one which shows that how it works
Engg chapter one which shows that how it worksEngg chapter one which shows that how it works
Engg chapter one which shows that how it works
Rahul_urunkar
 
Emc new1
Emc new1Emc new1
DataCore Technology Overview
DataCore Technology OverviewDataCore Technology Overview
DataCore Technology Overview
Jeff Slapp
 
Exposing and Fixing Common App Performance Problems
Exposing and Fixing Common App Performance ProblemsExposing and Fixing Common App Performance Problems
Exposing and Fixing Common App Performance Problems
Riverbed Technology
 
Designing Scalable Applications
Designing Scalable ApplicationsDesigning Scalable Applications
Designing Scalable Applications
Fabricio Epaminondas
 
Simplifying debugging for multi-core Linux devices and low-power Linux clusters
Simplifying debugging for multi-core Linux devices and low-power Linux clusters Simplifying debugging for multi-core Linux devices and low-power Linux clusters
Simplifying debugging for multi-core Linux devices and low-power Linux clusters
Rogue Wave Software
 
Beyond Traditional Mobile Testing
Beyond Traditional Mobile TestingBeyond Traditional Mobile Testing
Beyond Traditional Mobile Testing
ColomboCampsCommunity
 
Performance Testing in a Mobile World
Performance Testing in a Mobile WorldPerformance Testing in a Mobile World
Performance Testing in a Mobile World
stuartmoncrieff
 
JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)
jaxLondonConference
 
Debugging Apache Hadoop YARN Cluster in Production
Debugging Apache Hadoop YARN Cluster in ProductionDebugging Apache Hadoop YARN Cluster in Production
Debugging Apache Hadoop YARN Cluster in Production
Xuan Gong
 
X Means Y
X Means YX Means Y
X Means Y
CommonsWare
 
Mobile Performance Testing - Testing the Server
Mobile Performance Testing  - Testing the ServerMobile Performance Testing  - Testing the Server
Mobile Performance Testing - Testing the Server
XBOSoft
 
ch1.pdfsystem programiming for engineeering in gct coimbator4e
ch1.pdfsystem programiming for engineeering in gct  coimbator4ech1.pdfsystem programiming for engineeering in gct  coimbator4e
ch1.pdfsystem programiming for engineeering in gct coimbator4e
EsakyS
 
Ch1
Ch1Ch1
Zero Downtime JEE Architectures
Zero Downtime JEE ArchitecturesZero Downtime JEE Architectures
Zero Downtime JEE Architectures
Alexander Penev
 
Open_IoT_Summit-Europe-2016-Building_a_Drone_from_scratch
Open_IoT_Summit-Europe-2016-Building_a_Drone_from_scratchOpen_IoT_Summit-Europe-2016-Building_a_Drone_from_scratch
Open_IoT_Summit-Europe-2016-Building_a_Drone_from_scratch
Igor Stoppa
 
ch1_OS_india_notes_india_good Help_book.pptx
ch1_OS_india_notes_india_good Help_book.pptxch1_OS_india_notes_india_good Help_book.pptx
ch1_OS_india_notes_india_good Help_book.pptx
megadata3
 
The Java Evolution Mismatch by Gil Tene, CTO at Azul Systems
The Java Evolution Mismatch by Gil Tene, CTO at Azul SystemsThe Java Evolution Mismatch by Gil Tene, CTO at Azul Systems
The Java Evolution Mismatch by Gil Tene, CTO at Azul Systems
zuluJDK
 
ch1.ppt
ch1.pptch1.ppt
HIT3328 - Chapter01 - Platforms and Devices
HIT3328 - Chapter01 - Platforms and DevicesHIT3328 - Chapter01 - Platforms and Devices
HIT3328 - Chapter01 - Platforms and Devices
Yhal Htet Aung
 

Similar to Tuning Android Applications (Part Deux) (20)

Engg chapter one which shows that how it works
Engg chapter one which shows that how it worksEngg chapter one which shows that how it works
Engg chapter one which shows that how it works
 
Emc new1
Emc new1Emc new1
Emc new1
 
DataCore Technology Overview
DataCore Technology OverviewDataCore Technology Overview
DataCore Technology Overview
 
Exposing and Fixing Common App Performance Problems
Exposing and Fixing Common App Performance ProblemsExposing and Fixing Common App Performance Problems
Exposing and Fixing Common App Performance Problems
 
Designing Scalable Applications
Designing Scalable ApplicationsDesigning Scalable Applications
Designing Scalable Applications
 
Simplifying debugging for multi-core Linux devices and low-power Linux clusters
Simplifying debugging for multi-core Linux devices and low-power Linux clusters Simplifying debugging for multi-core Linux devices and low-power Linux clusters
Simplifying debugging for multi-core Linux devices and low-power Linux clusters
 
Beyond Traditional Mobile Testing
Beyond Traditional Mobile TestingBeyond Traditional Mobile Testing
Beyond Traditional Mobile Testing
 
Performance Testing in a Mobile World
Performance Testing in a Mobile WorldPerformance Testing in a Mobile World
Performance Testing in a Mobile World
 
JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)
 
Debugging Apache Hadoop YARN Cluster in Production
Debugging Apache Hadoop YARN Cluster in ProductionDebugging Apache Hadoop YARN Cluster in Production
Debugging Apache Hadoop YARN Cluster in Production
 
X Means Y
X Means YX Means Y
X Means Y
 
Mobile Performance Testing - Testing the Server
Mobile Performance Testing  - Testing the ServerMobile Performance Testing  - Testing the Server
Mobile Performance Testing - Testing the Server
 
ch1.pdfsystem programiming for engineeering in gct coimbator4e
ch1.pdfsystem programiming for engineeering in gct  coimbator4ech1.pdfsystem programiming for engineeering in gct  coimbator4e
ch1.pdfsystem programiming for engineeering in gct coimbator4e
 
Ch1
Ch1Ch1
Ch1
 
Zero Downtime JEE Architectures
Zero Downtime JEE ArchitecturesZero Downtime JEE Architectures
Zero Downtime JEE Architectures
 
Open_IoT_Summit-Europe-2016-Building_a_Drone_from_scratch
Open_IoT_Summit-Europe-2016-Building_a_Drone_from_scratchOpen_IoT_Summit-Europe-2016-Building_a_Drone_from_scratch
Open_IoT_Summit-Europe-2016-Building_a_Drone_from_scratch
 
ch1_OS_india_notes_india_good Help_book.pptx
ch1_OS_india_notes_india_good Help_book.pptxch1_OS_india_notes_india_good Help_book.pptx
ch1_OS_india_notes_india_good Help_book.pptx
 
The Java Evolution Mismatch by Gil Tene, CTO at Azul Systems
The Java Evolution Mismatch by Gil Tene, CTO at Azul SystemsThe Java Evolution Mismatch by Gil Tene, CTO at Azul Systems
The Java Evolution Mismatch by Gil Tene, CTO at Azul Systems
 
ch1.ppt
ch1.pptch1.ppt
ch1.ppt
 
HIT3328 - Chapter01 - Platforms and Devices
HIT3328 - Chapter01 - Platforms and DevicesHIT3328 - Chapter01 - Platforms and Devices
HIT3328 - Chapter01 - Platforms and Devices
 

More from CommonsWare

The Action Bar: Front to Back
The Action Bar: Front to BackThe Action Bar: Front to Back
The Action Bar: Front to Back
CommonsWare
 
Secondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManagerSecondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManager
CommonsWare
 
Not Quite As Painful Threading
Not Quite As Painful ThreadingNot Quite As Painful Threading
Not Quite As Painful Threading
CommonsWare
 
Android Development: The 20,000-Foot View
Android Development: The 20,000-Foot ViewAndroid Development: The 20,000-Foot View
Android Development: The 20,000-Foot View
CommonsWare
 
Maps V2... And You!
Maps V2... And You!Maps V2... And You!
Maps V2... And You!
CommonsWare
 
A Deep Dive Into ViewPager
A Deep Dive Into ViewPagerA Deep Dive Into ViewPager
A Deep Dive Into ViewPager
CommonsWare
 
Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2
CommonsWare
 
Integrate Android Apps and Web Apps
Integrate Android Apps and Web AppsIntegrate Android Apps and Web Apps
Integrate Android Apps and Web Apps
CommonsWare
 
From Android to the Mobile Web
From Android to the Mobile WebFrom Android to the Mobile Web
From Android to the Mobile Web
CommonsWare
 
The Wonderful World of Wearables
The Wonderful World of WearablesThe Wonderful World of Wearables
The Wonderful World of Wearables
CommonsWare
 
Securing User Data with SQLCipher
Securing User Data with SQLCipherSecuring User Data with SQLCipher
Securing User Data with SQLCipher
CommonsWare
 
Beaming Data to Devices with NFC
Beaming Data to Devices with NFCBeaming Data to Devices with NFC
Beaming Data to Devices with NFC
CommonsWare
 
What's New in Jelly Bean
What's New in Jelly BeanWhat's New in Jelly Bean
What's New in Jelly Bean
CommonsWare
 
Making Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business ModelsMaking Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business Models
CommonsWare
 
AppsWorld Keynote
AppsWorld KeynoteAppsWorld Keynote
AppsWorld Keynote
CommonsWare
 
App Integration (Revised and Updated)
App Integration (Revised and Updated)App Integration (Revised and Updated)
App Integration (Revised and Updated)
CommonsWare
 
Rich Text Editing and Beyond
Rich Text Editing and BeyondRich Text Editing and Beyond
Rich Text Editing and Beyond
CommonsWare
 
App integration: Strategies and Tactics
App integration: Strategies and TacticsApp integration: Strategies and Tactics
App integration: Strategies and Tactics
CommonsWare
 
Backwards Compatibility: Strategies and Tactics
Backwards Compatibility: Strategies and TacticsBackwards Compatibility: Strategies and Tactics
Backwards Compatibility: Strategies and Tactics
CommonsWare
 
Android Hardware That's A Little Bit... Odd
Android Hardware That's A Little Bit... OddAndroid Hardware That's A Little Bit... Odd
Android Hardware That's A Little Bit... Odd
CommonsWare
 

More from CommonsWare (20)

The Action Bar: Front to Back
The Action Bar: Front to BackThe Action Bar: Front to Back
The Action Bar: Front to Back
 
Secondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManagerSecondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManager
 
Not Quite As Painful Threading
Not Quite As Painful ThreadingNot Quite As Painful Threading
Not Quite As Painful Threading
 
Android Development: The 20,000-Foot View
Android Development: The 20,000-Foot ViewAndroid Development: The 20,000-Foot View
Android Development: The 20,000-Foot View
 
Maps V2... And You!
Maps V2... And You!Maps V2... And You!
Maps V2... And You!
 
A Deep Dive Into ViewPager
A Deep Dive Into ViewPagerA Deep Dive Into ViewPager
A Deep Dive Into ViewPager
 
Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2
 
Integrate Android Apps and Web Apps
Integrate Android Apps and Web AppsIntegrate Android Apps and Web Apps
Integrate Android Apps and Web Apps
 
From Android to the Mobile Web
From Android to the Mobile WebFrom Android to the Mobile Web
From Android to the Mobile Web
 
The Wonderful World of Wearables
The Wonderful World of WearablesThe Wonderful World of Wearables
The Wonderful World of Wearables
 
Securing User Data with SQLCipher
Securing User Data with SQLCipherSecuring User Data with SQLCipher
Securing User Data with SQLCipher
 
Beaming Data to Devices with NFC
Beaming Data to Devices with NFCBeaming Data to Devices with NFC
Beaming Data to Devices with NFC
 
What's New in Jelly Bean
What's New in Jelly BeanWhat's New in Jelly Bean
What's New in Jelly Bean
 
Making Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business ModelsMaking Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business Models
 
AppsWorld Keynote
AppsWorld KeynoteAppsWorld Keynote
AppsWorld Keynote
 
App Integration (Revised and Updated)
App Integration (Revised and Updated)App Integration (Revised and Updated)
App Integration (Revised and Updated)
 
Rich Text Editing and Beyond
Rich Text Editing and BeyondRich Text Editing and Beyond
Rich Text Editing and Beyond
 
App integration: Strategies and Tactics
App integration: Strategies and TacticsApp integration: Strategies and Tactics
App integration: Strategies and Tactics
 
Backwards Compatibility: Strategies and Tactics
Backwards Compatibility: Strategies and TacticsBackwards Compatibility: Strategies and Tactics
Backwards Compatibility: Strategies and Tactics
 
Android Hardware That's A Little Bit... Odd
Android Hardware That's A Little Bit... OddAndroid Hardware That's A Little Bit... Odd
Android Hardware That's A Little Bit... Odd
 

Recently uploaded

Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 

Recently uploaded (20)

Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 

Tuning Android Applications (Part Deux)

  • 1. Tuning Android Applications (part deux) Copyright © 2011 CommonsWare, LLC
  • 2. What I'll Be Yammering About ● You Missed It – Traceview – MAT ● Now – Battery and Bandwidth – Top Ten Tuning Tips Copyright © 2011 CommonsWare, LLC
  • 3. Bandwidth & Battery Measurement Copyright © 2011 CommonsWare, LLC
  • 4. Bandwidth Issues ● Too Much In General – Users on metered plans pay through the nose – Users on “unlimited” plans hit the, um, limits ● Too Much At Poor Times – While the user is trying to use bandwidth for other purposes (e.g., streaming video) – When the user is on mobile data instead of WiFi Copyright © 2011 CommonsWare, LLC
  • 5. Measuring Bandwidth ● Option #1: Find an App – Bandwidth Monitor – Traffic Monitor – Network Traffic Detail – Etc. Copyright © 2011 CommonsWare, LLC
  • 6. Measuring Bandwidth ● Option #2: TrafficStats – Static methods to report bandwidth consumption to date ● Entire device, all networks ● Entire device, by network (mobile data vs. WiFi) ● Per UID (all, TCP vs. UDP) – Transmit (Tx) vs. Receive (Rx) – Bytes vs. Segments vs. Packets Copyright © 2011 CommonsWare, LLC
  • 7. Measuring Bandwidth ● Option #1: TrafficStats – Take snapshots at points in time ● Delta between values = consumed bandwidth – Two Integration Styles ● In test suites, to determine if your mitigation strategies are working ● In production, for traffic shaping Copyright © 2011 CommonsWare, LLC
  • 8. Measuring Bandwidth ● Option #2: ICS Settings – Chart of bandwidth consumed – Ability to see per-application and set limits – Downside: hardware only? Copyright © 2011 CommonsWare, LLC
  • 9. Measuring Bandwidth ● Option #3: Wireshark – Requires rooted device or integration at WiFi access point – Gives you full logs of all activity ● Determine not only how much bandwidth, but what it is being used for Copyright © 2011 CommonsWare, LLC
  • 10. Issues with Battery ● You Get Blamed – Your app shows up on the battery consumption Settings screen, users get irritated ● You Want to be Friendly – Dynamically adjust your behavior to deal with low battery conditions Copyright © 2011 CommonsWare, LLC
  • 11. Measuring Power Usage ● Qualcomm MDP and Trepn – Pros ● Highly detailed information, down to the component and process ● Graphs (on-device) and logs (for offline analysis) – Cons ● Trepn only works on Qualcomm MDP ● MDP is frakkin' expensive (~$1,400) Copyright © 2011 CommonsWare, LLC
  • 12. Measuring Power Usage ● PowerTutor – Pros ● Free! – Cons ● Accuracy so-so for Nexus One, worse for other modern devices ● No logging Copyright © 2011 CommonsWare, LLC
  • 13. Measuring Power Usage ● Settings' Battery “Blame Screen” – If you don't show up here, how bad can it be? ● adb shell dumpsys batteryinfo – Tons of data – Difficult to grok Copyright © 2011 CommonsWare, LLC
  • 14. Top Ten Tuning Tips (totally) Copyright © 2011 CommonsWare, LLC
  • 15. Measure, Measure, Measure ● Don't Start Hacking Away – Example: randomly removing accessor methods ● Identify Problem Area First – What is too slow, or leaking, or whatever? ● Cure What Ails Ya – Premature optimization helps nobody Copyright © 2011 CommonsWare, LLC
  • 16. Recycling: It's Good for the “Urf!” ● Adapter View Recycling – Rows in lists – Pages in ViewPager ● Bitmaps – If it has a recycle() method, use it! Copyright © 2011 CommonsWare, LLC
  • 17. Activities Stay Active ● Activities Not Destroyed to Free Heap Space – BACK button, finish(), configuration change – Process termination (may not call onDestroy()) ● Mitigation Strategies – Activity recycling – Time-based belt-tightening Copyright © 2011 CommonsWare, LLC
  • 18. Threads: More Than a Panacea, But... ● The Good – Move stuff off the main application thread ● The Bad – Most devices in use still single core – Threads consume more CPU time ● The Ugly – Thrashing among too many threads Copyright © 2011 CommonsWare, LLC
  • 19. Robbing Peter to Pay Paul ● Threads ● Caching – Trading off RAM to save disk I/O, or CPU time, or bandwidth – Trading off disk space to save bandwidth, or CPU time – Ensure you don't trade too much (whack-a-mole) Copyright © 2011 CommonsWare, LLC
  • 20. Hardware Is Real. Really Real. ● Emulator Is Slower At... – CPU ● Emulator Is Faster At... – Disk I/O – Network (usually, compared to wireless data) ● Net: Test on Hardware Too Copyright © 2011 CommonsWare, LLC
  • 21. Globals, Processes, and Cavemen ● Global Scope: Risk of Memory Leaks – Tempting as central holding spot for data – Reason why considered bad form in standard Java development ● Extra Processes: Just Say No! – Usually add no value – Consume extra RAM, CPU time Copyright © 2011 CommonsWare, LLC
  • 22. YAGNI ● You Ain't Gonna Need It – Downloading and caching data that might not get used – Fancy plug-in architecture for an app with no plug-ins ● Constrained Devices Need Constrained Plans Copyright © 2011 CommonsWare, LLC
  • 23. Don't Be Chatty ● JNI/NDK – Each context switch from Java to C/C++ (and back) adds overhead ● IPC – Every call between processes adds overhead – Includes sendBroadcast()! ● Aim For Coarse-Grained Protocols Copyright © 2011 CommonsWare, LLC
  • 24. Lather. Rinse. Repeat. ● Keep Testing and Tuning – Major application releases – Major OS releases ● Example: rumored AsyncTask thread pool shrinkage – Major device style releases ● Example: multi-core Copyright © 2011 CommonsWare, LLC