Android Performance Tip

Posted on:November 04 2012

When developing high performance code for android there are already a lot of tips on the web to use. One thing I learned today: Don't believe other people's suggestions on performance if you haven't tried it out yourself. One common misconception I came across multiple times for example is that it is a negligible trade-off when you use ArrayList instead of a real, Java array. For me, this wasn't true. Replacing an ArrayList with the Java array at performance critical parts of my code resulted in an overall 20% speed increase! I think one reason for this also might be that I used arrays of primitive types. When they are in the ArrayList, each type again is wrapped in a wrapper type (like 'Integer' for 'int'), probably also causing an additional impact. So yes, arrays are faster than ArrayList. Sometimes.





Comments:


Interesting I have actually found both Array List and Java Array to be faster in certain circumstances also.
Justin
Quote
2012-11-05 06:00:00


A native array of primitive types will always be faster than an ArrayList, no matter what. This might or might not apply to reference types, but for primitive types it's a simple consequence of Java's retarded type system. It always requires boxing/unboxing in this case, so it can't be as fast as a native array.
Michi
Quote
2012-11-08 19:38:00


Add comment:


Posted by:


Enter the missing letter in: "Inter?ational"


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons