WO2019024804A1 - Cpu监测方法、计算机可读存储介质和移动终端 - Google Patents

Cpu监测方法、计算机可读存储介质和移动终端 Download PDF

Info

Publication number
WO2019024804A1
WO2019024804A1 PCT/CN2018/097535 CN2018097535W WO2019024804A1 WO 2019024804 A1 WO2019024804 A1 WO 2019024804A1 CN 2018097535 W CN2018097535 W CN 2018097535W WO 2019024804 A1 WO2019024804 A1 WO 2019024804A1
Authority
WO
WIPO (PCT)
Prior art keywords
cpu usage
application
cpu
difference
mobile terminal
Prior art date
Application number
PCT/CN2018/097535
Other languages
English (en)
French (fr)
Inventor
王彬
张俊
帅朝春
Original Assignee
Oppo广东移动通信有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Oppo广东移动通信有限公司 filed Critical Oppo广东移动通信有限公司
Publication of WO2019024804A1 publication Critical patent/WO2019024804A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3024Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a central processing unit [CPU]

Definitions

  • the intelligent mobile terminal system program running and the third-party application running need to consume the system resources of the smart mobile terminal.
  • the system resources of the smart mobile terminal are consumed in a large amount, the operating efficiency of the smart mobile terminal is affected.
  • a CPU monitoring method, a non-transitory computer readable storage medium, and a mobile terminal are provided in accordance with various embodiments of the present application.
  • a CPU monitoring method includes:
  • the current system CPU usage is used as the first CPU usage
  • the CPU usage of the system is continuously obtained according to the preset first time interval.
  • the CPU usage of the system is not less than the duration of the first CPU usage exceeds the specified duration, the CPU usage of each application is obtained.
  • One or more non-transitory computer readable storage media containing computer executable instructions that, when executed by one or more processors, cause the processor to:
  • the current system CPU usage is used as the first CPU usage
  • the CPU usage of the system is continuously obtained according to the preset first time interval.
  • the CPU usage of the system is not less than the duration of the first CPU usage exceeds the specified duration, the CPU usage of each application is obtained.
  • a mobile terminal includes a memory and a processor, wherein the memory stores computer readable instructions, and when the instructions are executed by the processor, the processor performs the following operations:
  • the current system CPU usage is used as the first CPU usage
  • the CPU usage of the system is continuously obtained according to the preset first time interval.
  • the CPU usage of the system is not less than the duration of the first CPU usage exceeds the specified duration, the CPU usage of each application is obtained.
  • the CPU usage of the system is obtained according to the preset first time interval, when the difference between the current system CPU usage and the system CPU usage of the first-time interval exceeds the specified value, the current system CPU usage is taken as the first.
  • the system CPU usage when the difference between the current system CPU usage and the system CPU usage of the first-time interval exceeds the specified value, the system CPU usage is continuously obtained according to the preset first time interval.
  • the usage rate is not less than the duration of the first CPU usage exceeds the specified duration, the CPU usage of each application is obtained.
  • the CPU usage of the application can be obtained in time, which is beneficial to monitoring the application.
  • FIG. 1 is an internal structural diagram of a mobile terminal in an embodiment
  • FIG. 2 is a flow chart of a CPU monitoring method in an embodiment
  • FIG. 3 is a flow chart of a CPU monitoring method in another embodiment
  • FIG. 5 is a flow chart of a CPU monitoring method in another embodiment
  • FIG. 6 is a flow chart of a CPU monitoring method in another embodiment
  • FIG. 7 is a flow chart of a CPU monitoring method in another embodiment
  • Figure 8 is a block diagram showing the structure of a CPU monitoring device in an embodiment
  • FIG. 9 is a block diagram showing the structure of a CPU monitoring device in another embodiment.
  • FIG. 10 is a block diagram showing the structure of a CPU monitoring device in another embodiment
  • FIG. 11 is a block diagram showing the structure of a CPU monitoring device in another embodiment
  • FIG. 12 is a block diagram showing a partial structure of a mobile phone related to a mobile terminal provided by an embodiment of the present application.
  • first, second and the like may be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another.
  • the first acquisition module may be referred to as a second acquisition module without departing from the scope of the present application, and similarly, the second acquisition module may be referred to as a first acquisition module. Both the first acquisition module and the second acquisition module are acquisition modules, but they are not the same acquisition module.
  • FIG. 1 is a schematic diagram showing the internal structure of a mobile terminal in an embodiment.
  • the mobile terminal includes a processor connected through a system bus, a non-volatile storage medium, an internal memory, a network interface, a display screen, and an input device.
  • the non-volatile storage medium of the mobile terminal stores an operating system and computer readable instructions.
  • the computer readable instructions are executed by a processor to implement a CPU monitoring method.
  • the processor is used to provide computing and control capabilities to support the operation of the entire mobile terminal.
  • the internal memory in the mobile terminal provides an environment for the operation of computer readable instructions in a non-volatile storage medium.
  • the network interface is used for network communication with the server.
  • the display screen of the mobile terminal may be a liquid crystal display or an electronic ink display screen.
  • the input device may be a touch layer covered on the display screen, or may be a button, a trackball or a touchpad provided on the casing of the mobile terminal, or may be An external keyboard, trackpad, or mouse.
  • the mobile terminal can be a mobile phone, a tablet or a personal digital assistant or a wearable device.
  • FIG. 1 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation of the mobile terminal to which the solution of the present application is applied.
  • the specific mobile terminal may It includes more or fewer components than those shown in the figures, or some components are combined, or have different component arrangements.
  • a CPU monitoring method includes operations 202 through 206. among them:
  • the system CPU usage rate is obtained according to the preset first time interval.
  • the CPU usage of the mobile terminal system is the CPU resource occupied by all programs running in the mobile terminal, including the system running program and the third-party running program. Generally, the higher the CPU usage of the system, the more programs run in the mobile terminal; the lower the CPU usage of the system, the fewer programs run in the mobile terminal.
  • the mobile terminal can obtain the system CPU usage rate according to the preset first time interval.
  • the preset first time interval can be a time interval set by the user, or can be a time interval obtained according to the historical collection time.
  • the operation of the mobile terminal to obtain the CPU usage of the system may include: the mobile terminal collects the accumulated working time of the CPU of the system according to the preset first time interval, and obtains the cumulative working time of the CPU collected twice consecutively, and the accumulated working time of the CPU and the previous CPU.
  • the difference between the accumulated working hours, the difference is the time when the system CPU actually works in the preset first time interval, and the ratio of the difference to the preset first time interval is the preset first time interval.
  • the cumulative working time of the above CPU is the total duration of the CPU operation from the start of the mobile terminal to the current time.
  • the preset first time interval may be any one of 5 seconds to 20 seconds, such as 5 seconds.
  • the mobile terminal collects the cumulative working time of the system CPU every 5 seconds. When the accumulated CPUs of the two consecutive acquisitions are 60 minutes 03 seconds and 60 minutes 04 seconds respectively, the system CPU is occupied in the 5 seconds.
  • the rate is 20%.
  • system CPU related information can be read in the /proc directory.
  • the stat file in the /proc directory contains all the information about the CPU activity of the system. All the information about the CPU activity of the above system is the cumulative duration of the CPU activity from the start of the mobile terminal to the current time.
  • the CPU monitoring module in the mobile terminal can periodically read the system CPU activity information in the /proc directory, and then obtain the system CPU usage rate of the mobile terminal during the collection time.
  • the mobile terminal After obtaining the CPU usage of the current system, the mobile terminal compares the CPU usage of the current system with the CPU usage of the system at the first interval, and obtains the difference in CPU usage of the system. When the difference in CPU usage of the system exceeds the specified value, it is determined that the CPU usage of the mobile terminal system changes greatly, and the CPU usage of the system in the mobile terminal is abnormal.
  • the above specified value is set to a positive number, which can be any number from 15% to 20%, such as 20%.
  • the current system CPU usage rate obtained by the mobile terminal is used as the first CPU usage rate, that is, Abnormal CPU usage.
  • the CPU usage of the system is continuously obtained according to the preset first time interval, when the system CPU is occupied.
  • the rate is not less than the duration of the first CPU usage exceeds the specified duration, the CPU usage of each application is obtained.
  • the mobile terminal After obtaining the first CPU usage rate, acquires the system CPU usage rate of the mobile terminal in the preset number of times according to the preset first time interval, and compares the obtained system CPU usage rate with the first CPU usage ratio. .
  • the CPU usage of the system is not less than the first CPU usage, the CPU usage of the system is not less than the duration of the abnormal CPU usage.
  • the duration of the CPU usage exceeds the specified duration.
  • the preset first time interval may be any time between 5 seconds and 30 seconds, such as 5 seconds. For example, if the system CPU usage of the system is 20% and 40%, and the system CPU usage difference is greater than the specified value of 15%, the system CPU usage is 40% as the first CPU usage.
  • the mobile terminal collects the CPU usage of the system every 5 seconds according to the preset first time interval, and collects the CPU usage of the system for 4 times, which are 42%, 45%, 47%, 50%, respectively.
  • the rate is more than 40%, that is, the CPU usage of the mobile terminal system exceeds 40% for 20 seconds and the specified duration is 18 seconds, and the CPU usage of each application in the mobile terminal is obtained.
  • the operation of the CPU for acquiring the CPU usage of each application may include: collecting the accumulated CPU duration of each application running in the mobile terminal according to the preset second time interval, and acquiring the occupied CPU of the application that is collected twice consecutively.
  • the difference between the accumulated duration of the CPU and the accumulated duration of the CPU occupied by the previous time, the difference is the time that the application occupies the CPU in the second time interval, and the ratio of the difference to the second time interval
  • the application CPU usage is at the second time interval.
  • the first time interval and the second time interval may be the same value or different values.
  • the sats file in the /proc/pid directory contains information about the CPU occupied by the application.
  • the CPU usage information of the process corresponding to the above application is the accumulated duration of the CPU occupied by the application after being started.
  • the CPU monitoring module in the mobile terminal can periodically read the accumulated duration of the CPU occupied by each application in the /proc/pid directory, and then obtain the CPU usage of the application in the collection time of the application.
  • the CPU monitoring method in the embodiment of the present application collects the CPU usage of the system according to the preset first time interval, that is, the total CPU usage of the mobile terminal, and when the system CPU occupancy rate is detected to be greatly increased and lasts for a long time. If it is determined that the application program consumes a large amount of CPU resources in the mobile terminal, the CPU usage of the application corresponding to the currently running application in the mobile terminal is obtained. In the above method, when the total CPU of the system is rapidly increased, the CPU usage of the application program can be obtained in time, which is beneficial for monitoring the CPU usage of the application and identifying an abnormal application.
  • the CPU monitoring method before the CPU usage of each application is acquired, the CPU monitoring method further includes:
  • the mobile terminal Before acquiring the CPU usage of the application corresponding to each application, the mobile terminal searches for the time when the CPU usage of each application is obtained last time, and obtains the time difference between the current time and the time when the CPU usage of each application is obtained last time.
  • the time difference exceeds the preset first threshold, the application CPU usage is acquired.
  • the operation of obtaining the CPU usage of the application is the same as the operation of obtaining the CPU usage of the application in operation 206, and details are not described herein again.
  • the mobile terminal directly obtains the CPU usage of each application collected last time as the current CPU usage of each application.
  • the first threshold may be a value set by the user, or may be a value obtained by analyzing the CPU usage data of each application according to the history, such as 30 seconds, 1 minute, and the like.
  • the CPU usage of the application in the mobile terminal does not change in a short time, and it takes a certain amount of system resources to acquire the CPU usage of each application.
  • the CPU monitoring method of the embodiment of the present application after receiving the CPU usage request of the application corresponding to each application, the time difference between the current time and the CPU usage of the application corresponding to the previous application is obtained, and the time difference is determined.
  • the time difference is short, the CPU usage of each application obtained last time is directly used as the current CPU usage of each application.
  • the time difference is long, the CPU usage of each application is reacquired. It not only ensures the accuracy of obtaining the CPU usage of an application, but also reduces the system power consumption and saves system resources.
  • the obtaining, by the operation 202, the CPU usage of the system includes:
  • system CPU related information can be read in the /proc directory.
  • the stat file in the /proc directory contains all the information about the CPU activity of the system. All the information about the CPU activity of the above system is the cumulative duration of the CPU activity from the start of the mobile terminal to the current time.
  • the CPU monitoring module in the mobile terminal can periodically read the system CPU activity information in the /proc directory, and then obtain the system CPU usage rate of the mobile terminal during the collection time.
  • the operation of the mobile terminal to obtain the CPU usage of the system may include: the mobile terminal collects the accumulated working time of the CPU of the system according to the preset first time interval, and obtains the cumulative working time of the CPU collected twice consecutively, and the accumulated working time of the CPU and the previous CPU.
  • the difference between the accumulated working hours, the difference is the time when the system CPU actually works in the preset first time interval, and the ratio of the difference to the preset first time interval is the preset first time interval.
  • the cumulative working time of the above CPU is the total duration of the CPU operation from the start of the mobile terminal to the current time.
  • the preset first time interval may be any one of 5 seconds to 20 seconds, and preferably, may be 5 seconds.
  • the foregoing CPU monitoring method further includes:
  • the operation 402 is configured to detect whether the application meets the preset rule when detecting that the CPU usage corresponding to the application exceeds the second threshold.
  • Operation 404 when the application does not satisfy the preset rule, stop running the process corresponding to the application.
  • the mobile terminal After obtaining the CPU usage of each application, the mobile terminal compares whether the CPU usage of each application exceeds a preset second threshold, and when the preset second threshold is exceeded, the application CPU is occupied. The rate is too high to further detect whether the above application meets the preset rules.
  • the second threshold may be a value set by the user, or may be a value obtained by analyzing the CPU usage of the application obtained according to the history, and the second threshold may be 20%.
  • Preset rules include: applications in the system whitelist, applications running in the foreground, applications are performing preset behaviors (including downloading files, uploading files, application updates, etc.), higher priority applications, playing music Application, etc.
  • the above preset rules can be rules set by the user.
  • the process corresponding to stopping the running of the application includes: closing or suspending the process corresponding to the application.
  • the process corresponding to closing the application refers to killing the process corresponding to the application.
  • Suspending the process corresponding to the application refers to suspending the running of the corresponding process of the application, and adding the process corresponding to the suspended application to the waiting queue.
  • the process corresponding to the application is resumed. Running.
  • the CPU monitoring method in the embodiment of the present application detects whether the application is a non-processing application preset by the mobile terminal or a non-processing application set by the user when the CPU usage of the application is high in the mobile terminal.
  • the application corresponding to the running of the application is stopped, that is, the application with abnormal CPU usage is checked and killed, thereby avoiding a large amount of CPU resources consumed by the abnormal application in the mobile terminal, causing the mobile terminal system to be stuck. Fever and so on.
  • the preset rule can ensure that the application does not be cleaned up when the application normally consumes a large amount of CPU resources, and the accuracy of identifying the abnormal application is improved, and the abnormal application of the killing is more accurate.
  • the foregoing CPU monitoring method further includes:
  • the CPU usage level is obtained according to the CPU usage of the system.
  • the mobile terminal can be divided into multiple CPU usage levels in advance, and each occupancy level can be corresponding to different occupation rate ranges, for example, four CPU usage levels, including L1, L2, L3, and L4, wherein the occupancy rate corresponding to the L1 occupation level is The range is less than 20%, the occupancy rate of the L2 occupation level is 20% to 40%, the occupancy rate of the L3 occupation level is 40% to 60%, and the occupancy rate of the L4 occupation level is greater than 60%. Not limited to this.
  • the mobile terminal collects the CPU usage of the system according to the preset first time interval, determines the occupied range of the collected system CPU usage, and obtains the CPU occupation level corresponding to the falling occupancy rate range. For example, if the CPU usage of the collected system is 18%, the CPU usage level is L1, the system CPU usage is 25%, and the CPU usage level is L2.
  • Operation 504 the cumulative number of consecutively maintained at the occupancy level.
  • the mobile terminal can allocate a level counter for each CPU occupation level, and record the number of consecutive times that the CPU maintains the corresponding occupation level by the level counter, wherein the CPU maintains a certain occupation level, which means that the CPU is always at the occupation level or above. Occupation level. For example, if the CPU usage level changes to the L2 occupation level, the L3 occupation level, and the L2 occupation level, the CPU can be considered to maintain the L2 occupation level, and the number of consecutive times is 3.
  • the mobile terminal collects the CPU usage of the system according to the preset first time interval, and determines the CPU occupation level, and may add 1 to the level counter corresponding to the occupation level and the following occupation level, respectively, and add other
  • the level counter of the occupancy level is cleared. For example, if the CPU usage level of this time is L3, the level counters of L1, L2, and L3 are incremented by one, and the level counter of L4 is cleared. The next CPU occupancy level is L2, and the level counters of L1 and L2 are respectively Add 1, L3, L4 level counter is cleared.
  • the type of the occupancy level may be divided, where the type may include an idle level and a busy level, for example, the L1 occupation level is regarded as an idle level, and the L2, L3, and L4 occupation levels are regarded as busy levels, respectively representing different levels. Busyness.
  • the mobile terminal collects the system CPU usage rate at the preset first time interval, and calculates the CPU occupation level.
  • the corresponding type may be determined first, and then in the level counter corresponding to the occupation level of the same type and the following occupation level. Add 1 and clear the level counters of other occupancy levels. For example, if the CPU usage level of this time is L1 and belongs to the idle level, the level counter of L1 is incremented by 1, and the level counters of L2, L3, and L4 are cleared.
  • the next CPU usage level is L3, which belongs to the busy level. L3 and the level counters of L2 belonging to the busy level are incremented by 1, and the level counters of L1 and L4 are cleared.
  • a corresponding third threshold may be set for each CPU usage level, and the third threshold may be used to determine whether the CPU of the mobile terminal is maintained in the working state of the corresponding occupation level.
  • the mobile terminal accumulates the number of times that the CPU is continuously maintained at each occupied level by the level counter.
  • the CPU may be determined to be stable in the working state of the occupied level.
  • a corresponding third threshold is set to c1, c2, c3, and c4, and when the number of times that the CPU continuously maintains the L1 level reaches c1, it is determined that the CPU is stable in the working state of L1. in.
  • the third threshold corresponding to each occupied level may decrease as the occupancy level increases.
  • the third thresholds corresponding to L1, L2, L3, and L4 are c1, c2, c3, and c4, where c1 >c2>c3>c4, for example, c1 is 5 times, c2 is 4 times, c3 is 3 times, c4 is 2 times, etc., but is not limited thereto.
  • the highest level of occupation level is selected as the stable working state of the CPU.
  • the CPU monitoring method in the embodiment of the present application sets different occupation levels of the CPU usage, and determines the busyness of the mobile terminal according to the number of times of maintaining the occupation level, which is beneficial to different processing of the application according to the busy procedure of the mobile terminal. For example, when the occupancy level is high and the system is busy, the process corresponding to the abnormal application is directly closed; when the occupation level is low, when the system is idle, the process corresponding to the abnormal application is suspended, and the flexibility of processing the abnormal application is improved. .
  • the CPU monitoring method before the running of the process corresponding to the application is stopped, the CPU monitoring method further includes:
  • Operation 602 displaying the abnormal information corresponding to the application and the stop running instruction of the application on the mobile terminal interface.
  • Operation 604 when receiving the trigger operation for stopping the running instruction, stopping the process corresponding to running the application.
  • the mobile terminal may also display the abnormal information corresponding to the application on the mobile terminal interface before stopping the process corresponding to the application.
  • the abnormal information may include: the current CPU usage of the application, the current program behavior of the application (such as downloading files in the background, etc.), and the current network speed of the application.
  • a cancel instruction can also be displayed. When the trigger operation on the cancel instruction is obtained, the application is not processed; when the trigger operation on the stop operation instruction is acquired, the process corresponding to the application is stopped.
  • the CPU monitoring method displays the abnormal information corresponding to the application on the mobile terminal interface after detecting the abnormal application, and stops the running of the process corresponding to the application after receiving the stop instruction of the user, which can avoid The misuse of the application killing improves the accuracy of the application.
  • a CPU monitoring method includes operations 702 through 714. among them:
  • the system CPU usage rate is obtained according to the preset first time interval.
  • the CPU usage of the above system is as follows:
  • the operation of obtaining the CPU usage of the system is the same as the operation of obtaining the CPU usage of the system in operation 202, and details are not described herein again.
  • the first CPU usage is the abnormal occupancy rate.
  • the operation of obtaining the first CPU usage is the same as the operation of obtaining the first CPU usage in the operation 204, and details are not described herein again.
  • the CPU usage of the system is continuously obtained according to the preset first time interval, when the system CPU is occupied.
  • the rate of the first CPU usage exceeds the specified duration, the time at which the CPU usage of each application is obtained last time is searched.
  • the operation of finding the time when the CPU usage of each application is obtained last time is the same as the operation of searching for the time when the CPU usage of each application is acquired last time in the operation 302, and details are not described herein again.
  • the operation of obtaining the CPU usage of the application is the same as the operation of obtaining the CPU usage of the application in operation 206, and details are not described herein again.
  • the operation of the application that meets the preset rule is the same as the operation of the operation 402, and details are not described herein.
  • operation 712 when the application meets the preset rule, the abnormal information corresponding to the application and the stop running instruction of the application are displayed on the mobile terminal interface.
  • the trigger operation for the stop operation instruction is received, the process corresponding to the running application is stopped.
  • the operation of displaying the abnormal information corresponding to the application in the mobile terminal and the operation of stopping the running of the application are the same as those in FIG. 6 and will not be described here.
  • the process corresponding to the stop running application is the same as the corresponding operation in operation 404, and details are not described herein again.
  • the CPU usage level is obtained according to the system CPU usage.
  • the cumulative number of consecutively maintained levels of occupancy is determined.
  • the operations in the flowchart of the method of the embodiment of the present application are sequentially displayed in accordance with the indication of the arrows, but the operations are not necessarily performed in the order indicated by the arrows. Except as explicitly stated herein, the execution of these operations is not strictly limited, and may be performed in other sequences. Moreover, at least a part of the operations in the method flowchart of the embodiment of the present application may include multiple sub-operations or multiple stages, which are not necessarily performed at the same time, but may be executed at different times. The order of execution is not necessarily performed sequentially, but may be performed alternately or alternately with at least a portion of the sub-operations or phases of other operations or other operations.
  • FIG. 8 is a block diagram showing the structure of a CPU monitoring device in one embodiment.
  • a CPU monitoring apparatus includes a first obtaining module 802, a difference module 804, and a second obtaining module 806. among them:
  • the first obtaining module 802 is configured to acquire a system CPU usage rate according to a preset first time interval.
  • the difference module 804 is configured to use the current system CPU usage as the first CPU usage rate when the difference between the current system CPU usage and the system CPU usage of the first time interval exceeds a specified value.
  • the second obtaining module 806 is configured to: when detecting that the difference between the CPU usage of the current system and the CPU usage of the system in the first time interval exceeds a specified value, continuously obtain the system CPU usage according to the preset first time interval. When the CPU usage of the system is not less than the duration of the first CPU usage exceeds the specified duration, the CPU usage of each application is obtained.
  • the second obtaining module 806 is further configured to search for a time when the CPU usage of each application is obtained last time before acquiring the CPU usage of each application. When the time difference between the current time and the time when the CPU usage of each application is acquired last time exceeds the first threshold, the CPU usage of each application is obtained.
  • the first obtaining module 802 is further configured to obtain a difference between the operating hours of the system CPUs that are collected twice in succession as the first difference. Obtaining system CPU usage according to the first difference and the first time interval.
  • FIG. 9 is a block diagram showing the structure of a CPU monitoring device in another embodiment.
  • a CPU monitoring apparatus includes a first obtaining module 902, a difference module 904, a second obtaining module 906, and a closing module 908.
  • the first obtaining module 902, the difference module 904, and the second obtaining module 906 have the same functions as the corresponding modules in FIG. 8.
  • the closing module 908 is configured to detect whether the application meets the preset rule when detecting that the CPU usage corresponding to the application exceeds a second threshold. When the application does not meet the preset rules, stop running the process corresponding to the application.
  • FIG. 10 is a block diagram showing the structure of a CPU monitoring device in another embodiment.
  • a CPU monitoring apparatus includes a first obtaining module 1002, a difference module 1004, a second obtaining module 1006, a third obtaining module 1008, an accumulating module 1010, and a determining module 1012.
  • the first obtaining module 1002, the difference module 1004, and the second obtaining module 1006 have the same functions as the corresponding modules in FIG. 8.
  • the third obtaining module 1008 is configured to obtain a corresponding CPU occupation level according to the system CPU usage.
  • the accumulation module 1010 is configured to accumulate the number of times that the occupation level is continuously maintained.
  • the determining module 1012 is configured to determine a busy degree corresponding to the occupied level when the number of times reaches a third threshold corresponding to the occupied level.
  • FIG. 11 is a block diagram showing the structure of a CPU monitoring device in another embodiment.
  • a CPU monitoring device includes a first obtaining module 1102, a difference module 1104, a second obtaining module 1106, a display module 1108, and a closing module 1110.
  • the first obtaining module 1102, the difference module 1104, and the second obtaining module 1106 have the same functions as the corresponding modules in FIG. 8.
  • the shutdown module 1110 has the same function as the corresponding module in FIG.
  • the display module 1108 is configured to display the abnormal information corresponding to the application and the stop running instruction of the application on the mobile terminal interface.
  • the shutdown module 1110 is further configured to stop running the process corresponding to the application when receiving the trigger operation of the stop operation instruction.
  • each module in the CPU monitoring device is for illustrative purposes only. In other embodiments, the CPU monitoring device may be divided into different modules as needed to complete all or part of the functions of the CPU monitoring device.
  • Each of the above-described CPU monitoring devices may be implemented in whole or in part by software, hardware, and combinations thereof.
  • the above modules may be embedded in the hardware in the processor or in the memory in the server, or may be stored in the memory in the server, so that the processor calls the corresponding operations of the above modules.
  • the terms "component”, “module” and “system” and the like are intended to mean a computer-related entity, which may be hardware, a combination of hardware and software, software, or software in execution.
  • a component can be, but is not limited to being, a process running on a processor, a processor, an object, an executable, a thread of execution, a program, and/or a computer.
  • an application running on a server and a server can be a component.
  • One or more components can reside within a process and/or executed thread, and the components can be located within one computer and/or distributed between two or more computers.
  • the embodiment of the present application also provides a non-transitory computer readable storage medium.
  • One or more non-transitory computer readable storage media containing computer executable instructions that, when executed by one or more processors, cause the processor to perform the CPU monitoring method as described above.
  • the embodiment of the present application further provides a mobile terminal.
  • a mobile terminal As shown in FIG. 12, for the convenience of description, only the parts related to the embodiments of the present application are shown. If the specific technical details are not disclosed, please refer to the method part of the embodiment of the present application.
  • the mobile terminal can be any mobile device, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), an on-board computer, a wearable device, or the like, and the mobile terminal is used as a mobile phone as an example. :
  • FIG. 12 is a block diagram showing a partial structure of a mobile phone related to a mobile terminal provided by an embodiment of the present application.
  • the mobile phone includes: a radio frequency (RF) circuit 1210, a memory 1220, an input unit 1230, a display unit 1240, a sensor 1250, an audio circuit 1260, a wireless fidelity (WiFi) module 1270, and a processor. 1280, and power supply 1290 and other components.
  • RF radio frequency
  • the structure of the handset shown in Figure 12 does not constitute a limitation to the handset, and may include more or fewer components than those illustrated, or some components may be combined, or different components may be arranged.
  • the RF circuit 1210 can be used for receiving and transmitting information during the transmission and reception of information or during the call.
  • the downlink information of the base station can be received and processed by the processor 1280.
  • the uplink data can also be sent to the base station.
  • RF circuits include, but are not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like.
  • LNA Low Noise Amplifier
  • RF circuitry 1210 can also communicate with the network and other devices via wireless communication.
  • the above wireless communication may use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (Code Division). Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), e-mail, Short Messaging Service (SMS), and the like.
  • GSM Global System of Mobile communication
  • GPRS General Pack
  • the memory 1220 can be used to store software programs and modules, and the processor 1280 executes various functional applications and data processing of the mobile phone by running software programs and modules stored in the memory 1220.
  • the memory 1220 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as an application of a sound playing function, an application of an image playing function, etc.);
  • the data storage area can store data (such as audio data, address book, etc.) created according to the use of the mobile phone.
  • memory 1220 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
  • the input unit 1230 can be configured to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the handset 1200.
  • the input unit 1230 may include a touch panel 1231 and other input devices 1232.
  • the touch panel 1231 which may also be referred to as a touch screen, can collect touch operations on or near the user (such as a user using a finger, a stylus, or the like on the touch panel 1231 or near the touch panel 1231. Operation) and drive the corresponding connection device according to a preset program.
  • the touch panel 1231 may include two parts of a touch detection device and a touch controller.
  • the touch detection device detects the touch orientation of the user, and detects a signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts the touch information into contact coordinates, and sends the touch information.
  • the processor 1280 is provided and can receive commands from the processor 1280 and execute them.
  • the touch panel 1231 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves.
  • the input unit 1230 may also include other input devices 1232.
  • other input devices 1232 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.).
  • the display unit 1240 can be used to display information input by the user or information provided to the user as well as various menus of the mobile phone.
  • the display unit 1240 may include a display panel 1241.
  • the display panel 1241 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
  • the touch panel 1231 can cover the display panel 1241. When the touch panel 1231 detects a touch operation thereon or nearby, the touch panel 1231 transmits to the processor 1280 to determine the type of the touch event, and then the processor 1280 is The type of touch event provides a corresponding visual output on display panel 1241.
  • the touch panel 1231 and the display panel 1241 are used as two independent components to implement the input and input functions of the mobile phone, in some embodiments, the touch panel 1231 and the display panel 1241 may be integrated. Realize the input and output functions of the phone.
  • the handset 1200 can also include at least one type of sensor 1250, such as a light sensor, motion sensor, and other sensors.
  • the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 1241 according to the brightness of the ambient light, and the proximity sensor may close the display panel 1241 and/or when the mobile phone moves to the ear. Or backlight.
  • the motion sensor may include an acceleration sensor, and the acceleration sensor can detect the magnitude of the acceleration in each direction, and the magnitude and direction of the gravity can be detected at rest, and can be used to identify the gesture of the mobile phone (such as horizontal and vertical screen switching), and vibration recognition related functions (such as Pedometer, tapping, etc.; in addition, the phone can also be equipped with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors.
  • the acceleration sensor can detect the magnitude of the acceleration in each direction, and the magnitude and direction of the gravity can be detected at rest, and can be used to identify the gesture of the mobile phone (such as horizontal and vertical screen switching), and vibration recognition related functions (such as Pedometer, tapping, etc.; in addition, the phone can also be equipped with gyroscopes, barometers, hygrometers, thermometers, infrared sensors and other sensors.
  • Audio circuitry 1260, speaker 1261, and microphone 1262 can provide an audio interface between the user and the handset.
  • the audio circuit 1260 can transmit the converted electrical data of the received audio data to the speaker 1261, and convert it into a sound signal output by the speaker 1261; on the other hand, the microphone 1262 converts the collected sound signal into an electrical signal, by the audio circuit 1260. After receiving, it is converted into audio data, and then processed by the audio data output processor 1280, transmitted to another mobile phone via the RF circuit 1210, or outputted to the memory 1220 for subsequent processing.
  • WiFi is a short-range wireless transmission technology.
  • the mobile phone through the WiFi module 1270 can help users to send and receive e-mail, browse the web and access streaming media, etc. It provides users with wireless broadband Internet access.
  • FIG. 12 shows the WiFi module 1270, it will be understood that it does not belong to the essential configuration of the handset 1200 and may be omitted as needed.
  • the processor 1280 is a control center for the handset that connects various portions of the entire handset using various interfaces and lines, by executing or executing software programs and/or modules stored in the memory 1220, and invoking data stored in the memory 1220, The phone's various functions and processing data, so that the overall monitoring of the phone.
  • processor 1280 can include one or more processing units.
  • the processor 1280 can integrate an application processor and a modem processor, wherein the application processor primarily processes an operating system, a user interface, an application, etc.; the modem processor primarily processes wireless communications. It will be appreciated that the above described modem processor may also not be integrated into the processor 1280.
  • the handset 1200 also includes a power source 1290 (such as a battery) that powers the various components.
  • a power source 1290 such as a battery
  • the power source can be logically coupled to the processor 1280 via a power management system to manage functions such as charging, discharging, and power management through the power management system.
  • the handset 1200 can also include a camera, a Bluetooth module, and the like.
  • the processor 1280 included in the mobile terminal implements the CPU monitoring method as described above when executing a computer program stored in the memory.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or the like.

Abstract

一种CPU监测方法方法,包括:按照预设的第一时间间隔获取系统CPU占用率;当当前系统CPU占用率与相邻第一时间间隔的系统CPU占用率的差值超过指定值时,将所述当前系统CPU占用率作为第一CPU占用率;当检测到当前系统CPU占用率与相邻第一时间间隔的系统CPU占用率的差值超过指定值之后,持续按照预设的第一时间间隔获取系统CPU占用率,当系统CPU占用率不小于所述第一CPU占用率的持续时长超过指定时长时,获取各应用程序CPU占用率。

Description

CPU监测方法、计算机可读存储介质和移动终端
相关申请的交叉引用
本申请要求于2017年08月01日提交中国专利局、申请号为2017106485423、发明名称为“CPU监测方法、装置、计算机可读存储介质和移动终端”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
背景技术
随着智能移动终端的迅速发展,用户对智能移动终端的性能要求越来越高。在智能移动终端中,智能移动终端系统程序运行、第三方应用程序运行均需要消耗智能移动终端的系统资源,当智能移动终端的系统资源被大量消耗时,会影响智能移动终端的运行效率。
发明内容
根据本申请的各种实施例提供一种CPU监测方法、非易失性计算机可读存储介质和移动终端。
一种CPU监测方法,包括:
按照预设的第一时间间隔获取系统CPU占用率;
当当前系统CPU占用率与相邻所述第一时间间隔的系统CPU占用率的差值超过指定值时,将所述当前系统CPU占用率作为第一CPU占用率;及
当检测到当前系统CPU占用率与相邻所述第一时间间隔的系统CPU占用率的差值超过指定值之后,持续按照预设的所述第一时间间隔获取所述系统CPU占用率,当所述系统CPU占用率不小于所述第一CPU占用率的持续时长超过指定时长时,获取各应用程序CPU占用率。
一个或多个包含计算机可执行指令的非易失性计算机可读存储介质,当所述计算机可执行指令被一个或多个处理器执行时,使得所述处理器执行以下操作:
按照预设的第一时间间隔获取系统CPU占用率;
当当前系统CPU占用率与相邻所述第一时间间隔的系统CPU占用率的差值超过指定值时,将所述当前系统CPU占用率作为第一CPU占用率;及
当检测到当前系统CPU占用率与相邻所述第一时间间隔的系统CPU占用率的差值超过指定值之后,持续按照预设的所述第一时间间隔获取所述系统CPU占用率,当所述系统CPU占用率不小于所述第一CPU占用率的持续时长超过指定时长时,获取各应用程序CPU占用率。
一种移动终端,包括存储器及处理器,所述存储器中储存有计算机可读指令,所述指令被所述处理器执行时,使得所述处理器执行如下操作:
按照预设的第一时间间隔获取系统CPU占用率;
当当前系统CPU占用率与相邻所述第一时间间隔的系统CPU占用率的差值超过指定值时,将所述当前系统CPU占用率作为第一CPU占用率;及
当检测到当前系统CPU占用率与相邻所述第一时间间隔的系统CPU占用率的差值超过指定值之后,持续按照预设的所述第一时间间隔获取所述系统CPU占用率,当所述系统CPU占用率不小于所述第一CPU占用率的持续时长超过指定时长时,获取各应用程序CPU占用率。
通过按照预设的第一时间间隔获取系统CPU占用率,当当前系统CPU占用率与相邻第一时间间隔的系统CPU占用率的差值超过指定值时,将当前系统CPU占用率作为第一CPU占用率,当检测到当前系统CPU占用率与相邻第一时间间隔的系统CPU占用率的差值超过指定值之后,持续按照预设的第一时间间隔获取系统CPU占用率,当系统CPU占用率不小 于第一CPU占用率的持续时长超过指定时长时,获取各应用程序CPU占用率,在系统总CPU迅速增大时,能够及时获取应用程序对应的CPU占用率,有利于监控应用程序的CPU占用率,识别异常应用程序。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征、目的和优点将从说明书、附图以及权利要求书变得明显。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为一个实施例中移动终端的内部结构图;
图2为一个实施例中CPU监测方法的流程图;
图3为另一个实施例中CPU监测方法的流程图;
图4为另一个实施例中CPU监测方法的流程图;
图5为另一个实施例中CPU监测方法的流程图;
图6为另一个实施例中CPU监测方法的流程图;
图7为另一个实施例中CPU监测方法的流程图;
图8为一个实施例中CPU监测装置的结构框图;
图9为另一个实施例中CPU监测装置的结构框图;
图10为另一个实施例中CPU监测装置的结构框图;
图11为另一个实施例中CPU监测装置的结构框图;
图12为与本申请实施例提供的移动终端相关的手机的部分结构的框图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
可以理解,本申请所使用的术语“第一”、“第二”等可在本文中用于描述各种元件,但这些元件不受这些术语限制。这些术语仅用于将第一个元件与另一个元件区分。举例来说,在不脱离本申请的范围的情况下,可以将第一获取模块称为第二获取模块,且类似地,可将第二获取模块称为第一获取模块。第一获取模块和第二获取模块两者都是获取模块,但其不是同一获取模块。
图1为一个实施例中移动终端的内部结构示意图。如图1所示,该移动终端包括通过系统总线连接的处理器、非易失性存储介质、内存储器、网络接口、显示屏和输入装置。其中,移动终端的非易失性存储介质存储有操作系统和计算机可读指令。该计算机可读指令被处理器执行时以实现一种CPU监测方法。该处理器用于提供计算和控制能力,支撑整个移动终端的运行。移动终端中的内存储器为非易失性存储介质中的计算机可读指令的运行提供环境。网络接口用于与服务器进行网络通信。移动终端的显示屏可以是液晶显示屏或者电子墨水显示屏等,输入装置可以是显示屏上覆盖的触摸层,也可以是移动终端外壳上设置的按键、轨迹球或触控板,也可以是外接的键盘、触控板或鼠标等。该移动终端可以是手机、平板电脑或者个人数字助理或穿戴式设备等。本领域技术人员可以理解,图1中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的移动终端的限定,具体的移动终端可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
图2为一个实施例中CPU监测方法的流程图。如图2所示,一种CPU监测方法,包括操作202至操作206。其中:
操作202,按照预设的第一时间间隔获取系统CPU占用率。
移动终端在运行时,移动终端内系统程序和第三方程序均会消耗移动终端内CPU(Central Processing Unit,中央处理器)资源。移动终端系统CPU占用率即为移动终端中运行的所有程序占用的CPU资源,包括系统运行程序和第三方运行程序。一般来说,系统CPU占用率越高、移动终端内运行的程序越多;系统CPU占用率越低、移动终端内运行的程序越少。移动终端可按照预设的第一时间间隔获取系统CPU占用率,预设的第一时间间隔可为用户设定的时间间隔,也可为根据历史采集时间得到的时间间隔。
移动终端获取系统CPU占用率的操作可包括:移动终端按照预设的第一时间间隔采集系统CPU累计工作时长,获取连续两次采集的CPU累计工作时长中后一次CPU累计工作时长与前一次CPU累计工作时长的差值,上述差值即为系统CPU在预设的第一时间间隔内真正工作的时间,上述差值与预设的第一时间间隔的比值即在预设的第一时间间隔内系统CPU占用率。上述CPU累计工作时长为移动终端自启动到当前时刻CPU工作的总时长。上述预设的第一时间间隔可为5秒至20秒中任一时长,如可为5秒。例如,移动终端每隔5秒采集一次系统CPU累计工作时长,当连续两次采集的CPU累计工作时长分别为60分03秒和60分04秒时,则在这5秒的时间内系统CPU占用率为20%。
在Android系统中,可在/proc目录下读取系统CPU相关信息。其中,/proc目录下stat文件包含了系统CPU活动的所有信息,上述系统CPU活动的所有信息均为移动终端自启动到当前时刻CPU活动累计的时长。移动终端中CPU监控模块可定时读取/proc目录下系统CPU活动信息,再获取移动终端在采集时间内的系统CPU占用率。
操作204,当当前系统CPU占用率与相邻第一时间间隔的系统CPU占用率的差值超过指定值时,将当前系统CPU占用率作为第一CPU占用率。
移动终端在获取到当前系统CPU占用率后,会把当前系统CPU占用率与相邻第一时间间隔的系统CPU占用率作差,获取系统CPU占用率差值。当上述系统CPU占用率差值超过指定值时,则判定移动终端系统CPU占用率变化较大,移动终端内系统CPU占用率异常。一般情况下,上述指定值设定为正数,可为15%至20%任一数字,如可为20%。当系统CPU占用率差值大于上述指定值,即移动终端系统CPU占用率突然增大,移动终端系统CPU占用率异常时,移动终端将获取的当前系统CPU占用率作为第一CPU占用率,即异常CPU占用率。
操作206,当检测到当前系统CPU占用率与相邻第一时间间隔的系统CPU占用率的差值超过指定值之后,持续按照预设的第一时间间隔获取系统CPU占用率,当系统CPU占用率不小于第一CPU占用率的持续时长超过指定时长时,获取各应用程序CPU占用率。
在移动终端获取第一CPU占用率后,再次按照预设的第一时间间隔获取预设次数的移动终端中系统CPU占用率,并将获取的系统CPU占用率依次与第一CPU占用率作比较。当获取的系统CPU占用率均不小于第一CPU占用率时,则系统CPU占用率不小于异常CPU占用率的持续时长超过指定时长,即移动终端中存在应用程序持续大量消耗CPU资源,获取移动终端中各应用程序的CPU占用率。上述预设的第一时间间隔可为5秒至30秒中任意时间,如可为5秒。例如,移动终端连续两次采集的系统CPU占用率为20%和40%,系统CPU占用率差值大于指定值15%,则将系统CPU占用率为40%作为第一CPU占用率。移动终端按照预设的第一时间间隔每隔5秒采集一次系统CPU占用率,共采集4次系统CPU占用率,分别为42%、45%、47%、50%,上述4次系统CPU占用率均超过40%,即移动终端系统CPU占用率超过40%的持续时长达到20秒超过指定时长18秒,则获取移动终端中各应用程序CPU占用率。
移动终端获取各应用程序CPU占用率的操作可包括:按照预设的第二时间间隔采集移 动终端中正在运行的各个应用程序的占用CPU的累计时长,获取连续两次采集的应用程序的占用CPU的累计时长中后一次占用CPU的累计时长与前一次占用CPU的累计时长的差值,上述差值为应用程序在第二时间间隔内占用CPU的时间,上述差值与第二时间间隔的比值为在第二时间间隔应用程序CPU占用率。上述第一时间间隔和第二时间间隔可为相同值或不同值。
在Android系统中,/proc/pid目录下sats文件包含了应用程序对应的进程占用CPU的信息。上述应用程序对应的进程占用CPU的信息为应用程序自启动后占用CPU的累计时长。移动终端中CPU监控模块可定时读取/proc/pid目录下各应用程序占用CPU的累计时长,再获取应用程序在采集时间内应用程序CPU占用率。
本申请实施例中CPU监测方法,按照预设的第一时间间隔采集系统CPU占用率,即移动终端中总CPU占用率,当检测到系统CPU占用率大幅度增大时且持续较长时间时,可判定移动终端中存在应用程序大量消耗CPU资源,则获取移动终端中当前运行的应用程序对应的应用程序CPU占用率。上述方法,在系统总CPU迅速增大时,能够及时获取应用程序对应的CPU占用率,有利于监控应用程序的CPU占用率,识别异常应用程序。
在一个实施例中,在获取各应用程序CPU占用率之前,上述CPU监测方法还包括:
操作302,查找上一次获取各应用程序CPU占用率的时刻。
操作304,当当前时刻与上一次获取各应用程序CPU占用率的时刻的时间差超过第一阈值时,获取各应用程序CPU占用率。
移动终端在获取各应用程序对应的应用程序CPU占用率之前,会查找上一次获取各应用程序CPU占用率的时刻,获取当前时刻与上一次获取各应用程序CPU占用率时刻之间的时间差。当上述时间差超过预设的第一阈值时,则获取应用程序CPU占用率。获取应用程序CPU占用率的操作与操作206中获取应用程序CPU占用率的操作相同,在此不再赘述。当上述时间差未超过预设的第一阈值时,移动终端则直接获取上一次采集的各应用程序CPU占用率作为当前各应用程序CPU占用率。上述第一阈值可为用户设定的值,也可为根据历史采集的各应用程序CPU占用率数据分析得到的数值,如30秒,1分钟等。
移动终端中应用程序CPU占用率在短时间内不会发生变化,且获取各应用程序CPU占用率需要消耗一定的系统资源。本申请实施例中CPU监测方法,在接收到获取各应用程序对应的应用程序CPU占用率请求后,先获取当前时刻与上一次获取各应用程序对应的应用程序CPU占用率时刻的时间差,判断时间差与预设时长的关系,在时间差较短时,直接将上一次获取的各应用程序CPU占用率作为当前各应用程序CPU占用率,在时间差较长时,在重新获取各应用程序CPU占用率。既保证了获取个应用程序CPU占用率的准确性,有降低了系统功耗,节省了系统资源。
在一个实施例中,操作202获取系统CPU占用率包括:
(1)获取连续两次采集的系统CPU累计工作时长的差值作为第一差值。
(2)根据第一差值和第一时间间隔获取系统CPU占用率。
在Android系统中,可在/proc目录下读取系统CPU相关信息。其中,/proc目录下stat文件包含了系统CPU活动的所有信息,上述系统CPU活动的所有信息均为移动终端自启动到当前时刻CPU活动累计的时长。移动终端中CPU监控模块可定时读取/proc目录下系统CPU活动信息,再获取移动终端在采集时间内的系统CPU占用率。移动终端获取系统CPU占用率的操作可包括:移动终端按照预设的第一时间间隔采集系统CPU累计工作时长,获取连续两次采集的CPU累计工作时长中后一次CPU累计工作时长与前一次CPU累计工作时长的差值,上述差值即为系统CPU在预设的第一时间间隔内真正工作的时间,上述差值与预设的第一时间间隔的比值即在预设的第一时间间隔内系统CPU占用率。上述CPU累计工作时长为移动终端自启动到当前时刻CPU工作的总时长。上述预设的第一时间间隔可为5秒至20秒中任一时长,优选的,可为5秒。
在一个实施例中,上述CPU监测方法还包括:
操作402,当检测到应用程序对应的CPU占用率超过第二阈值时,检测应用程序是否满足预设规则。
操作404,当应用程序不满足预设规则时,停止运行应用程序对应的进程。
移动终端在获取到各应用程序对应的CPU占用率后,依次比较各应用程序对应的CPU占用率是否超过预设的第二阈值,当超过预设的第二阈值时,则表示应用程序CPU占用率过高,进一步检测上述应用程序是否满足预设规则。上述第二阈值可为用户设定的值,也可为根据历史获取的应用程序CPU占用率分析得到的值,如上述第二阈值可为20%。预设规则包括:系统白名单中应用程序、前台运行的应用程序、应用程序正在执行预设行为(包括下载文件、上传文件、应用程序更新等)、优先级较高的应用程序、播放音乐的应用程序等。上述预设规则可为用户设置的规则。当应用程序满足上述预设规则时,不对应用程序进行处理,如对用户设置的白名单中应用程序不进行处理、对用户设置的优先级前三的应用程序不进行处理。当应用程序不满足上述预设规则时,停止运行上述应用程序对应的进程。其中,停止运行上述应用程序对应的进程包括:关闭或挂起应用程序对应的进程等方式。其中,关闭应用程序对应的进程指的是终止(kill)应用程序对应的进程。挂起应用程序对应的进程指的是暂停应用程序对应的进程的运行,可将挂起的应用程序对应的进程加入等待队列中,当系统CPU占用率较低时,再恢复应用程序对应的进程的运行。
本申请实施例中CPU监测方法,在移动终端中应用程序CPU占用率较高时,检测应用程序是否为移动终端预设的不处理应用程序或用户设定的不处理应用程序。当不是不处理应用程序时,停止运行应用程序对应的进行,即对CPU占用率异常的应用程序进行查杀处理,避免了移动终端中异常应用程序大量耗费CPU资源,造成移动终端系统卡顿、发热等。其中,预设规则可以保证应用程序正常占用大量CPU资源的情况下,应用程序不被清理,提高了识别异常应用程序的精确度,查杀的异常应用程序更准确。
在一个实施例中,上述CPU监测方法还包括:
操作502,根据系统CPU占用率获取对应的CPU占用级别。
移动终端可预先划分多个CPU占用级别,每个占用级别可对应不同的占用率范围,例如,划分4个CPU占用级别,包括L1、L2、L3及L4,其中,L1占用级别对应的占用率范围为小于20%,L2占用级别对应的占用率范围为20%~40%,L3占用级别对应的占用率范围为40%~60%,L4占用级别对应的占用率范围为大于60%等,不限于此。移动终端按照预设的第一时间间隔采集系统CPU占用率,可确定采集的系统CPU占用率落入的占用率范围,并得到与该落入的占用率范围对应的CPU占用级别。例如,采集的系统CPU占用率为18%,则CPU占用级别为L1,系统CPU占用率为25%,则CPU占用级别为L2等。
操作504,累计连续维持在占用级别的次数。
移动终端可为每个CPU占用级别分配一个级别计数器,通过级别计数器记录CPU维持在对应的占用级别的连续次数,其中,CPU维持在某个占用级别,指的是CPU一直处于该占用级别或以上的占用级别。例如,CPU占用级别变化为L2占用级别、L3占用级别、L2占用级别,则可认为CPU维持在L2占用级别,连续次数为3。
在一个实施例中,移动终端按照预设的第一时间间隔采集系统CPU占用率,并确定CPU占用级别,可分别在该占用级别及以下的占用级别对应的级别计数器中加1,并将其他占用级别的级别计数器清零。例如,本次的CPU占用级别为L3,则将L1、L2及L3的级别计数器分别加1,L4的级别计数器清零,下一次的CPU占用级别为L2,则将L1、L2的级别计数器分别加1,L3、L4的级别计数器清零。
在一个实施例中,可划分占用级别的类型,其中,类型可包括为空闲级别及繁忙级别,例如,将L1占用级别作为空闲级别,将L2、L3、L4占用级别作为繁忙级别,分别代表不同的繁忙程度。移动终端每隔预设的第一时间间隔采集系统CPU占用率,并计算CPU占用 级别,可先确定对应的类型,再分别在该占用级别及以下的属于同一类型的占用级别对应的级别计数器中加1,并将其他占用级别的级别计数器清零。例如,本次的CPU占用级别为L1,属于空闲级别,则将L1的级别计数器加1,L2、L3及L4的级别计数器清零,下一次的CPU占用级别为L3,属于繁忙级别,则将L3以及同属于繁忙级别的L2的级别计数器分别加1,L1、L4的级别计数器清零。
操作506,当次数达到占用级别对应的第三阈值时,确定与占用级别对应的繁忙程度。
可为每个CPU占用级别设定对应的第三阈值,该第三阈值可用于判断移动终端的CPU是否维持在对应占用级别的工作状态中。移动终端通过级别计数器累计CPU连续维持在各个占用级别的次数,当CPU连续维持在占用级别的次数达到与该占用级别对应的第三阈值时,则可认定CPU稳定在该占用级别的工作状态中。例如,对L1、L2、L3及L4,分别设定一个对应的第三阈值为c1、c2、c3及c4,当CPU连续维持在L1级别的次数达到c1,则认定CPU稳定在L1的工作状态中。进一步地,各占用级别对应的第三阈值,可随着占用级别的增大而减小,例如,L1、L2、L3及L4对应的第三阈值为c1、c2、c3及c4,其中,c1>c2>c3>c4,比如,c1为5次,c2为4次,c3为3次,c4为2次等,但不限于此。在一个实施例中,当同时存在多个连续维持的次数达到对应的第三阈值的占用级别时,则选取最高级别的占用级别作为CPU稳定的工作状态。
本申请实施例中CPU监测方法,对CPU占用率设定不同的占用级别,根据维持在占用级别的次数确定移动终端的繁忙程度,有利于根据移动终端的繁忙程序对应用程序进行不同的处理,如在占用级别较高,系统较繁忙时,直接关闭异常应用程序对应的进程;在占用级别较低,系统较空闲时,挂起异常应用程序对应的进程,提高了处理异常应用程序的灵活性。
在一个实施例中,在停止运行应用程序对应的进程之前,上述CPU监测方法还包括:
操作602,在移动终端界面展示应用程序对应的异常信息、对应用程序的停止运行指令。
操作604,当接收到对停止运行指令的触发操作时,停止运行应用程序对应的进程。
移动终端在停止运行应用程序对应的进程之前,还可在移动终端界面展示应用程序对应的异常信息。上述异常信息可包括:应用程序当前CPU占用率,应用程序当前程序行为(如后台下载文件等)、应用程序当前占用网速等。除展示应用程序的停止运行指令外,还可展示取消指令。当获取到对取消指令的触发操作时,则对应用程序不进行处理;当获取到对停止运行指令的触发操作时,则停止运行应用程序对应的进程。
本申请实施例中CPU监测方法,在检测出异常应用程序后,在移动终端界面展示应用程序对应的异常信息,接收到用户停止运行指令后在对应用程序对应的进程进行停止运行,可以避免对应用程序查杀的误操作,提高了应用程序查杀的精度。
图7为另一个实施例中CPU监测方法的流程图。如图7所示,一种CPU监测方法,包括操作702至操作714。其中:
操作702,按照预设的第一时间间隔获取系统CPU占用率。上述获取系统CPU占用率包括:
(1)获取连续两次采集的系统CPU累计工作时长的差值作为第一差值。
(2)根据第一差值和第一时间间隔获取系统CPU占用率。
获取系统CPU占用率的操作与操作202中获取系统CPU占用率的操作相同,在此不再赘述。
操作704,当当前系统CPU占用率与相邻第一时间间隔的系统CPU占用率的差值超过指定值时,将当前系统CPU占用率作为第一CPU占用率。
上述第一CPU占用率即为异常占用率。获取第一CPU占用率的操作与操作204中获取第一CPU占用率的操作相同,在此不再赘述。
操作706,当检测到当前系统CPU占用率与相邻第一时间间隔的系统CPU占用率的差值超过指定值之后,持续按照预设的第一时间间隔获取系统CPU占用率,当系统CPU占用率不小于第一CPU占用率的持续时长超过指定时长时,查找上一次获取各应用程序CPU占用率的时刻。
查找上一次获取各应用程序CPU占用率的时刻的操作与操作302中查找上一次获取各应用程序CPU占用率的时刻的操作相同,在此不再赘述。
操作708,当当前时刻与上一次获取各应用程序CPU占用率的时刻的时间差超过第一阈值时,获取各应用程序CPU占用率。
获取应用程序CPU占用率的操作与操作206中获取应用程序CPU占用率的操作相同,在此不再赘述。
操作710,当检测到应用程序对应的CPU占用率超过第二阈值时,检测应用程序是否满足预设规则。
检测应用程序对应的CPU占用率是否超过第二阈值,应用程序是否满足预设规则的操作与操作402中对应的操作相同,在此不再赘述。
操作712,当应用程序满足预设规则时,在移动终端界面展示应用程序对应的异常信息、对应用程序的停止运行指令。当接收到对停止运行指令的触发操作时,停止运行应用程序对应的进程。
在移动终端展示应用程序对应的异常信息、对应用程序的停止运行指令操作与图6中对应的操作相同,在此不再赘述。停止运行应用程序对应的进程与操作404中对应的操作相同,在此不再赘述。
操作714,根据系统CPU占用率获取对应的CPU占用级别。累计连续维持在占用级别的次数。当次数达到占用级别对应的第三阈值时,确定与占用级别对应的繁忙程度。
获取系统CPU占用率对应的CPU占用级别,确定与CPU占用界别对应的繁忙程度的操作与图5中对应的操作相同,在此不再赘述。
本申请实施例的方法流程图中的各个操作按照箭头的指示依次显示,但是这些操作并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些操作的执行并没有严格的顺序限制,其可以以其他的顺序执行。而且,本申请实施例的方法流程图中的至少一部分操作可以包括多个子操作或者多个阶段,这些子操作或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,其执行顺序也不必然是依次进行,而是可以与其他操作或者其他操作的子操作或者阶段的至少一部分轮流或者交替地执行。
图8为一个实施例中CPU监测装置的结构框图。一种CPU监测装置,包括第一获取模块802、差值模块804和第二获取模块806。其中:
第一获取模块802,用于按照预设的第一时间间隔获取系统CPU占用率。
差值模块804,用于当当前系统CPU占用率与相邻第一时间间隔的系统CPU占用率的差值超过指定值时,将当前系统CPU占用率作为第一CPU占用率。
第二获取模块806,用于当检测到当前系统CPU占用率与相邻第一时间间隔的系统CPU占用率的差值超过指定值之后,持续按照预设的第一时间间隔获取系统CPU占用率,当系统CPU占用率不小于第一CPU占用率的持续时长超过指定时长时,获取各应用程序CPU占用率。
在一个实施例中,第二获取模块806还用于在获取各应用程序CPU占用率之前,查找上一次获取各应用程序CPU占用率的时刻。当当前时刻与上一次获取各应用程序CPU占用率的时刻的时间差超过第一阈值时,获取各应用程序CPU占用率。
在一个实施例中,第一获取模块802还用于获取连续两次采集的系统CPU工作时长的差值作为第一差值。根据第一差值和第一时间间隔获取系统CPU占用率。
图9为另一个实施例中CPU监测装置的结构框图。一种CPU监测装置,包括第一获取模块902、差值模块904、第二获取模块906和关闭模块908。其中第一获取模块902、差值模块904和第二获取模块906与图8中对应的模块功能相同。
关闭模块908,用于当检测到应用程序对应的CPU占用率超过第二阈值,检测应用程序是否满足预设规则。当应用程序不满足预设规则时,停止运行应用程序对应的进程。
图10为另一个实施例中CPU监测装置的结构框图。一种CPU监测装置,包括第一获取模块1002、差值模块1004、第二获取模块1006、第三获取模块1008、累计模块1010和确定模块1012。其中第一获取模块1002、差值模块1004和第二获取模块1006与图8中对应的模块功能相同。
第三获取模块1008,用于根据系统CPU占用率获取对应的CPU占用级别。
累计模块1010,用于累计连续维持在占用级别的次数。
确定模块1012,用于当次数达到占用级别对应的第三阈值时,确定与占用级别对应的繁忙程度。
图11为另一个实施例中CPU监测装置的结构框图。一种CPU监测装置,包括第一获取模块1102、差值模块1104、第二获取模块1106、展示模块1108和关闭模块1110。其中第一获取模块1102、差值模块1104和第二获取模块1106与图8中对应的模块功能相同。关闭模块1110与图9中对应的模块功能相同。
展示模块1108,用于在移动终端界面展示应用程序对应的异常信息、对应用程序的停止运行指令。
关闭模块1110还用于当接收到对停止运行指令的触发操作时,停止运行应用程序对应的进程。
上述CPU监测装置中各个模块的划分仅用于举例说明,在其他实施例中,可将CPU监测装置按照需要划分为不同的模块,以完成上述CPU监测装置的全部或部分功能。
上述CPU监测装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于服务器中的处理器中,也可以以软件形式存储于服务器中的存储器中,以便于处理器调用执行以上各个模块对应的操作。如在本申请中所使用的,术语“组件”、“模块”和“系统”等旨在表示计算机相关的实体,它可以是硬件、硬件和软件的组合、软件、或者执行中的软件。例如,组件可以是但不限于是,在处理器上运行的进程、处理器、对象、可执行码、执行的线程、程序和/或计算机。作为说明,运行在服务器上的应用程序和服务器都可以是组件。一个或多个组件可以驻留在进程和/或执行的线程中,并且组件可以位于一个计算机内和/或分布在两个或更多的计算机之间。
本申请实施例还提供了一种非易失性计算机可读存储介质。一个或多个包含计算机可执行指令的非易失性计算机可读存储介质,当计算机可执行指令被一个或多个处理器执行时,使得处理器执行如上所述的CPU监测方法。
本申请实施例还提供了一种移动终端。如图12所示,为了便于说明,仅示出了与本申请实施例相关的部分,具体技术细节未揭示的,请参照本申请实施例方法部分。该移动终端可以为包括手机、平板电脑、PDA(Personal Digital Assistant,个人数字助理)、POS(Point of Sales,销售终端)、车载电脑、穿戴式设备等任意终端设备,以移动终端为手机为例:
图12为与本申请实施例提供的移动终端相关的手机的部分结构的框图。参考图12,手机包括:射频(Radio Frequency,RF)电路1210、存储器1220、输入单元1230、显示单元1240、传感器1250、音频电路1260、无线保真(wireless fidel ity,WiFi)模块1270、处理器1280、以及电源1290等部件。本领域技术人员可以理解,图12所示的手机结构并不构成对手机的限定,可以包括比图示更多或更少的部件,或者组 合某些部件,或者不同的部件布置。
其中,RF电路1210可用于收发信息或通话过程中,信号的接收和发送,可将基站的下行信息接收后,给处理器1280处理;也可以将上行的数据发送给基站。通常,RF电路包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器(Low Noise Amplifier,LNA)、双工器等。此外,RF电路1210还可以通过无线通信与网络和其他设备通信。上述无线通信可以使用任一通信标准或协议,包括但不限于全球移动通讯系统(Global System of Mobile communication,GSM)、通用分组无线服务(General Packet Radio Service,GPRS)、码分多址(Code Division Multiple Access,CDMA)、宽带码分多址(Wideband Code Division Multiple Access,WCDMA)、长期演进(Long Term Evolution,LTE))、电子邮件、短消息服务(Short Messaging Service,SMS)等。
存储器1220可用于存储软件程序以及模块,处理器1280通过运行存储在存储器1220的软件程序以及模块,从而执行手机的各种功能应用以及数据处理。存储器1220可主要包括程序存储区和数据存储区,其中,程序存储区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能的应用程序、图像播放功能的应用程序等)等;数据存储区可存储根据手机的使用所创建的数据(比如音频数据、通讯录等)等。此外,存储器1220可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。
输入单元1230可用于接收输入的数字或字符信息,以及产生与手机1200的用户设置以及功能控制有关的键信号输入。具体地,输入单元1230可包括触控面板1231以及其他输入设备1232。触控面板1231,也可称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板1231上或在触控面板1231附近的操作),并根据预先设定的程式驱动相应的连接装置。在一个实施例中,触控面板1231可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器1280,并能接收处理器1280发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板1231。除了触控面板1231,输入单元1230还可以包括其他输入设备1232。具体地,其他输入设备1232可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)等中的一种或多种。
显示单元1240可用于显示由用户输入的信息或提供给用户的信息以及手机的各种菜单。显示单元1240可包括显示面板1241。在一个实施例中,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板1241。在一个实施例中,触控面板1231可覆盖显示面板1241,当触控面板1231检测到在其上或附近的触摸操作后,传送给处理器1280以确定触摸事件的类型,随后处理器1280根据触摸事件的类型在显示面板1241上提供相应的视觉输出。虽然在图12中,触控面板1231与显示面板1241是作为两个独立的部件来实现手机的输入和输入功能,但是在某些实施例中,可以将触控面板1231与显示面板1241集成而实现手机的输入和输出功能。
手机1200还可包括至少一种传感器1250,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板1241的亮度,接近传感器可在手机移动到耳边时,关闭显示面板1241和/或背光。运动传感器可包括加速度传感器,通过加速度传感器可检测各个方向上加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换)、振动识别相关功能(比如计步器、敲击) 等;此外,手机还可配置陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器等。
音频电路1260、扬声器1261和传声器1262可提供用户与手机之间的音频接口。音频电路1260可将接收到的音频数据转换后的电信号,传输到扬声器1261,由扬声器1261转换为声音信号输出;另一方面,传声器1262将收集的声音信号转换为电信号,由音频电路1260接收后转换为音频数据,再将音频数据输出处理器1280处理后,经RF电路1210可以发送给另一手机,或者将音频数据输出至存储器1220以便后续处理。
WiFi属于短距离无线传输技术,手机通过WiFi模块1270可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图12示出了WiFi模块1270,但是可以理解的是,其并不属于手机1200的必须构成,可以根据需要而省略。
处理器1280是手机的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器1220内的软件程序和/或模块,以及调用存储在存储器1220内的数据,执行手机的各种功能和处理数据,从而对手机进行整体监控。在一个实施例中,处理器1280可包括一个或多个处理单元。在一个实施例中,处理器1280可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等;调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器1280中。
手机1200还包括给各个部件供电的电源1290(比如电池),优选的,电源可以通过电源管理系统与处理器1280逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。
在一个实施例中,手机1200还可以包括摄像头、蓝牙模块等。
在本申请实施例中,该移动终端所包括的处理器1280执行存储在存储器上的计算机程序时实现如上所述的CPU监测方法。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,的程序可存储于一非易失性计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)等。
以上实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。

