1 / 31

Of Bytes, Cycles and Battery Life

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 p ngcrush your PNGs [3]

yana
Télécharger la présentation

Of Bytes, Cycles and Battery Life

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Of Bytes, CyclesandBattery Life

  2. Who am I? [2] [1] @badlogicgames http://www.badlogicgames.com

  3. Whati‘lltalkabout • Howtoreduceyour APK size • Memory Analysis Tools • Performance Analysis Tools

  4. Howtoreduceyour APK size • Reduceassetsize • pngcrushyour PNGs [3] • SVG (YMMV) [4] • lower bit-rates foraudio • Reducecodesize • Remove unnecessarydependencies! • Proguard, for Class files [5] [6] • Dexguard, forDexfiles [7]

  5. „But i can‘treducemy APK size“ • Multiple-APKs tothe „rescue“ [8] • One APK per screendensity • One APK per texturecompressionalgorithm • Use Google Play filters • EasierwithnewAndroidGradlebuildsystem • APK Expansion files [9] • hostedby Google • Roll yourown „Expansion files“ • Avoidifyoucan!

  6. Memory Analysis Tools • „But wehave a GarbageCollector!“ • Youcan still „leak“ memory • Nastystaticvarsreferencingunusedobjects • Hidden objectreferences • Native memoryallocatedby Java classes • Ifyouwritegames, GC killsyoursteady framerate

  7. DDMS [10] Heap View

  8. DDMS AllocationTracker

  9. HPROF/Eclipse MAT [11] • Select theprocess • Click • Save to a locationofyourchoice • Convertto „real“ HPROF file • Open in Eclipse MAT [12]

  10. HPROF/Eclipse MAT

  11. HPROF/Eclipse MAT

  12. HPROF/Eclipse MAT

  13. Performance Analysis Tools • Why do wewanttoanalyse? • Jerkyanimations • Do less, conservebattery • Betteruser Experience • What do wewanttoanalyse? • Time spent in Java code • Time spent in Native code • Time spentdrawingstuff

  14. Beforewestart... • Never usetheemulator! • Ever, thinkofthekittens • Identifyhotspots in yourapp, not in microbenchmarks • Onlyspend time ifyouhave a real problem

  15. Java Profilers • DDMS • Quitecapablemethodlevelprofiler • Goodenoughfor 99% ofusecases • Works withanyAndroidversion • 4.1+ Profilingtools • Systrace [13], More powerful, also tracks OS calls • Needs rootandAndroid 4.1+ • We‘llcheck out thegraphicalpartslater

  16. DDMS • Start app • Navigatetoproblematicactivity, hit • Wait a bit, hit • View profilingdata • Ignore absolute time, onlycarefor relative timings • Ignore trivial getters/setters, instrumentationmesseswithtimings

  17. DDMS

  18. Native Code Profilers • Android NDK Profiler [14] • Not an official NDK tool • Setup a bitinvolved • Device specific CPU profilers • NVIDIA Nsight [15], ... • Roll yourown • Instrument manually • Track down hotspots

  19. Graphics Profilers • What do weanalyse? • Overdraw, yourbiggestenemy • Draw calls, yoursecondbiggestenemy • Use DDMS/systrace • Relatedtomemory • Textures on VRAM (whichisusually RAM) • Bitmaps in RAM

  20. Graphics Profilers • 4.1+ Profilingtools • GPU VendorSpecific • NVIDIA [16], Qualcomm [17], Imagination Technologies [18] • Outside ofscopeofthistalk

  21. VisualizeOverdraw [19]

  22. VisualizeOverdraw • Normal Color – 0 Overdraw • Blue – 1x Overdraw • Green – 2x Overdraw • Light Red– 3x Overdraw • Dark Red– +4x Overdraw

  23. VisualizeOverdraw • Hierarchy View [20] • Window -> Open Perspective -> Other...

  24. VisualizeOverdraw

  25. VisualizeOverdraw • Tracer for OpenGL [21] • Window -> Open Perspective -> Other ... • Click • Enterpackagename • Wait

  26. VisualizeOverdraw

  27. VisualizeOverdraw

  28. Closing Words • So muchtotell, so little time • See Dalvik Performance Tips [22] • Read all references • Yourusers will thankyouforexcellentbatterylifeandbuttery smooth UIs

  29. FIN Thanksfor Listening Questions?

  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/tools-and-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

More Related