Common:
1. optimized the cycle. Re-organize repeated subexpressions to improve the running performance of the loop body.
2. Reduce the number of objects used to improve the running performance.
3. reduce network transmission data to shorten the wait time.
Others:
1. The object pool technology is used to improve the utilization efficiency of objects.
The loss of performance is mainly caused by the creation and release of objects. Therefore, the creation and release of objects must be avoided. The object pool technology is used to pre-define an object pool and create a group of objects to be used first:
Enemy [5] Enemy = new enemy [5];
For (INT I = 0; I <5; I ++ ){
Enemy [I] = new enemy ();
}
Add a flag such as used and reset to identify the enemy status. To create an object, obtain an unused object from the object pool and initialize it using the reset method. to release an object, you only need to modify the flag for the next use. Java object pool technology: http://www.cnblogs.com/devinzhang/archive/2012/01/05/2313406.html
2. Try to replace the object with the basic data type
For example, a two-dimensional array is used to replace a simple object.
3. OptimizationAlgorithm
For example, scenarios and algorithms that do not require fine-grained writing are simulated using simple algorithms.
4. Other Optimizations
A. When extracting a string, try to return the substring instead of creating a copy.
B. Try to create as few temporary objects as possible.
C. If you can use a library function, do not create it yourself (the library function is optimized)
D. Map map = new hashmap ();
Hashmap map = new hashmap (); // higher performance, refactoringCode
E. When using the enhanced for loop and iterable, you need to create an object with caution.
F. Avoid the enum type.
G. Pay attention to floating point usage during embedded development. (Whether the processor supports floating point)
H. Compression of image resources, adding multiple image sets to one image (much smaller than individual and smaller, saving data blocks such as each header file and ending file, and combining the color palette)