Claims (18)

  1. 一种CPU监测方法,包括:
    按照预设的第一时间间隔获取系统CPU占用率;
    当当前系统CPU占用率与相邻所述第一时间间隔的系统CPU占用率的差值超过指定值时,将所述当前系统CPU占用率作为第一CPU占用率;及
    当检测到当前系统CPU占用率与相邻所述第一时间间隔的系统CPU占用率的差值超过指定值之后,持续按照预设的所述第一时间间隔获取所述系统CPU占用率,当所述系统CPU占用率不小于所述第一CPU占用率的持续时长超过指定时长时,获取各应用程序CPU占用率。
  2. 根据权利要求1所述的CPU监测方法,其特征在于,在所述获取各应用程序CPU占用率之前,还包括:
    查找上一次获取各应用程序CPU占用率的时刻;及
    当当前时刻与所述上一次获取各应用程序CPU占用率的时刻的时间差超过第一阈值时,获取所述各应用程序CPU占用率。
  3. 根据权利要求1所述的CPU监测方法,其特征在于,所述获取系统CPU占用率包括:
    获取连续两次采集的系统CPU累计工作时长的差值作为第一差值;及
    根据所述第一差值和所述第一时间间隔获取系统CPU占用率。
  4. 根据权利要求1所述的CPU监测方法,其特征在于,还包括:
    当检测到应用程序对应的CPU占用率超过第二阈值时,检测所述应用程序是否满足预设规则;及
    当所述应用程序不满足预设规则时,停止运行所述应用程序对应的进程。
  5. 根据权利要求4所述的CPU监测方法,其特征在于,在所述停止运行所述应用程序对应的进程之前,还包括:
    在移动终端界面展示所述应用程序对应的异常信息与对所述应用程序的停止运行指令;
    当接收到对所述停止运行指令的触发操作时,停止运行所述应用程序对应的进程。
  6. 根据权利要求1所述的CPU监测方法,其特征在于,还包括:
    根据所述系统CPU占用率获取对应的CPU占用级别;
    累计连续维持在所述占用级别的次数;及
    当所述次数达到所述占用级别对应的第三阈值时,确定与所述占用级别对应的繁忙程度。
  7. 一个或多个包含计算机可执行指令的非易失性计算机可读存储介质,当所述计算机可执行指令被一个或多个处理器执行时,使得所述处理器执行以下操作:
    按照预设的第一时间间隔获取系统CPU占用率;
    当当前系统CPU占用率与相邻所述第一时间间隔的系统CPU占用率的差值超过指定值时,将所述当前系统CPU占用率作为第一CPU占用率;及
    当检测到当前系统CPU占用率与相邻所述第一时间间隔的系统CPU占用率的差值超过指定值之后,持续按照预设的所述第一时间间隔获取所述系统CPU占用率,当所述系统CPU占用率不小于所述第一CPU占用率的持续时长超过指定时长时,获取各应用程序CPU占用率。
  8. 根据权利要求7所述的非易失性计算机可读存储介质,其特征在于,在所述获取各应用程序CPU占用率之前,还包括:
    查找上一次获取各应用程序CPU占用率的时刻;及
    当当前时刻与所述上一次获取各应用程序CPU占用率的时刻的时间差超过第一阈值 时,获取所述各应用程序CPU占用率。
  9. 根据权利要求7所述的非易失性计算机可读存储介质,其特征在于,所述获取系统CPU占用率包括:
    获取连续两次采集的系统CPU累计工作时长的差值作为第一差值;及
    根据所述第一差值和所述第一时间间隔获取系统CPU占用率。
  10. 根据权利要求7所述的非易失性计算机可读存储介质,其特征在于,所述计算机可执行指令被一个或多个处理器执行时,还执行:
    当检测到应用程序对应的CPU占用率超过第二阈值时,检测所述应用程序是否满足预设规则;及
    当所述应用程序不满足预设规则时,停止运行所述应用程序对应的进程。
  11. 根据权利要求10所述的非易失性计算机可读存储介质,其特征在于,在所述停止运行所述应用程序对应的进程之前,还包括:
    在移动终端界面展示所述应用程序对应的异常信息与对所述应用程序的停止运行指令;
    当接收到对所述停止运行指令的触发操作时,停止运行所述应用程序对应的进程。
  12. 根据权利要求7所述的非易失性计算机可读存储介质,其特征在于,所述计算机可执行指令被一个或多个处理器执行时,还执行:
    根据所述系统CPU占用率获取对应的CPU占用级别;
    累计连续维持在所述占用级别的次数;及
    当所述次数达到所述占用级别对应的第三阈值时,确定与所述占用级别对应的繁忙程度。
  13. 一种移动终端,包括存储器及处理器,所述存储器中储存有计算机可读指令,所述指令被所述处理器执行时,使得所述处理器执行如下操作:
    按照预设的第一时间间隔获取系统CPU占用率;
    当当前系统CPU占用率与相邻所述第一时间间隔的系统CPU占用率的差值超过指定值时,将所述当前系统CPU占用率作为第一CPU占用率;及
    当检测到当前系统CPU占用率与相邻所述第一时间间隔的系统CPU占用率的差值超过指定值之后,持续按照预设的所述第一时间间隔获取所述系统CPU占用率,当所述系统CPU占用率不小于所述第一CPU占用率的持续时长超过指定时长时,获取各应用程序CPU占用率。
  14. 根据权利要求13所述的移动终端,其特征在于,在所述获取各应用程序CPU占用率之前,还包括:
    查找上一次获取各应用程序CPU占用率的时刻;及
    当当前时刻与所述上一次获取各应用程序CPU占用率的时刻的时间差超过第一阈值时,获取所述各应用程序CPU占用率。
  15. 根据权利要求13所述的移动终端,其特征在于,所述获取系统CPU占用率包括:
    获取连续两次采集的系统CPU累计工作时长的差值作为第一差值;及
    根据所述第一差值和所述第一时间间隔获取系统CPU占用率。
  16. 根据权利要求13所述的移动终端,其特征在于,所述计算机可执行指令被所述处理器执行时,使得所述处理器还执行:
    当检测到应用程序对应的CPU占用率超过第二阈值时,检测所述应用程序是否满足预设规则;及
    当所述应用程序不满足预设规则时,停止运行所述应用程序对应的进程。
  17. 根据权利要求16所述的移动终端,其特征在于,在所述停止运行所述应用程序对应的进程之前,还包括:
    在移动终端界面展示所述应用程序对应的异常信息与对所述应用程序的停止运行指令;
    当接收到对所述停止运行指令的触发操作时,停止运行所述应用程序对应的进程。
  18. 根据权利要求13所述的移动终端,其特征在于,所述计算机可执行指令被所述处理器执行时,使得所述处理器还执行:
    根据所述系统CPU占用率获取对应的CPU占用级别;
    累计连续维持在所述占用级别的次数;及
    当所述次数达到所述占用级别对应的第三阈值时,确定与所述占用级别对应的繁忙程度。
