Write in front:
Test together, Bo Master contact is also fur, have not touched the ROM test, the bottom is that bloggers have been exposed to the performance test of the app. I'll just talk about methods and less about concepts. The great God does not like to spray.
Overview
In addition to the startup time, we should do a test that may need to verify the performance of the app in several states. The specific business form may also be more complex, depending on the specific business to decide what kind of test to do.
1, the app idle state.
2, the app normal use status.
3, the state of the app under pressure (normal fast operation).
4, Monkey (random) operating conditions of performance.
1. Start-Up time
Start-up time generally we will test three cases.
• First Boot
• Non-first boot
activity time spent in switching
Test methods are generally used in two ways:
1), the program internal to Logcat, manual operation to obtain log log, to obtain the corresponding time.
2), using the ADB command to operate, before and after the operation to record the time consumed. (This method is not very accurate because the ADB operation may be delayed, etc.)
PS. There is also a way to tell the camera by the way to do, because I have not contacted, do not do too much to explain, interested can self-check how to do.
2, CPU and memory
1), Get CPU data
adb Shell Dumpsys Cpuinfo | grep $package _name
The output format is;
45% total:18% user + 20% kernel + 6.2% iowait + 0.2% SOFTIRQ
The total value is preferable as the overall CPU utilization.
2), Get memory data
adb Shell Dumpsys Meminfo | grep $package _name or adb shell Dumpsys meminfo $package _name
Directly Dumpsys meminfo $package _name can see more complete heap, thread, Java and other levels of memory data, PSS can be used as memory reference.
3), using top to obtain both CPU and memory, the-D parameter specifies the time between sampling data.
ADB Shell top-d 2
Output:
PID PR CPU% S #THR VSS RSS PCY UID Name
Noun Explanation:
- VSS-Virtual Set Size virtualized memory consumption (contains memory consumed by shared libraries)
- RSS-resident Set Size actually uses physical memory (contains memory consumed by shared libraries)
- PSS-Proportional Set Size actual physical memory used (proportional allocation of memory consumed by shared libraries)
- USS-Unique Set Size process consumes physical memory alone (does not contain memory consumed by shared libraries)
In general, memory footprint has the following rules: VSS >= RSS >= PSS >= USS
As you can see, the top command takes out the memory corresponding to VSS and RSS, where RSS is slightly larger than PSS, and if there are no particularly stringent requirements, just compare the memory leaks up and other issues, RSS can also be used as a reference.
3. Flow rate
1), grab the packet through tcpdump, and then wireshark the packet information to get the traffic data.
2), through the ADB command to obtain, first obtain the application of the PID, and then through the/proc/uid_stat/uid/file to read the traffic value. This way there will be ROM compatibility issues, not all files can find these two files.
adb shell Dumpsys $package _nameadb Shell cat/proc/uid_stat/uid/tcp_rcv --Download traffic adb shell CAT/PROC/UID_STAT/UID/TCP_ SND --upload traffic
Because of TCP_RCV, the value of TCP_SND is a cumulative value, want to get two operations between the traffic consumed, can be obtained before and after the operation, the difference is the amount of traffic consumed during the period. You can also sample each period of time to obtain the entire process of use.
4. Frame rate
The frame rate is somewhat responsive to how smoothly the app is in use, ideally 60 frames per second.
1), in the developer options, there is a "GPU Rendering mode analysis (profile GPU rendering, calculating the rendering time in the ADB shell Dumpsys gfxinfo)" function, after you turn on this function, The system records the time information that retains the last 128 frames of the image drawn for each interface. After you turn on this feature, restart the app, swipe the page, and then execute the ADB command.
adb shell Dumpsys gfxinfo $package _name
This part of the data is included in the output result
Draw Process Execute1.30 1.25 0.53
0.63 0.62 1.64
0.24 0.51 0.44
0.25 1.76 0.40
0.25 1.55 0.43
0.25 0.53 0.37
0.49 1.51 2.12
Draw: Represents the time taken by the OnDraw () method in the Create Display list section in Java.
Process: Indicates the time spent by the rendering engine to execute a display list, and the longer the view is, the more time it takes.
Execute: Represents the amount of time spent in sending a frame of data to a screen layout. It is actually the time when the background buffers that actually display the frame data are exchanged with the foreground buffer and the contents of the foreground buffer are displayed to the screen.
Draw + Process + Execute = Full display of one frame, this time is less than 16ms to save 60 frames per second.
2), through the Surfaceflinger, this way has not been studied, over time to add
ADB Shell Dumpsys Surfaceflinger
5. Power
There is no particularly good way to test battery power, and you can choose to use a physical device to test the battery status.
For Android 5.0 or more systems, the ADB command can support the acquisition of battery power information.
adb shell Dumpsys Battery
The output reads as follows:
AC powered:false USB powered:true Wireless powered:false status:1 #电池状态: 2: Charging status, other numbers for non-charging status Health:2 present:true level:55 #电量: Percent scale:100 voltage:3977 Current now :-335232 temperature:335 #电池状态 technology:li-poly
If USB is used to connect the phone, (the phone is always in the state of charging), so the test data will not be very accurate.
If you have any good ways, we can discuss it together.
Android Performance Test