Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Performance Testing Tools in Android - DevConf

Performance Testing Tools in Android - DevConf

Developing an app for the fragmented Android ecosystem can be a difficult task. Problems such as small amounts of RAM or low performance GPUs on some devices makes the job of an Android developer a difficult one. In this talk, we will discuss various tools (and how to use them) to ensure your app isn’t slow or dropping frames. Enabling your app to run smoothly across a larger set of devices.

Rebecca Franks

March 08, 2016
Tweet

More Decks by Rebecca Franks

Other Decks in Technology

Transcript

  1. @riggaroo #DevConf Overview • What went wrong? • Types of

    Performance Issues • Analysing Performance issues • Pixel Pushin’ (Rendering Analysis) • Where did I put that object again? (Memory Analysis) • Does not Compute (Compute Analysis) • Battery Drain (Battery Analysis)
  2. @riggaroo #DevConf OutOfMemoryError (OOM) java.lang.OutOfMemoryError: Failed to allocate a 4308492

    byte allocation with 467872 free bytes and 456KB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609) at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java: 988) at android.content.res.Resources.loadDrawableForCookie(Resources.java:2580) at android.content.res.Resources.loadDrawable(Resources.java:2487) at android.content.res.Resources.getDrawable(Resources.java:814) at android.content.res.Resources.getDrawable(Resources.java:767)
  3. @riggaroo #DevConf GPU Overdraw • Colour coding to show how

    many times each pixel is redrawn on the screen • Used for: • Reducing rendering overhead. 1x Overdraw 2x Overdraw 3x Overdraw 4x Overdraw
  4. @riggaroo #DevConf Hierarchy Viewer • Visualises your app’s view hierarchy

    • Profiles rendering speed • Good for: • Simplifying view hierarchy • Finding rendering performance bottlenecks
  5. @riggaroo #DevConf Profile GPU Rendering • Quick visual representation of

    how much time it takes to render the frames of a UI window • 16-ms-per-frame benchmark. • Good for: • Quickly seeing how a UI window performs against the 16-ms-per- frame target. • Looking for spikes in frame rendering time
  6. @riggaroo #DevConf Memory Monitor • Real time report on how

    much memory your app is using • Shows available memory & GC Events • Good for: • Quickly picking up OOM • If slowness is related to many GC Events
  7. @riggaroo #DevConf Heap Viewer • Real-time what types of objects

    your app has allocated, how many, their sizes on the heap • Eclipse Memory Analyser has a few more advanced features • Good for: • Identifying memory leaks • Seeing how your app allocates & deallocates memory
  8. @riggaroo #DevConf Avoiding memory leaks in Android • Never store

    a Context or View in a static variable. • Avoid non-static inner class declarations especially AsyncTasks/Threads • Don’t store strong references to Activity/View in your AsyncTasks or background threads • Always unregister listeners in the onPause() or onDestroy() methods
  9. @riggaroo #DevConf Systrace • Captures & displays execution times of

    your application processes • Useful for diagnosing display issues when: • Slow to draw • Stutters during animation • App is keeping to 60fps
  10. @riggaroo #DevConf NimbleDroid • Automated performance analysis tool • Easy

    to use - upload your APK and get a report • Measures cold start time • https://nimbledroid.com
  11. @riggaroo #DevConf Battery Historian • Collects battery data (batterystats) from

    device & converts into HTML visualisation • Good For: • Showing where and how processes are drawing current from the battery • Identifying tasks that can be deferred or removed • https://github.com/google/battery-historian • adb bugreport > logs.txt
  12. @riggaroo #DevConf Avoiding Battery Drain •Avoid wake locks if possible

    •Defer operations that are not important •Batch operations to reduce mobile radio usage •Take advantage of the OS - JobScheduler API, SyncAdapter
  13. @riggaroo #DevConf Conclusion • Lots of other tools available: Network

    monitor, CPU monitor, TraceView, Allocation Tracker • Use ProGuard to strip out unused code (shrinkResources & minifyEnabled) • Your users matter (especially the ones with low end devices) • Fast App = Happy Users = Good Reviews = Happy devs!
  14. @riggaroo #DevConf Links • GPU Overdraw - http://developer.android.com/tools/performance/debug-gpu-overdraw/ index.html •

    Hierarchy Viewer - http://developer.android.com/tools/performance/hierarchy- viewer/index.html • GL Tracer - http://developer.android.com/tools/help/gltracer.html • Memory Monitor - http://developer.android.com/tools/performance/memory-monitor/ index.html • Fixing Memory leaks - http://riggaroo.co.za/fixing-memory-leaks-in-android- outofmemoryerror/ • Heap Viewer - http://developer.android.com/tools/performance/heap-viewer/ index.html • Systrace - http://developer.android.com/tools/help/systrace.html • NimbleDroid - https://nimbledroid.com/ • Battery Historian - https://github.com/google/battery-historian