PCT/CN2018/097535 2017-08-01 2018-07-27 Cpu监测方法、计算机可读存储介质和移动终端 WO2019024804A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710648542.3 2017-08-01
CN201710648542.3A CN107368400B (zh) 2017-08-01 2017-08-01 Cpu监测方法、装置、计算机可读存储介质和移动终端

Publications (1)

Publication Number Publication Date
WO2019024804A1 true WO2019024804A1 (zh) 2019-02-07

Family

ID=60308754

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/097535 WO2019024804A1 (zh) 2017-08-01 2018-07-27 Cpu监测方法、计算机可读存储介质和移动终端

Country Status (2)

Country Link
CN (1) CN107368400B (zh)
WO (1) WO2019024804A1 (zh)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107368400B (zh) * 2017-08-01 2020-02-04 Oppo广东移动通信有限公司 Cpu监测方法、装置、计算机可读存储介质和移动终端
CN107967178B (zh) * 2017-12-06 2020-03-17 Oppo广东移动通信有限公司 资源配置方法和资源配置装置及移动终端和介质
CN109800124B (zh) * 2018-12-15 2023-04-11 中国平安人寿保险股份有限公司 Cpu使用率监控方法、装置、电子设备及存储介质
CN109726003B (zh) * 2019-01-04 2020-09-15 Oppo广东移动通信有限公司 应用解冻的处理方法、电子装置及计算机可读存储介质
CN111414295B (zh) * 2020-03-09 2023-06-30 浙江大华技术股份有限公司 一种cpu占用率的统计方法、装置、设备及介质
CN111930593B (zh) * 2020-07-27 2023-03-28 长沙景嘉微电子股份有限公司 Gpu占用率确定方法、装置、处理系统及存储介质
CN112218411A (zh) * 2020-11-03 2021-01-12 深圳茂硕电子科技有限公司 一种led电源状态监测方法
CN113535516B (zh) * 2021-07-06 2023-05-30 上海上讯信息技术股份有限公司 一种监控cpu占用率异常的方法及设备
CN114003367B (zh) * 2022-01-04 2022-03-15 北京新唐思创教育科技有限公司 风险监控方法、装置、设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20060128231A (ko) * 2005-06-09 2006-12-14 에스케이 텔레콤주식회사 중앙처리장치의 사용률 산출 방법
CN104239196A (zh) * 2014-09-17 2014-12-24 北京金山安全软件有限公司 应用程序运行异常的检测方法、装置和移动终端
CN105224439A (zh) * 2014-07-02 2016-01-06 北京金山安全软件有限公司 终端app的cpu占用率的检测方法、装置及终端
CN105589546A (zh) * 2015-12-21 2016-05-18 北京金山安全软件有限公司 一种信息检测方法及装置
CN107368400A (zh) * 2017-08-01 2017-11-21 广东欧珀移动通信有限公司 Cpu监测方法、装置、计算机可读存储介质和移动终端

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101876933A (zh) * 2009-04-28 2010-11-03 深圳富泰宏精密工业有限公司 Cpu使用率分析系统及方法
CN102110043A (zh) * 2010-12-30 2011-06-29 上海顶竹通讯技术有限公司 一种cpu占用率的计算方法及装置
CN105357026B (zh) * 2015-09-24 2019-07-23 华为技术有限公司 一种资源信息收集方法和计算节点

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20060128231A (ko) * 2005-06-09 2006-12-14 에스케이 텔레콤주식회사 중앙처리장치의 사용률 산출 방법
CN105224439A (zh) * 2014-07-02 2016-01-06 北京金山安全软件有限公司 终端app的cpu占用率的检测方法、装置及终端
CN104239196A (zh) * 2014-09-17 2014-12-24 北京金山安全软件有限公司 应用程序运行异常的检测方法、装置和移动终端
CN105589546A (zh) * 2015-12-21 2016-05-18 北京金山安全软件有限公司 一种信息检测方法及装置
CN107368400A (zh) * 2017-08-01 2017-11-21 广东欧珀移动通信有限公司 Cpu监测方法、装置、计算机可读存储介质和移动终端

