Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities.
This paper has participated inProject DigginTo win the creative gift package and challenge the creative incentive money.
preface
We have studied the memory in The Performance test index of Android APP, and have a certain understanding of the concepts such as memory leakage and memory overflow.
Memory refers to running memory (RAM), not device storage (ROM). Although our equipment is constantly improving, storage is still a scarce resource.
Android is a multi-task system. In order to ensure that multiple application processes can run stably at the same time, Android limits the dalvik heap memory available to each application process.
This means that normally your app cannot use unlimited memory, and exceeding this limit will result in OOM. How big the memory limit is is not fixed.
Specific decision is made by the manufacturer, APP can not control, the earliest 16M. It depends on the memory capacity of the device and the size of the device’s screen (the larger the screen, the more memory is used when displaying higher-resolution images).
Therefore, the memory resources of mobile devices are not enough to satisfy all the graduates.
There is also a device resource in the device resource as well as memory, CPU, so in this installment we will continue to look at CPU metrics in performance testing.
1. Summary of the CPU
What is a CPU?
CPU Central Processing Unit (CPU) is the computing and control core of a computer system. It is the final execution Unit for information Processing and program running.
The CPU is the computing and control core of the computer, through which all the actions performed in the device are controlled. It acts as the brain center in our body.
Why focus on CPU management?
- CPU is a proportional limit on the amount of time a process takes
- When running a multitasking system, the limited CPU needs to be allocated properly
- Poor CPU management will affect the efficiency of program execution, operation delay, slow response, and even crash
Key notes:
- The performance improvement brought by multi-core is not the multiple of a simple CPU core, because it is affected by the shared resources between multiple cores. For example, dual-core performance is only 1.4 to 1.8 times that of single-core.
2. The CPU architecture
In embedded systems, there are many CPU architectures, such as ARM, MIPS, Coldfire/ 68K, PowerPC, X86, PIC, Intel 8051, Atmel AVR, Renesas H8, SH, V850, M32R, DMCU
Different cpus support different instruction sets, so the actual impact on the project:
-
After the CPU architecture was changed, all system modules and applications dependent on the system had to be retested throughout the project.
-
SO library: Applications with SO library need to achieve the corresponding SO library for each CPU architecture, which cannot be universal;
How does CPU affect system performance?
- The code execution efficiency is affected and the load is too high, resulting in performance bottlenecks
- As a result, the system is slow to perform operations, ANR, or even the system freezes
When we play a video in the device, the following Mosaic will appear in the video playing screen when we operate the mouse
🌟 Relationship between process priorities and cpus: A process with a higher priority is more likely to be executed by the CPU
3. CPU specifications
-
User time
- Represents the percentage of CPU time spent on user processes. A high value of user time is a good state in which the system is performing real tasks.
-
System time
- Represents the percentage of CPU time spent on kernel operations. Consistently high system time can indicate network and driver stack bottlenecks.
- The system should spend as little time as possible on kernel time;
-
Waiting time
- Total time the CPU spends waiting for AN I/O operation
- The system should not spend a lot of time waiting for IO operations, or you should investigate the performance of the IO subsystem
-
Idle time
- Represents the time ratio of the system waiting tasks in space;
4. Scenario with high CPU load
- Application of animation, graphics rendering and processing;
- Apply multi-thread long polling;
- Bluetooth search for nearby devices;
… Etc. Application of high load code execution scenarios;
5. CPU data acquisition method
- Checking the CPU Temperature
adb shell cat "/sys/class/thermal/thermal_zone7/temp"
Copy the code
- Check whether the type is CPU
adb shell cat "/sys/class/thermal/thermal_zone7/type"
Copy the code
- Displays the top 10 applications that occupy the largest NUMBER of cpus
adb shell top -m 10
Copy the code
- Viewing CPU Information
adb shell dumpsys cpuinfo
Copy the code
conclusion
In this issue, we have analyzed the important CPU indicators of performance testing APP. In practical work, there are many tools that can provide us with visual data display, among which perfDog of Tencent is more popular, Jmeter and Loadrunner are commonly used in the industry
That’s the content of this episode. Please give us your thumbs up and comments. See you next time