● Object creation ● String manipulation ○ timestamp -> human time ○ like count, comment count ○ image path ● Log ● Autoboxing, unboxing (Integer vs int)
Drawing ● Keep the view hierarchy flat ○ faster measure ○ careful about 2 pass measure layout ■ RelativeLayout ■ LinearLayout with weight ● Over draw ● All-in-one vs separate view for each type
GPU profiling ● Draw is the time spent building display lists in Java. It indicates how much time is spent running methods such as View.onDraw(Canvas). ● Process is the time spent by Android’s 2D renderer to execute the display lists. The more Views in your hierarchy, the more drawing commands must be executed. ● Execute is the time it took to send a frame to the compositor. This part of the graph is usually small. ● Reminder: to render smoothly at 60 fps, each frame must take less than 16 ms to complete. http://www.curious-creature.org/2012/12/01/android-performance-case-study/
onScroll ● Infinite scroll ● Pre download images ○ file.exists() ? ● Add rate limit for heavy tasks ● Dont notifyDataSetChanged during scroll ○ dont append data during scroll
GC ● Pause the system a few/many ms ● cause lag when scrolling ● cant do anything about it ● Work around? ○ call System.gc() when idle ○ System.gc() - Note that this is a hint only. There is no guarantee that the garbage collector will actually be run.