Top Banner
Performance myths in Android Javier Gamarra / @nhpatt
74

Performance myths in android

Apr 16, 2017

Download

Technology

Javier Gamarra
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Performance myths in android

Performance myths in AndroidJavier Gamarra / @nhpatt

Page 2: Performance myths in android

“Why is this important?”

Page 3: Performance myths in android

“Please try again soon!”

Page 4: Performance myths in android

Performance is another feature of your app like

… login

Page 5: Performance myths in android

Performance is… CPU… memory… network… battery… smoothness

Page 6: Performance myths in android

Always measure first

Page 7: Performance myths in android

Tools!--using the right tool for the job

Page 8: Performance myths in android

Performance monitors

Page 9: Performance myths in android

Android device monitor

Page 10: Performance myths in android

GPU Overdraw

Page 11: Performance myths in android

Leak Canary

Page 12: Performance myths in android

Hierarchy view

Page 13: Performance myths in android

Allocation tracker

Page 14: Performance myths in android

Traceview

Page 15: Performance myths in android

Traceview

Page 16: Performance myths in android

GPU profiler

Page 17: Performance myths in android

HProf

Page 18: Performance myths in android

systrace

Page 19: Performance myths in android

Battery historian

Page 20: Performance myths in android

External tools (nimbledroid…)

Page 21: Performance myths in android

Use an old device

Page 22: Performance myths in android

Be pragmatic

Page 23: Performance myths in android

FACTSor

MYTHS?

Page 24: Performance myths in android

“things the communityis very passionate about”

Page 25: Performance myths in android

lots of things...

Page 26: Performance myths in android

iosched

Page 27: Performance myths in android

“Own” methods

Without games and not counting library methods

Page 28: Performance myths in android

Methods in most popular apps

-facebook-facebook chat-twitter

Page 29: Performance myths in android

1 DATABASES

Page 30: Performance myths in android
Page 31: Performance myths in android
Page 32: Performance myths in android

Record actual performance“Write” Espresso tests

Rewrite database “layer”Measure time to finish

Check allocation trackerCheck traceview

Page 33: Performance myths in android

Use Case 1 (first use)

4,18MB78,8% parsing2,5 TV seconds8,8 seconds

Page 34: Performance myths in android

Use case 2 (remotely)

4,23MB13% drawing1,64 TV seconds4,28 seconds

Page 35: Performance myths in android

Use case 3 (normal)

4,83MB13% drawing2,54 TV seconds4,82 seconds

Page 36: Performance myths in android
Page 37: Performance myths in android

“Realm objects can only be accessed on the thread they were created”

Page 38: Performance myths in android
Page 39: Performance myths in android

0’0%

Page 40: Performance myths in android
Page 42: Performance myths in android

Do NOT choose an ORM because performance

Page 43: Performance myths in android

I'll take something 10-20% slower that offers better APIs for the very reason that you'll never get close to the limits -- Jake

Page 44: Performance myths in android

2

DI FRAMEWORKS

Page 45: Performance myths in android

How slow is reflection?

Page 46: Performance myths in android

... pretty much when done a lot700 ms to NYTimes660 ms to photobucket

...like JSON/XML parsing

Page 47: Performance myths in android

And in DI frameworks?

Page 49: Performance myths in android

“Roboguice would (...) be (...) a mere 5 times [slower] compared to Dagger”

Page 51: Performance myths in android

3

REACTIVE LIBRARIES

Page 52: Performance myths in android

<BS> about lazyness

Page 53: Performance myths in android

Shakespeare plays scrabble

Page 54: Performance myths in android

Range

Page 56: Performance myths in android

= 8x slower to iterate

Page 57: Performance myths in android

4PART04

MICRO OPTIMIZATIONS

Page 58: Performance myths in android

Enums-- like 285 bytes lost

Page 59: Performance myths in android

“If you use integer constants instead of enums in your Android app you are a fool” --Jake Wharton

Page 60: Performance myths in android

We use enums regularly because they are safer than Strings or ints and their performance downsides are minimal --instagram

Page 61: Performance myths in android

OnClickListeners?

Page 62: Performance myths in android

How much costs to iterate between 1M likes?

Page 63: Performance myths in android

300 ms

30 MB

Page 64: Performance myths in android

JSON parsingNetwork requests

Page 65: Performance myths in android

LASTWORDS

Page 66: Performance myths in android

Things I like/UI

● Flat layout hierarchy

● Merge tags

● Optimized bitmaps

● Inexistent alpha

Page 67: Performance myths in android

Things I like/code

● WeakReferences

● Caches

● FlatBuffers

● Developer Efficiency

Page 68: Performance myths in android

“Do the simple thing first… and optimize what matters”

Page 69: Performance myths in android

Ok, dagger/rx/ORM is slow but does it matter to you?

Page 70: Performance myths in android

?QUESTIONS?@nhpatt / twitter

gmailgithub...

Page 71: Performance myths in android

THANKS

Page 73: Performance myths in android

“If you care more about performance

than correctness why using a computer

at all?”

I can give you the wrong answer faster

than any machine ;) -- Mario Fusco

Page 74: Performance myths in android

Performance myths in AndroidJavier Gamarra / @nhpatt