Designing for Performance
Designing for Performance
An Android application should be fast. Well, it's probably more accurate to say that it should be efficient. That is, it should execute as efficiently as possible in the mobile device environment, with its limited computing power and data storage, smaller screen, and constrained battery life.
As you develop your application, keep in mind that, while the application may perform well enough in your emulator, running on your dual-core development computer, it will not perform that well when run a mobile device — even the most powerful mobile device can't match the capabilities of a typical desktop system. For that reason, you should strive to write efficient code, to ensure the best possible performance on a variety of mobile devices.
Generally speaking, writing fast or efficient code means keeping memory allocations to a minimum, writing tight code, and avoiding certain language and programming idioms that can subtly cripple performance. In object-oriented terms, most of this work takes place at the method level, on the order of actual lines of code, loops, and so on.
This document covers these topics:
As you develop your application, keep in mind that, while the application may perform well enough in your emulator, running on your dual-core development computer, it will not perform that well when run a mobile device — even the most powerful mobile device can't match the capabilities of a typical desktop system. For that reason, you should strive to write efficient code, to ensure the best possible performance on a variety of mobile devices.
Generally speaking, writing fast or efficient code means keeping memory allocations to a minimum, writing tight code, and avoiding certain language and programming idioms that can subtly cripple performance. In object-oriented terms, most of this work takes place at the method level, on the order of actual lines of code, loops, and so on.
This document covers these topics:
- Introduction
- Avoid Creating Objects
- Use Native Methods
- Prefer Virtual Over Interface
- Prefer Static Over Virtual
- Avoid Internal Getters/Setters
- Cache Field Lookups
- Declare Constants Final
- Use Enhanced For Loop Syntax With Caution
- Avoid Enums
- Use Package Scope with Inner Classes
- Avoid Float
- Some Sample Performance Numbers
- Closing Notes
Comments
Post a Comment
Please post comments here:-)