Of bytes cycles and battery life
This presentation is the property of its rightful owner.
Sponsored Links
1 / 31

Of Bytes, Cycles and Battery Life PowerPoint PPT Presentation


  • 43 Views
  • Uploaded on
  • Presentation posted in: General

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]

Download Presentation

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Of bytes cycles and battery life

Of Bytes, CyclesandBattery Life


Who am i

Who am I?

[2]

[1]

@badlogicgames

http://www.badlogicgames.com


What i ll talk about

Whati‘lltalkabout

  • Howtoreduceyour APK size

  • Memory Analysis Tools

  • Performance Analysis Tools


How to reduce your apk size

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]


But i can t reduce my apk size

„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!


Memory analysis tools

Memory Analysis Tools

  • „But wehave a GarbageCollector!“

    • Youcan still „leak“ memory

    • Nastystaticvarsreferencingunusedobjects

    • Hidden objectreferences

    • Native memoryallocatedby Java classes

  • Ifyouwritegames, GC killsyoursteady framerate


Ddms 10 heap view

DDMS [10] Heap View


Ddms allocation tracker

DDMS AllocationTracker


Hprof eclipse mat 11

HPROF/Eclipse MAT [11]

  • Select theprocess

  • Click

  • Save to a locationofyourchoice

  • Convertto „real“ HPROF file

  • Open in Eclipse MAT [12]


Hprof eclipse mat

HPROF/Eclipse MAT


Hprof eclipse mat1

HPROF/Eclipse MAT


Hprof eclipse mat2

HPROF/Eclipse MAT


Performance analysis tools

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


Before we start

Beforewestart...

  • Never usetheemulator!

    • Ever, thinkofthekittens

  • Identifyhotspots in yourapp, not in microbenchmarks

  • Onlyspend time ifyouhave a real problem


Java profilers

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


Of bytes cycles and battery life

DDMS

  • Start app

  • Navigatetoproblematicactivity, hit

  • Wait a bit, hit

  • View profilingdata

    • Ignore absolute time, onlycarefor relative timings

    • Ignore trivial getters/setters, instrumentationmesseswithtimings


Of bytes cycles and battery life

DDMS


Native code profilers

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


Graphics profilers

Graphics Profilers

  • What do weanalyse?

    • Overdraw, yourbiggestenemy

    • Draw calls, yoursecondbiggestenemy

      • Use DDMS/systrace

    • Relatedtomemory

      • Textures on VRAM (whichisusually RAM)

      • Bitmaps in RAM


Graphics profilers1

Graphics Profilers

  • 4.1+ Profilingtools

  • GPU VendorSpecific

    • NVIDIA [16], Qualcomm [17], Imagination Technologies [18]

    • Outside ofscopeofthistalk


Visualize overdraw 19

VisualizeOverdraw [19]


Visualize overdraw

VisualizeOverdraw

  • Normal Color – 0 Overdraw

  • Blue – 1x Overdraw

  • Green – 2x Overdraw

  • Light Red– 3x Overdraw

  • Dark Red– +4x Overdraw


Visualize overdraw1

VisualizeOverdraw

  • Hierarchy View [20]

  • Window -> Open Perspective -> Other...


Visualize overdraw2

VisualizeOverdraw


Visualize overdraw3

VisualizeOverdraw

  • Tracer for OpenGL [21]

  • Window -> Open Perspective -> Other ...

  • Click

  • Enterpackagename

  • Wait


Visualize overdraw4

VisualizeOverdraw


Visualize overdraw5

VisualizeOverdraw


Closing words

Closing Words

  • So muchtotell, so little time

  • See Dalvik Performance Tips [22]

  • Read all references

    • Yourusers will thankyouforexcellentbatterylifeandbuttery smooth UIs


Of bytes cycles and battery life

FIN

Thanksfor Listening

Questions?


References

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


References1

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


  • Login