Also Published As

Publication number Publication date
CN107368400B (zh) 2020-02-04
CN107368400A (zh) 2017-11-21

Similar Documents

Publication Publication Date Title
US11099900B2 (en) Memory reclamation method and apparatus
WO2019024804A1 (zh) Cpu监测方法、计算机可读存储介质和移动终端
CN107526640B (zh) 资源管理方法、装置、移动终端及计算机可读存储介质
CN107577508B (zh) 应用程序处理方法、装置、可读存储介质和移动终端
WO2019128546A1 (zh) 应用程序处理方法、电子设备、计算机可读存储介质
CN107526638B (zh) 应用程序处理方法、装置、移动终端及存储介质
CN103024205B (zh) 一种功率控制的方法、装置及终端
JP6487044B2 (ja) ユーザ機器のための電力管理方法および電力管理装置
AU2017435232B2 (en) Method for reducing power consumption of terminal, and terminal
WO2019128540A1 (zh) 资源管理方法、移动终端及计算机可读存储介质
CN108334345B (zh) 应用程序处理方法、装置、可读存储介质和移动终端
US10474507B2 (en) Terminal application process management method and apparatus
WO2017206902A1 (zh) 应用控制方法及相关设备
CN107562539B (zh) 应用程序处理方法和装置、计算机设备、存储介质
WO2019128598A1 (zh) 应用处理方法、电子设备、计算机可读存储介质
CN108681498B (zh) 一种cpu占用率的监测方法、装置以及移动终端
KR101939008B1 (ko) 정보 추천 관리 방법, 디바이스 및 시스템
WO2020093208A1 (zh) 应用程序处理方法和装置、计算机设备、计算机可读存储介质
WO2019128537A1 (zh) 应用冻结方法、计算机设备和计算机可读存储介质
CN107526637B (zh) 应用程序处理方法、装置、移动终端及存储介质
CN107870874B (zh) 一种数据写入控制方法及存储设备
JP2014529146A (ja) 中央演算装置を制御するための方法および装置
WO2017206901A1 (zh) 进程控制方法及相关设备
JP7272694B2 (ja) 端末の電力消費を低減するための方法、および端末
WO2019128569A1 (zh) 应用程序冻结方法、装置、存储介质和终端

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18841665

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18841665

Country of ref document: EP

Kind code of ref document: A1