I have considered some application optimization issues in IM applications.
The optimization focuses on Power Optimization and traffic optimization:
How to test power consumption by optimizing Power Consumption (front-end power consumption and back-end power consumption)
1. dedicated devices
2. Performance-related apps
3. Manually write Power Consumption
Power Optimization
1. Do not affect sleep of mobile phones
Heartbeat packet starting from alarm Manager
2. Minimize network requests
Data cache, local storage, synchronous incremental, send multiple requests at a time
3. Less GPS positioning, Network Positioning preferred
4. Optimize different network types
The download speed of the mobile network is higher than the upload speed; the data packet sent at a time of 2 GB is not too large; the 3g4g 4G sends multiple data packets at a time, which saves power.
Upload buffer size: 2G 1024 bytes, 3G 10 K
Download buffer size: 2G 1024 bytes, 3G 30 K
For other optimizations, refer to the official website.
How to test traffic Optimization
Uid = process. myuid ();
Initrecvbytes = trafficstats. getuidrxbytes (UID );
Initsendbytes = trafficstats. getuidtxbytes (UID );
Traffic Optimization
1. heartbeat
Reduce heartbeat Packet
Reduce sending frequency
Intelligent heartbeat and dynamic heartbeat time
2. Packet Protocol
Customize the packet Protocol to reduce the packet size.
3. Abnormal reconnection Mechanism
Dynamic reconnection Mechanism
4. Compression
File compression
Used compression algorithm: Gzip
Message Optimization
Every important message must be returned to the server.
Im application optimization