Movatterモバイル変換


[0]ホーム

URL:


CN107368400B - CPU monitoring method and device, computer readable storage medium and mobile terminal - Google Patents

CPU monitoring method and device, computer readable storage medium and mobile terminal
Download PDF

Info

Publication number
CN107368400B
CN107368400BCN201710648542.3ACN201710648542ACN107368400BCN 107368400 BCN107368400 BCN 107368400BCN 201710648542 ACN201710648542 ACN 201710648542ACN 107368400 BCN107368400 BCN 107368400B
Authority
CN
China
Prior art keywords
cpu
occupancy rate
application program
cpu occupancy
mobile terminal
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201710648542.3A
Other languages
Chinese (zh)
Other versions
CN107368400A (en
Inventor
王彬
张俊
帅朝春
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
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 Guangdong Oppo Mobile Telecommunications Corp LtdfiledCriticalGuangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN201710648542.3ApriorityCriticalpatent/CN107368400B/en
Publication of CN107368400ApublicationCriticalpatent/CN107368400A/en
Priority to PCT/CN2018/097535prioritypatent/WO2019024804A1/en
Application grantedgrantedCritical
Publication of CN107368400BpublicationCriticalpatent/CN107368400B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Classifications

Landscapes

Abstract

The embodiment of the invention relates to a CPU monitoring method, a CPU monitoring device, a computer readable storage medium and a mobile terminal. The method comprises the following steps: acquiring the occupancy rate of a system CPU according to a preset first time interval; if the difference value between the current system CPU occupancy rate and the last adjacent system CPU occupancy rate exceeds a specified value, taking the current system CPU occupancy rate as a first CPU occupancy rate; and if the system CPU occupancy rate is not less than the duration of the first CPU occupancy rate and exceeds a specified duration, acquiring the CPU occupancy rate of each application program. According to the method, when the CPU occupancy rate of the system is detected to be greatly increased and lasts for a long time, the CPU occupancy rate of the application program corresponding to the currently running application program in the mobile terminal can be acquired if the fact that the application program in the mobile terminal consumes a large amount of CPU resources can be judged. When the total CPU of the system is rapidly increased, the CPU occupancy rate corresponding to the application program can be obtained in time, the monitoring of the CPU occupancy rate of the application program is facilitated, and abnormal application programs are identified.

Description

Translated fromChinese
CPU监测方法、装置、计算机可读存储介质和移动终端CPU monitoring method, device, computer-readable storage medium and mobile terminal

技术领域technical field

本发明涉及计算机技术领域,特别是涉及一种CPU监测方法、装置、计算机可读存储介质和移动终端。The present invention relates to the field of computer technology, and in particular, to a CPU monitoring method, device, computer-readable storage medium and mobile terminal.

背景技术Background technique

随着智能移动终端的迅速发展,用户对智能移动终端的性能要求越来越高。在智能移动终端中,智能移动终端系统程序运行、第三方应用程序运行均需要消耗智能移动终端的系统资源,当智能移动终端的系统资源被大量消耗时,会影响智能移动终端的运行效率。With the rapid development of intelligent mobile terminals, users have higher and higher requirements for the performance of intelligent mobile terminals. In the intelligent mobile terminal, the operation of the intelligent mobile terminal system program and the operation of the third-party application program consumes the system resources of the intelligent mobile terminal. When the system resources of the intelligent mobile terminal are greatly consumed, the operation efficiency of the intelligent mobile terminal will be affected.

发明内容SUMMARY OF THE INVENTION

本发明实施例提供一种CPU监测方法、装置、计算机可读存储介质和移动终端,可以监测移动终端中应用程序的CPU占用率。Embodiments of the present invention provide a CPU monitoring method, device, computer-readable storage medium, and mobile terminal, which can monitor the CPU occupancy rate of an application program in the mobile terminal.

一种CPU监测方法,包括:A CPU monitoring method, comprising:

按照预设的第一时间间隔获取系统CPU占用率;Obtain the system CPU occupancy rate according to the preset first time interval;

若当前系统CPU占用率与相邻上一次系统CPU占用率的差值超过指定值,将所述当前系统CPU占用率作为第一CPU占用率;If the difference between the current system CPU occupancy rate and the adjacent last system CPU occupancy rate exceeds the specified value, the current system CPU occupancy rate is used as the first CPU occupancy rate;

若系统CPU占用率不小于所述第一CPU占用率的持续时长超过指定时长,获取各应用程序CPU占用率。If the system CPU occupancy rate is not less than the first CPU occupancy rate and the duration exceeds the specified time period, obtain the CPU occupancy rate of each application program.

一种CPU监测装置,包括:A CPU monitoring device, comprising:

第一获取模块,用于按照预设的第一时间间隔获取系统CPU占用率;a first obtaining module, configured to obtain the system CPU occupancy rate according to a preset first time interval;

差值模块,用于若当前系统CPU占用率与相邻上一次系统CPU占用率的差值超过指定值,将所述当前系统CPU占用率作为第一CPU占用率;A difference module, used for taking the current system CPU occupancy rate as the first CPU occupancy rate if the difference between the current system CPU occupancy rate and the adjacent last system CPU occupancy rate exceeds a specified value;

第二获取模块,用于若系统CPU占用率不小于所述第一CPU占用率的持续时长超过指定时长,获取各应用程序CPU占用率。The second obtaining module is configured to obtain the CPU occupancy rate of each application program if the duration of the system CPU occupancy rate not less than the first CPU occupancy rate exceeds the specified time period.

一个或多个包含计算机可执行指令的非易失性计算机可读存储介质,当所述计算机可执行指令被一个或多个处理器执行时,使得所述处理器执行如上所述的CPU监测方法。One or more non-volatile computer-readable storage media containing computer-executable instructions that, when executed by one or more processors, cause the processors to perform the CPU monitoring method described above .

一种移动终端,包括存储器及处理器,所述存储器中储存有计算机可读指令,所述指令被所述处理器执行时,使得所述处理器执行如上所述的CPU监测方法。A mobile terminal includes a memory and a processor, wherein computer-readable instructions are stored in the memory, and when the instructions are executed by the processor, the processor executes the CPU monitoring method described above.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative efforts.

图1为一个实施例中移动终端的内部结构示意图;1 is a schematic diagram of the internal structure of a mobile terminal in one embodiment;

图2为一个实施例中CPU监测方法的流程图;2 is a flowchart of a CPU monitoring method in one embodiment;

图3为另一个实施例中CPU监测方法的流程图;3 is a flowchart of a CPU monitoring method in another embodiment;

图4为另一个实施例中CPU监测方法的流程图;4 is a flowchart of a CPU monitoring method in another embodiment;

图5为另一个实施例中CPU监测方法的流程图;5 is a flowchart of a CPU monitoring method in another embodiment;

图6为另一个实施例中CPU监测方法的流程图;6 is a flowchart of a CPU monitoring method in another embodiment;

图7为另一个实施例中CPU监测方法的流程图;7 is a flowchart of a CPU monitoring method in another embodiment;

图8为一个实施例中CPU监测装置的结构框图;8 is a structural block diagram of a CPU monitoring device in one embodiment;

图9为另一个实施例中CPU监测装置的结构框图;9 is a structural block diagram of a CPU monitoring device in another embodiment;

图10为另一个实施例中CPU监测装置的结构框图;Fig. 10 is a structural block diagram of a CPU monitoring device in another embodiment;

图11为另一个实施例中CPU监测装置的结构框图;11 is a structural block diagram of a CPU monitoring device in another embodiment;

图12为与本发明实施例提供的移动终端相关的手机的部分结构的框图。FIG. 12 is a block diagram of a partial structure of a mobile phone related to a mobile terminal provided by an embodiment of the present invention.

具体实施方式Detailed ways

为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。In order to make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention.

可以理解,本发明所使用的术语“第一”、“第二”等可在本文中用于描述各种元件,但这些元件不受这些术语限制。这些术语仅用于将第一个元件与另一个元件区分。举例来说,在不脱离本发明的范围的情况下,可以将第一获取模块称为第二获取模块,且类似地,可将第二获取模块称为第一获取模块。第一获取模块和第二获取模块两者都是获取模块,但其不是同一获取模块。It will be understood that the terms "first", "second", etc., as used herein, may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, a first acquisition module may be referred to as a second acquisition module, and similarly, a second acquisition module may be referred to as a first acquisition module, without departing from the scope of the present invention. Both the first acquisition module and the second acquisition module are acquisition modules, but they are not the same acquisition module.

图1为一个实施例中移动终端的内部结构示意图。如图1所示,该移动终端包括通过系统总线连接的处理器、非易失性存储介质、内存储器、网络接口、显示屏和输入装置。其中,移动终端的非易失性存储介质存储有操作系统和计算机可读指令。该计算机可读指令被处理器执行时以实现一种CPU监测方法。该处理器用于提供计算和控制能力,支撑整个移动终端的运行。移动终端中的内存储器为非易失性存储介质中的计算机可读指令的运行提供环境。网络接口用于与服务器进行网络通信。移动终端的显示屏可以是液晶显示屏或者电子墨水显示屏等,输入装置可以是显示屏上覆盖的触摸层,也可以是移动终端外壳上设置的按键、轨迹球或触控板,也可以是外接的键盘、触控板或鼠标等。该移动终端可以是手机、平板电脑或者个人数字助理或穿戴式设备等。本领域技术人员可以理解,图1中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的移动终端的限定,具体的移动终端可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。FIG. 1 is a schematic diagram of the internal structure of a mobile terminal in one embodiment. As shown in FIG. 1 , the mobile terminal includes a processor, a non-volatile storage medium, an internal memory, a network interface, a display screen and an input device connected through a system bus. The non-volatile storage medium of the mobile terminal stores an operating system and computer-readable instructions. The computer readable instructions, when executed by a processor, 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 execution of computer readable instructions in the 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 screen or an electronic ink display screen, etc., and the input device may be a touch layer covered on the display screen, a button, a trackball or a touchpad set on the casing of the mobile terminal, or a An external keyboard, trackpad, or mouse, etc. The mobile terminal may be a mobile phone, a tablet computer, a personal digital assistant, a wearable device, or the like. Those skilled in the art can understand that the structure shown in 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 on the mobile terminal to which the solution of the present application is applied. The specific mobile terminal may be Include more or fewer components than shown in the figures, or combine certain components, or have a different arrangement of components.

图2为一个实施例中CPU监测方法的流程图。如图2所示,一种CPU监测方法,包括步骤202至步骤206。其中:FIG. 2 is a flowchart of a CPU monitoring method in one embodiment. As shown in FIG. 2 , a CPU monitoring method includessteps 202 to 206 . in:

步骤202,按照预设的第一时间间隔获取系统CPU占用率。Step 202: Acquire the system CPU occupancy rate according to a preset first time interval.

移动终端在运行时,移动终端内系统程序和第三方程序均会消耗移动终端内CPU(Central Processing Unit,中央处理器)资源。移动终端系统CPU占用率即为移动终端中运行的所有程序占用的CPU资源,包括系统运行程序和第三方运行程序。一般来说,系统CPU占用率越高、移动终端内运行的程序越多;系统CPU占用率越低、移动终端内运行的程序越少。移动终端可按照预设的第一时间间隔获取系统CPU占用率,预设的第一时间间隔可为用户设定的时间间隔,也可为根据历史采集时间得到的时间间隔。When the mobile terminal is running, both the system program and the third-party program in the mobile terminal consume CPU (Central Processing Unit, central processing unit) resources in the mobile terminal. The CPU occupancy rate of the mobile terminal system is the CPU resources occupied by all programs running in the mobile terminal, including system running programs and third-party running programs. Generally speaking, the higher the system CPU occupancy rate, the more programs running in the mobile terminal; the lower the system CPU occupancy rate, the fewer programs running in the mobile terminal. The mobile terminal may acquire the system CPU occupancy rate according to a preset first time interval, and the preset first time interval may be a time interval set by a user, or may be a time interval obtained according to a historical collection time.

移动终端获取系统CPU占用率的步骤可包括:移动终端按照预设的第一时间间隔采集系统CPU累计工作时长,获取连续两次采集的CPU累计工作时长中后一次CPU累计工作时长与前一次CPU累计工作时长的差值,上述差值即为系统CPU在预设的第一时间间隔内真正工作的时间,上述差值与预设的第一时间间隔的比值即在预设的第一时间间隔内系统CPU占用率。上述CPU累计工作时长为移动终端自启动到当前时刻CPU工作的总时长。上述预设的第一时间间隔可为5秒至20秒中任一时长,优选的,可为5秒。例如,移动终端每隔5秒采集一次系统CPU累计工作时长,若连续两次采集的CPU累计工作时长分别为60分03秒和60分04秒,则在这5秒的时间内系统CPU占用率为20%。The step of acquiring the system CPU occupancy rate by the mobile terminal may include: the mobile terminal collects the cumulative working time of the system CPU according to a preset first time interval, and obtains the cumulative working time of the CPU collected for two consecutive times, and the cumulative working time of the latter CPU is the same as the previous CPU cumulative working time. The difference between the accumulated working hours, the difference is the actual working time of the system CPU within the preset first time interval, and the ratio of the difference to the preset first time interval is the preset first time interval. Internal system CPU usage. The above-mentioned cumulative working time of the CPU is the total working time of the CPU from the start of the mobile terminal to the current moment. The above-mentioned preset first time interval may be any length from 5 seconds to 20 seconds, and preferably, it may be 5 seconds. For example, the mobile terminal collects the cumulative working time of the system CPU every 5 seconds. If the cumulative working time of the CPU collected for two consecutive times is 60 minutes 03 seconds and 60 minutes 04 seconds, respectively, the system CPU usage rate during these 5 seconds is calculated. 20%.

在Android系统中,可在/proc目录下读取系统CPU相关信息。其中,/proc目录下stat文件包含了系统CPU活动的所有信息,上述系统CPU活动的所有信息均为移动终端自启动到当前时刻CPU活动累计的时长。移动终端中CPU监控模块可定时读取/proc目录下系统CPU活动信息,再获取移动终端在采集时间内的系统CPU占用率。In the Android system, you can read system CPU-related information in the /proc directory. Among them, the stat file in the /proc directory contains all the information of the system CPU activity, and all the above-mentioned system CPU activity information is the accumulated time duration of the CPU activity from the mobile terminal to the current moment. 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 occupancy rate of the mobile terminal during the collection time.

步骤204,若当前系统CPU占用率与相邻上一次系统CPU占用率的差值超过指定值,将当前系统CPU占用率作为第一CPU占用率。Step 204, if the difference between the current system CPU occupancy rate and the adjacent last system CPU occupancy rate exceeds a specified value, the current system CPU occupancy rate is taken as the first CPU occupancy rate.

移动终端在获取到当前系统CPU占用率后,会把当前系统CPU占用率与相邻上一次系统CPU占用率作差,获取系统CPU占用率差值。若上述系统CPU占用率差值超过指定值,则判定移动终端系统CPU占用率变化较大,移动终端内系统CPU占用率异常。一般情况下,上述指定值设定为正数,可为15%至20%任一数字,优选的可为20%。系统CPU占用率差值大于上述指定值,即移动终端系统CPU占用率突然增大,移动终端系统CPU占用率异常。将获取的当前系统CPU占用率作为第一CPU占用率,即异常CPU占用率。After obtaining the current system CPU usage, the mobile terminal will make a difference between the current system CPU usage and the adjacent previous system CPU usage to obtain the difference in system CPU usage. If the difference in the above-mentioned system CPU occupancy rate exceeds the specified value, it is determined that the system CPU occupancy rate of the mobile terminal changes greatly, and the system CPU occupancy rate in the mobile terminal is abnormal. In general, the above specified value is set as a positive number, which can be any number from 15% to 20%, preferably 20%. If the difference in the system CPU usage is greater than the specified value, that is, the CPU usage of the mobile terminal system suddenly increases, and the CPU usage of the mobile terminal system is abnormal. The obtained current system CPU usage is taken as the first CPU usage, that is, the abnormal CPU usage.

步骤206,若系统CPU占用率不小于第一CPU占用率的持续时长超过指定时长,获取各应用程序CPU占用率。Step 206, if the system CPU occupancy rate is not less than the first CPU occupancy rate and the duration exceeds the specified time period, obtain the CPU occupancy rate of each application program.

在移动终端获取第一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占用率。After the mobile terminal obtains the first CPU occupancy rate, the mobile terminal obtains the system CPU occupancy rate of the mobile terminal for a preset number of times according to the preset first time interval again, and sequentially compares the obtained system CPU occupancy rate with the first CPU occupancy rate . If the obtained system CPU usage is not less than the first CPU usage, the system CPU usage is not less than the abnormal CPU usage and the duration exceeds the specified duration, that is, there are applications in the mobile terminal that continue to consume a large amount of CPU resources. Obtain the mobile terminal. CPU usage of each application. The above-mentioned preset first time interval can be any time from 5 seconds to 30 seconds, and preferably, it can be 5 seconds. For example, if the system CPU occupancy rate collected by the mobile terminal for two consecutive times is 20% and 40%, and the difference between the system CPU occupancy rate is greater than the specified value of 15%, the system CPU occupancy rate is 40% as the first CPU occupancy rate. According to the preset first time interval, the system CPU occupancy rate is collected every 5 seconds, and the system CPU occupancy rate is collected 4 times, which are 42%, 45%, 47%, and 50% respectively. Exceeds 40%, that is, the duration of the mobile terminal system CPU usage exceeding 40% reaches 20 seconds and exceeds the specified duration of 18 seconds, and obtains the CPU usage of each application program in the mobile terminal.

移动终端获取各应用程序CPU占用率的步骤可包括:按照预设的第二时间间隔采集移动终端中正在运行的各个应用程序的占用CPU的累计时长,获取连续两次采集的应用程序的占用CPU的累计时长中后一次占用CPU的累计时长与前一次占用CPU的累计时长的差值,上述差值为应用程序在第二时间间隔内占用CPU的时间,上述差值与第二时间间隔的比值为在第二时间间隔应用程序CPU占用率。上述第一时间间隔和第二时间间隔可为相同值或不同值。The step of acquiring the CPU occupancy rate of each application program by the mobile terminal may include: collecting the cumulative CPU occupancy time of each application program running in the mobile terminal according to a preset second time interval, and acquiring the occupied CPU occupancy of the application program collected twice in a row The difference between the cumulative duration of the last CPU usage and the cumulative duration of the previous CPU usage, the difference is the time the application occupies the CPU in the second time interval, and the ratio of the difference to the second time interval for the application CPU usage at the second interval. The above-mentioned first time interval and second time interval may be the same value or different values.

在Android系统中,/proc/pid目录下sats文件包含了应用程序对应的进程占用CPU的信息。上述应用程序对应的进程占用CPU的信息为应用程序自启动后占用CPU的累计时长。移动终端中CPU监控模块可定时读取/proc/pid目录下各应用程序占用CPU的累计时长,再获取应用程序在采集时间内应用程序CPU占用率。In the Android system, the sats file in the /proc/pid directory contains information about the CPU usage of the process corresponding to the application. The information about the CPU occupied by the process corresponding to the above application program is the cumulative duration of the CPU occupied by the application program since it was started. The CPU monitoring module in the mobile terminal can periodically read the cumulative duration of CPU usage by each application in the /proc/pid directory, and then obtain the application CPU usage during the collection time.

本发明实施例中CPU监测方法,按照预设的第一时间间隔采集系统CPU占用率,即移动终端中总CPU占用率,当检测到系统CPU占用率大幅度增大时且持续较长时间时,可判定移动终端中存在应用程序大量消耗CPU资源,则获取移动终端中当前运行的应用程序对应的应用程序CPU占用率。上述方法,在系统总CPU迅速增大时,能够及时获取应用程序对应的CPU占用率,有利于监控应用程序的CPU占用率,识别异常应用程序。The CPU monitoring method in the embodiment of the present invention collects the system CPU occupancy rate, that is, the total CPU occupancy rate in the mobile terminal, according to a preset first time interval. When it is detected that the system CPU occupancy rate increases significantly and lasts for a long time , it can be determined that an application program in the mobile terminal consumes a large amount of CPU resources, and then the application program CPU occupancy rate corresponding to the application program currently running in the mobile terminal is obtained. In the above method, when the total CPU of the system increases rapidly, the CPU occupancy rate corresponding to the application program can be obtained in time, which is beneficial to monitor the CPU occupancy rate of the application program and identify abnormal application programs.

在一个实施例中,在获取各应用程序CPU占用率之前,上述CPU监测方法还包括:In one embodiment, before acquiring the CPU occupancy rate of each application, the above-mentioned CPU monitoring method further includes:

步骤302,查找上一次获取各应用程序CPU占用率的时刻。Step 302: Find the last time when the CPU usage of each application was obtained.

步骤304,若当前时刻与上一次获取各应用程序CPU占用率的时刻的时间差超过第一阈值,获取各应用程序CPU占用率。Step 304 , if the time difference between the current moment and the moment when the CPU occupancy rate of each application program was acquired last time exceeds a first threshold, acquire the CPU occupancy rate of each application program.

移动终端在获取各应用程序对应的应用程序CPU占用率之前,会查找上一次获取各应用程序CPU占用率的时刻,获取当前时刻与上一次获取各应用程序CPU占用率时刻之间的时间差。若上述时间差超过预设的第一阈值,则获取应用程序CPU占用率。获取应用程序CPU占用率的步骤与步骤206中获取应用程序CPU占用率的步骤相同,在此不再赘述。若上述时间差未超过预设的第一阈值,则直接获取上一次采集的各应用程序CPU占用率作为当前各应用程序CPU占用率。上述第一阈值可为用户设定的值,也可为根据历史采集的各应用程序CPU占用率数据分析得到的数值,如30秒,1分钟等。Before acquiring the CPU usage of each application corresponding to the mobile terminal, the mobile terminal searches for the time when the CPU usage of each application was obtained last time, and obtains the time difference between the current time and the last time when the CPU usage of each application was obtained. If the above-mentioned time difference exceeds the preset first threshold, the CPU usage rate of the application program is obtained. The step of acquiring the CPU usage rate of the application program is the same as the step of acquiring the CPU usage rate of the application program instep 206, and details are not repeated here. If the above-mentioned time difference does not exceed the preset first threshold, the CPU occupancy rate of each application program collected last time is directly obtained as the current CPU occupancy rate of each application program. The above-mentioned 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 program collected historically, such as 30 seconds, 1 minute, and the like.

移动终端中应用程序CPU占用率在短时间内不会发生变化,且获取各应用程序CPU占用率需要消耗一定的系统资源。本发明实施例中CPU监测方法,在接收到获取各应用程序对应的应用程序CPU占用率请求后,先获取当前时刻与上一次获取各应用程序对应的应用程序CPU占用率时刻的时间差,判断时间差与预设时长的关系,在时间差较短时,直接将上一次获取的各应用程序CPU占用率作为当前各应用程序CPU占用率,在时间差较长时,在重新获取各应用程序CPU占用率。既保证了获取个应用程序CPU占用率的准确性,有降低了系统功耗,节省了系统资源。The CPU occupancy rate of the application program in the mobile terminal will not change in a short time, and obtaining the CPU occupancy rate of each application program needs to consume a certain amount of system resources. In the CPU monitoring method according to the embodiment of the present invention, after receiving a request for obtaining the application program CPU occupancy rate corresponding to each application program, first obtain the time difference between the current moment and the last time when the application program CPU occupancy rate corresponding to each application program was obtained, and determine the time difference In relation to the preset duration, when the time difference is short, the CPU usage of each application program obtained last time is directly used as the current CPU usage rate of each application program, and when the time difference is long, the CPU usage rate of each application program is re-acquired. It not only ensures the accuracy of obtaining the CPU occupancy rate of an application program, but also reduces system power consumption and saves system resources.

在一个实施例中,步骤202获取系统CPU占用率包括:In one embodiment, step 202 to obtain the system CPU usage includes:

(1)获取连续两次采集的系统CPU累计工作时长的差值作为第一差值。(1) Obtain the difference between the accumulated working hours of the system CPU collected twice in a row as the first difference.

(2)根据第一差值和时间间隔获取系统CPU占用率。(2) Obtaining the system CPU occupancy rate according to the first difference value and the time interval.

在Android系统中,可在/proc目录下读取系统CPU相关信息。其中,/proc目录下stat文件包含了系统CPU活动的所有信息,上述系统CPU活动的所有信息均为移动终端自启动到当前时刻CPU活动累计的时长。移动终端中CPU监控模块可定时读取/proc目录下系统CPU活动信息,再获取移动终端在采集时间内的系统CPU占用率。移动终端获取系统CPU占用率的步骤可包括:移动终端按照预设的第一时间间隔采集系统CPU累计工作时长,获取连续两次采集的CPU累计工作时长中后一次CPU累计工作时长与前一次CPU累计工作时长的差值,上述差值即为系统CPU在预设的第一时间间隔内真正工作的时间,上述差值与预设的第一时间间隔的比值即在预设的第一时间间隔内系统CPU占用率。上述CPU累计工作时长为移动终端自启动到当前时刻CPU工作的总时长。上述预设的第一时间间隔可为5秒至20秒中任一时长,优选的,可为5秒。In the Android system, you can read system CPU-related information in the /proc directory. Among them, the stat file in the /proc directory contains all the information of the system CPU activity, and all the above-mentioned system CPU activity information is the accumulated time duration of the CPU activity from the mobile terminal to the current moment. 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 occupancy rate of the mobile terminal during the collection time. The step of acquiring the system CPU occupancy rate by the mobile terminal may include: the mobile terminal collects the cumulative working time of the system CPU according to a preset first time interval, and obtains the cumulative working time of the CPU collected for two consecutive times, and the cumulative working time of the latter CPU is the same as the previous CPU cumulative working time. The difference between the accumulated working hours, the difference is the actual working time of the system CPU within the preset first time interval, and the ratio of the difference to the preset first time interval is the preset first time interval. Internal system CPU usage. The above-mentioned cumulative working time of the CPU is the total working time of the CPU from the start of the mobile terminal to the current moment. The above-mentioned preset first time interval may be any length from 5 seconds to 20 seconds, and preferably, it may be 5 seconds.

在一个实施例中,上述CPU监测方法还包括:In one embodiment, the above-mentioned CPU monitoring method further includes:

步骤402,若检测到应用程序对应的CPU占用率超过第二阈值,检测应用程序是否满足预设规则。Step 402, if it is detected that the CPU occupancy rate corresponding to the application program exceeds the second threshold, it is detected whether the application program satisfies the preset rule.

步骤404,若否,停止运行应用程序对应的进程。Step 404, if no, stop the process corresponding to the running application.

移动终端在获取到各应用程序对应的CPU占用率后,依次比较各应用程序对应的CPU占用率是否超过预设的第二阈值,若超过预设的第二阈值,则表示应用程序CPU占用率过高,进一步检测上述应用程序是否满足预设规则。上述第二阈值可为用户设定的值,也可为根据历史获取的应用程序CPU占用率分析得到的值,如上述第二阈值可为20%。预设规则包括:系统白名单中应用程序、前台运行的应用程序、应用程序正在执行预设行为(包括下载文件、上传文件、应用程序更新等)、优先级较高的应用程序、播放音乐的应用程序等。上述预设规则可为用户设置的规则。当应用程序满足上述预设规则时,不对应用程序进行处理,如对用户设置的白名单中应用程序不进行处理、对用户设置的优先级前三的应用程序不进行处理。当应用程序不满足上述预设规则时,停止运行上述应用程序对应的进程。其中,停止运行上述应用程序对应的进程包括:关闭或挂起应用程序对应的进程等方式,其中,关闭应用程序对应的进程指的是终止(kill)应用程序对应的进程,挂起应用程序对应的进程指的是暂停应用程序对应的进程的运行,可将挂起的应用程序对应的进程加入等待队列中,当系统CPU占用率较低时,再恢复应用程序对应的进程的运行。After obtaining the CPU occupancy rate corresponding to each application program, the mobile terminal sequentially compares whether the CPU occupancy rate corresponding to each application program exceeds a preset second threshold, and if it exceeds the preset second threshold, it means that the application program CPU occupancy rate If it is too high, further check whether the above application satisfies the preset rules. The above-mentioned second threshold may be a value set by the user, or may be a value obtained by analyzing the CPU occupancy rate of the application program obtained from the history, for example, the above-mentioned second threshold may be 20%. The preset rules include: applications in the system whitelist, applications running in the foreground, applications that are performing preset behaviors (including downloading files, uploading files, application updates, etc.), applications with higher priority, and applications that play music. applications, etc. The above preset rules may be rules set by the user. When the application satisfies the above preset rules, the application is not processed, for example, the application in the whitelist set by the user is not processed, and the application with the top three priorities set by the user is not processed. When the application program does not satisfy the above-mentioned preset rule, the process corresponding to the above-mentioned application program is stopped. Wherein, stopping the process corresponding to the application program includes: closing or suspending the process corresponding to the application program. The process refers to suspending the running of the process corresponding to the application. The process corresponding to the suspended application can be added to the waiting queue. When the system CPU usage is low, the running of the process corresponding to the application can be resumed.

本发明实施例中CPU监测方法,在移动终端中应用程序CPU占用率较高时,检测应用程序是否为移动终端预设的不处理应用程序或用户设定的不处理应用程序。当不是不处理应用程序时,停止运行应用程序对应的进行,即对CPU占用率异常的应用程序进行查杀处理,避免了移动终端中异常应用程序大量耗费CPU资源,造成移动终端系统卡顿、发热等。其中,预设规则可以保证应用程序正常占用大量CPU资源的情况下,应用程序不被清理,提高了识别异常应用程序的精确度,查杀的异常应用程序更准确。In the CPU monitoring method in the embodiment of the present invention, when the CPU occupancy rate of the application program in the mobile terminal is high, it is detected whether the application program is a non-processing application program preset by the mobile terminal or a non-processing application program set by the user. When it is not that the application is not processed, the corresponding process of running the application is stopped, that is, the application with abnormal CPU usage is detected and killed, so as to avoid the abnormal application in the mobile terminal consuming a lot of CPU resources, causing the mobile terminal system to freeze, fever, etc. Among them, the preset rules can ensure that the application program is not cleaned up when the application program normally occupies a large amount of CPU resources, which improves the accuracy of identifying abnormal application programs, and detects and kills abnormal application programs more accurately.

在一个实施例中,上述CPU监测方法还包括:In one embodiment, the above-mentioned CPU monitoring method further includes:

步骤502,根据系统CPU占用率获取对应的CPU占用级别。Step 502: Obtain the corresponding CPU occupancy level according to the system CPU occupancy rate.

可预先划分多个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等。Multiple CPU occupancy levels can be pre-divided, and each occupancy level can correspond to a different occupancy rate range. For example, four CPU occupancy levels are divided, including L1, L2, L3, and L4. The occupancy rate range corresponding to the L1 occupancy level is If the occupancy rate is less than 20%, the occupancy rate corresponding to the L2 occupancy level ranges from 20% to 40%, the occupancy rate corresponding to the L3 occupancy level ranges from 40% to 60%, and the occupancy rate corresponding to the L4 occupancy level ranges from more than 60%. this. The mobile terminal collects the system CPU occupancy rate according to the preset first time interval, determines the occupancy rate range in which the collected system CPU occupancy rate falls, and obtains the CPU occupancy level corresponding to the occupancy rate range. For example, if the collected system CPU usage is 18%, the CPU usage level is L1, and if the system CPU usage is 25%, the CPU usage level is L2, and so on.

步骤504,累计连续维持在占用级别的次数。Step 504: Accumulate the number of times that the occupancy level is continuously maintained.

移动终端可为每个CPU占用级别分配一个级别计数器,通过级别计数器记录CPU维持在对应的占用级别的连续次数,其中,CPU维持在某个占用级别,指的是CPU一直处于该占用级别或以上的占用级别,例如,CPU占用级别变化为L2占用级别、L3占用级别、L2占用级别,则可认为CPU维持在L2占用级别,连续次数为3。The mobile terminal can allocate a level counter for each CPU occupancy level, and use the level counter to record the consecutive times that the CPU is maintained at the corresponding occupancy level. For example, if the CPU occupancy level changes to L2 occupancy level, L3 occupancy level, and L2 occupancy level, it can be considered that the CPU is maintained at the L2 occupancy level, and the number of consecutive times is 3.

在一个实施例中,移动终端按照预设的第一时间间隔采集系统CPU占用率,并确定CPU占用级别,可分别在该占用级别及以下的占用级别对应的级别计数器中加1,并将其他占用级别的级别计数器清零。例如,本次的CPU占用级别为L3,则将L1、L2及L3的级别计数器分别加1,L4的级别计数器清零,下一次的CPU占用级别为L2,则将L1、L2的级别计数器分别加1,L3、L4的级别计数器清零。In one embodiment, the mobile terminal collects the CPU occupancy rate of the system according to a preset first time interval, and determines the CPU occupancy level. The occupancy level's level counter is cleared. For example, if the CPU occupancy level this time is L3, the level counters of L1, L2, and L3 are incremented by 1, and the level counter of L4 is cleared. The next time the CPU occupancy level is L2, the level counters of L1 and L2 are respectively Add 1, and the level counters of L3 and L4 are cleared.

在一个实施例中,可划分占用级别的类型,其中,类型可包括为空闲级别及繁忙级别,例如,将L1占用级别作为空闲级别,将L2、L3、L4占用级别作为繁忙级别,分别代表不同的繁忙程度。移动终端每隔预设的第一时间间隔采集系统CPU占用率,并计算CPU占用级别,可先确定对应的类型,再分别在该占用级别及以下的属于同一类型的占用级别对应的级别计数器中加1,并将其他占用级别的级别计数器清零。例如,本次的CPU占用级别为L1,属于空闲级别,则将L1的级别计数器加1,L2、L3及L4的级别计数器清零,下一次的CPU占用级别为L3,属于繁忙级别,则将L3以及同属于繁忙级别的L2的级别计数器分别加1,L1、L4的级别计数器清零。In one embodiment, the types of occupancy levels may be divided, wherein the types may include idle levels and busy levels. For example, the L1 occupancy level is used as the idle level, and the L2, L3, and L4 occupancy levels are used as the busy levels, respectively representing different busyness. The mobile terminal collects the system CPU occupancy rate every preset first time interval, and calculates the CPU occupancy level. The corresponding type can be determined first, and then the level counters corresponding to the occupancy level of the same type and below the occupancy level are respectively recorded. Increments by 1 and clears the level counters for other occupancy levels. For example, if the CPU occupancy level this time is L1, which 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 to zero. The next CPU occupancy level is L3, which belongs to the busy level. The level counters of L3 and L2 that belong to the same busy level are incremented by 1 respectively, and the level counters of L1 and L4 are cleared to zero.

步骤506,当次数达到占用级别对应的第三阈值时,确定与占用级别对应的繁忙程度。Step 506, when the number of times reaches the third threshold corresponding to the occupancy level, determine the busyness level corresponding to the occupancy level.

可为每个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稳定的工作状态。A corresponding third threshold can be set for each CPU occupancy level, and the third threshold can be used to determine whether the CPU of the mobile terminal is maintained in the working state of the corresponding occupancy level. The mobile terminal accumulates the number of times the CPU is continuously maintained at each occupancy level through the level counter. When the number of times the CPU is continuously maintained at the occupancy level reaches a third threshold corresponding to the occupancy level, it can be determined that the CPU is stable in the working state of the occupancy level. . For example, for L1, L2, L3 and L4, set a corresponding third threshold as c1, c2, c3 and c4 respectively. 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. middle. Further, the third threshold corresponding to each occupancy level may decrease as the occupancy level increases. For example, 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 not limited thereto. In one embodiment, if there are multiple occupancy levels with the number of times of continuous maintenance reaching the corresponding third threshold at the same time, the occupancy level of the highest level is selected as the stable working state of the CPU.

本发明实施例中CPU监测方法,对CPU占用率设定不同的占用级别,根据维持在占用级别的次数确定移动终端的繁忙程度,有利于根据移动终端的繁忙程序对应用程序进行不同的处理,如在占用级别较高,系统较繁忙时,直接关闭异常应用程序对应的进程;在占用级别较低,系统较空闲时,挂起异常应用程序对应的进程,提高了处理异常应用程序的灵活性。In the CPU monitoring method in the embodiment of the present invention, different occupancy levels are set for the CPU occupancy rate, and the busy degree of the mobile terminal is determined according to the number of times the occupancy level is maintained, which is beneficial to different processing of the application program according to the busy program of the mobile terminal. For example, when the occupation level is high and the system is busy, the process corresponding to the abnormal application is directly closed; when the occupation level is low and the system is idle, the process corresponding to the abnormal application is suspended, which improves the flexibility of handling abnormal applications. .

在一个实施例中,在停止运行应用程序对应的进程之前,上述CPU监测方法还包括:In one embodiment, before stopping the process corresponding to the running application, the above-mentioned CPU monitoring method further includes:

步骤602,在移动终端界面展示应用程序对应的异常信息、对应用程序的停止运行指令。Step 602 , displaying abnormal information corresponding to the application program and a stop running instruction for the application program on the mobile terminal interface.

步骤604,若接收到对停止运行指令的触发操作,停止运行应用程序对应的进程。Step 604, if a triggering operation for the stop running instruction is received, stop running the process corresponding to the application program.

移动终端在停止运行应用程序对应的进程之前,还可在移动终端界面展示应用程序对应的异常信息。上述异常信息可包括:应用程序当前CPU占用率,应用程序当前程序行为(如后台下载文件等)、应用程序当前占用网速等。除展示应用程序的停止运行指令外,还可展示取消指令。若获取到对取消指令的触发操作,则对应用程序不进行处理;若获取到对停止运行指令的触发操作,则停止运行应用程序对应的进程。Before the mobile terminal stops running the process corresponding to the application, the abnormal information corresponding to the application may also be displayed on the interface of the mobile terminal. The above exception 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.), the network speed currently occupied by the application, and the like. In addition to showing the stop command of the application, the cancel command can also be shown. If the trigger operation for the cancel instruction is obtained, the application program is not processed; if the trigger operation for the stop operation instruction is obtained, the process corresponding to the application program is stopped.

本发明实施例中CPU监测方法,在检测出异常应用程序后,在移动终端界面展示应用程序对应的异常信息,接收到用户停止运行指令后在对应用程序对应的进程进行停止运行,可以避免对应用程序查杀的误操作,提高了应用程序查杀的精度。In the CPU monitoring method in the embodiment of the present invention, after an abnormal application program is detected, the abnormal information corresponding to the application program is displayed on the interface of the mobile terminal, and the process corresponding to the application program is stopped after receiving the user's stop operation instruction, which can avoid any The misoperation of application detection and killing improves the precision of application detection and killing.

图7为另一个实施例中CPU监测方法的流程图。如图7所示,一种CPU监测方法,包括步骤702至步骤714。其中:FIG. 7 is a flowchart of a CPU monitoring method in another embodiment. As shown in FIG. 7 , a CPU monitoring method includessteps 702 to 714 . in:

步骤702,按照预设的第一时间间隔获取系统CPU占用率。上述获取系统CPU占用率包括:Step 702: Acquire the system CPU occupancy rate according to a preset first time interval. The above obtained system CPU usage includes:

(1)获取连续两次采集的系统CPU累计工作时长的差值作为第一差值。(1) Obtain the difference between the accumulated working hours of the system CPU collected twice in a row as the first difference.

(2)根据第一差值和时间间隔获取系统CPU占用率。(2) Obtaining the system CPU occupancy rate according to the first difference value and the time interval.

获取系统CPU占用率的步骤与步骤202中获取系统CPU占用率的步骤相同,在此不再赘述。The step of acquiring the system CPU usage rate is the same as the step of acquiring the system CPU usage rate instep 202, and details are not repeated here.

步骤704,若当前系统CPU占用率与相邻上一次系统CPU占用率的差值超过指定值,将当前系统CPU占用率作为第一CPU占用率。Step 704, if the difference between the current system CPU occupancy rate and the adjacent last system CPU occupancy rate exceeds a specified value, the current system CPU occupancy rate is taken as the first CPU occupancy rate.

上述第一CPU占用率即为异常占用率。获取第一CPU占用率的步骤与步骤204中获取第一CPU占用率的步骤相同,在此不再赘述。The above-mentioned first CPU occupancy rate is the abnormal occupancy rate. The step of acquiring the first CPU occupancy rate is the same as the step of acquiring the first CPU occupancy rate in step 204, and details are not repeated here.

步骤706,若系统CPU占用率不小于第一CPU占用率的持续时长超过指定时长,查找上一次获取各应用程序CPU占用率的时刻。Step 706 , if the system CPU occupancy rate is not less than the first CPU occupancy rate and the duration exceeds the specified time period, search for the last time when the CPU occupancy rate of each application program was obtained.

查找上一次获取各应用程序CPU占用率的时刻的步骤与步骤302中查找上一次获取各应用程序CPU占用率的时刻的步骤相同,在此不再赘述。The step of finding the time when the CPU occupancy rate of each application program was obtained last time is the same as the step of finding the time when the CPU occupancy rate of each application program was obtained last time instep 302 , and details are not repeated here.

步骤708,若当前时刻与上一次获取各应用程序CPU占用率的时刻的时间差超过第一阈值,获取各应用程序CPU占用率。Step 708 , if the time difference between the current moment and the moment when the CPU occupancy rate of each application program was obtained last time exceeds a first threshold, obtain the CPU occupancy rate of each application program.

获取应用程序CPU占用率的步骤与步骤206中获取应用程序CPU占用率的步骤相同,在此不再赘述。The step of acquiring the CPU usage rate of the application program is the same as the step of acquiring the CPU usage rate of the application program instep 206, and details are not repeated here.

步骤710,若检测到应用程序对应的CPU占用率超过第二阈值,检测应用程序是否满足预设规则。Step 710, if it is detected that the CPU occupancy rate corresponding to the application program exceeds the second threshold, it is detected whether the application program satisfies the preset rule.

检测应用程序对应的CPU占用率是否超过第二阈值,应用程序是否满足预设规则的步骤与步骤402中对应的步骤相同,在此不再赘述。The steps of detecting whether the CPU occupancy rate corresponding to the application program exceeds the second threshold and whether the application program satisfies the preset rule are the same as the corresponding steps instep 402, and are not repeated here.

步骤712,若否,在移动终端界面展示应用程序对应的异常信息、对应用程序的停止运行指令。若接收到对停止运行指令的触发操作,停止运行应用程序对应的进程。Step 712 , if not, display the exception information corresponding to the application and the stop running instruction for the application on the interface of the mobile terminal. If a trigger operation for the stop operation instruction is received, the process corresponding to the application program is stopped.

在移动终端展示应用程序对应的异常信息、对应用程序的停止运行指令步骤与图6中对应的步骤相同,在此不再赘述。停止运行应用程序对应的进程与步骤404中对应的步骤相同,在此不再赘述。The steps of displaying the abnormal information corresponding to the application program on the mobile terminal and the instruction to stop running the application program are the same as the corresponding steps in FIG. 6 , and will not be repeated here. The process corresponding to stopping the running of the application is the same as the corresponding step instep 404, and details are not repeated here.

步骤714,根据系统CPU占用率获取对应的CPU占用级别。累计连续维持在占用级别的次数。当次数达到占用级别对应的第三阈值时,确定与占用级别对应的繁忙程度。Step 714: Obtain the corresponding CPU occupancy level according to the system CPU occupancy rate. Accumulates the number of times that the occupancy level is maintained continuously. When the number of times reaches the third threshold corresponding to the occupancy level, the busy degree corresponding to the occupancy level is determined.

获取系统CPU占用率对应的CPU占用级别,确定与CPU占用界别对应的繁忙程度的步骤与图5中对应的步骤相同,在此不再赘述。The steps of obtaining the CPU occupancy level corresponding to the CPU occupancy rate of the system, and determining the busyness level corresponding to the CPU occupancy level are the same as the corresponding steps in FIG. 5 , and are not repeated here.

图8为一个实施例中CPU监测装置的结构框图。一种CPU监测装置,包括第一获取模块802、差值模块804和第二获取模块806。其中:FIG. 8 is a structural block diagram of a CPU monitoring apparatus in one embodiment. A CPU monitoring device includes afirst acquisition module 802 , adifference value module 804 and asecond acquisition module 806 . in:

第一获取模块802,用于按照预设的第一时间间隔获取系统CPU占用率。The first obtainingmodule 802 is configured to obtain the system CPU occupancy rate according to a preset first time interval.

差值模块804,用于若当前系统CPU占用率与相邻上一次系统CPU占用率的差值超过指定值,将当前系统CPU占用率作为第一CPU占用率。Thedifference value module 804 is configured to use the current system CPU occupancy rate as the first CPU occupancy rate if the difference between the current system CPU occupancy rate and the adjacent last system CPU occupancy rate exceeds a specified value.

第二获取模块806,用于若系统CPU占用率不小于第一CPU占用率的持续时长超过指定时长,获取各应用程序CPU占用率。The second obtainingmodule 806 is configured to obtain the CPU occupancy rate of each application program if the system CPU occupancy rate is not less than the first CPU occupancy rate and the duration exceeds the specified time period.

在一个实施例中,第二获取模块806还用于在获取各应用程序CPU占用率之前,查找上一次获取各应用程序CPU占用率的时刻。若当前时刻与上一次获取各应用程序CPU占用率的时刻的时间差超过第一阈值,获取各应用程序CPU占用率。In one embodiment, the second obtainingmodule 806 is further configured to, before obtaining the CPU occupancy rate of each application program, search for the last time when the CPU occupancy rate of each application program was obtained. If the time difference between the current moment and the moment when the CPU usage rate of each application program was acquired last time exceeds the first threshold, the CPU usage rate of each application program is acquired.

在一个实施例中,第一获取模块802还用于获取连续两次采集的系统CPU工作时长的差值作为第一差值。根据第一差值和时间间隔获取系统CPU占用率。In one embodiment, the first obtainingmodule 802 is further configured to obtain a difference between two consecutively collected working durations of the system CPU as the first difference. Acquire the system CPU usage rate according to the first difference value and the time interval.

图9为另一个实施例中CPU监测装置的结构框图。一种CPU监测装置,包括第一获取模块902、差值模块904、第二获取模块906和关闭模块908。其中第一获取模块902、差值模块904和第二获取模块906与图8中对应的模块功能相同。FIG. 9 is a structural block diagram of a CPU monitoring apparatus in another embodiment. A CPU monitoring device includes a first obtainingmodule 902 , adifference value module 904 , a second obtainingmodule 906 and aclosing module 908 . The first obtainingmodule 902 , thedifference value module 904 and the second obtainingmodule 906 have the same functions as the corresponding modules in FIG. 8 .

关闭模块908,用于若检测到应用程序对应的CPU占用率超过第二阈值,检测应用程序是否满足预设规则。若否,停止运行应用程序对应的进程。Theclosing module 908 is configured to detect whether the application program satisfies the preset rule if it is detected that the CPU occupancy rate corresponding to the application program exceeds the second threshold. If not, stop the process corresponding to the running application.

图10为另一个实施例中CPU监测装置的结构框图。一种CPU监测装置,包括第一获取模块1002、差值模块1004、第二获取模块1006、第三获取模块1008、累计模块1010和确定模块1012。其中第一获取模块1002、差值模块1004和第二获取模块1006与图8中对应的模块功能相同。FIG. 10 is a structural block diagram of a CPU monitoring apparatus in another embodiment. A CPU monitoring device includes a first acquisition module 1002 , a difference value module 1004 , a second acquisition module 1006 , a third acquisition module 1008 , an accumulation module 1010 and a determination module 1012 . The first obtaining module 1002 , the difference value module 1004 and the second obtaining module 1006 have the same functions as the corresponding modules in FIG. 8 .

第三获取模块1008,用于根据系统CPU占用率获取对应的CPU占用级别。The third obtaining module 1008 is configured to obtain the corresponding CPU occupancy level according to the system CPU occupancy rate.

累计模块1010,用于累计连续维持在占用级别的次数。The accumulating module 1010 is used for accumulating the number of times that the occupancy level is maintained continuously.

确定模块1012,用于当次数达到占用级别对应的第三阈值时,确定与占用级别对应的繁忙程度。The determining module 1012 is configured to determine the busy degree corresponding to the occupancy level when the number of times reaches the third threshold corresponding to the occupancy level.

图11为另一个实施例中CPU监测装置的结构框图。一种CPU监测装置,包括第一获取模块1102、差值模块1104、第二获取模块1106、展示模块1108和关闭模块1110。其中第一获取模块1102、差值模块1104和第二获取模块1106与图8中对应的模块功能相同。关闭模块1110与图9中对应的模块功能相同。FIG. 11 is a structural block diagram of a CPU monitoring apparatus in another embodiment. A CPU monitoring device includes a first obtainingmodule 1102 , adifference value module 1104 , a second obtainingmodule 1106 , adisplay module 1108 and aclosing module 1110 . The first obtainingmodule 1102 , thedifference value module 1104 and the second obtainingmodule 1106 have the same functions as the corresponding modules in FIG. 8 . Theshutdown module 1110 has the same function as the corresponding module in FIG. 9 .

展示模块1108,用于在移动终端界面展示应用程序对应的异常信息、对应用程序的停止运行指令。Thedisplay module 1108 is configured to display the abnormal information corresponding to the application program and the stop operation instruction for the application program on the mobile terminal interface.

关闭模块1110还用于若接收到对停止运行指令的触发操作,停止运行应用程序对应的进程。Theshutdown module 1110 is further configured to stop the process corresponding to the application program if a trigger operation for the stop operation instruction is received.

上述CPU监测装置中各个模块的划分仅用于举例说明,在其他实施例中,可将CPU监测装置按照需要划分为不同的模块,以完成上述CPU监测装置的全部或部分功能。The division of each module in the above CPU monitoring device is only used for illustration. In other embodiments, the CPU monitoring device can be divided into different modules as required to complete all or part of the functions of the above CPU monitoring device.

本发明实施例还提供了一种计算机可读存储介质。一个或多个包含计算机可执行指令的非易失性计算机可读存储介质,当计算机可执行指令被一个或多个处理器执行时,使得处理器执行如上所述的CPU监测方法。Embodiments of the present invention also provide a computer-readable storage medium. One or more non-volatile computer-readable storage media containing computer-executable instructions, when executed by one or more processors, cause the processors to perform the CPU monitoring method as described above.

本发明实施例还提供了一种移动终端。如图12所示,为了便于说明,仅示出了与本发明实施例相关的部分,具体技术细节未揭示的,请参照本发明实施例方法部分。该移动终端可以为包括手机、平板电脑、PDA(Personal Digital Assistant,个人数字助理)、POS(Point of Sales,销售终端)、车载电脑、穿戴式设备等任意终端设备,以移动终端为手机为例:The embodiment of the present invention also provides a mobile terminal. As shown in FIG. 12 , for the convenience of description, only the part related to the embodiment of the present invention is shown, and the specific technical details are not disclosed, please refer to the method part of the embodiment of the present invention. The mobile terminal can be any terminal device including a mobile phone, a tablet computer, a PDA (Personal Digital Assistant, personal digital assistant), a POS (Point of Sales, a sales terminal), a vehicle-mounted computer, a wearable device, etc. Take the mobile terminal as an example of a mobile phone :

图12为与本发明实施例提供的移动终端相关的手机的部分结构的框图。参考图12,手机包括:射频(Radio Frequency,RF)电路1210、存储器1220、输入单元1230、显示单元1240、传感器1250、音频电路1260、无线保真(wireless fidelity,WiFi)模块1270、处理器1280、以及电源1290等部件。本领域技术人员可以理解,图12所示的手机结构并不构成对手机的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。FIG. 12 is a block diagram of a partial structure of a mobile phone related to a mobile terminal provided by an embodiment of the present invention. 12 , the mobile phone includes: a radio frequency (RF)circuit 1210 , amemory 1220 , aninput unit 1230 , adisplay unit 1240 , asensor 1250 , anaudio circuit 1260 , a wireless fidelity (WiFi)module 1270 , and aprocessor 1280 , andpower supply 1290 and other components. Those skilled in the art can understand that the structure of the mobile phone shown in FIG. 12 does not constitute a limitation on the mobile phone, and may include more or less components than shown, or combine some components, or arrange different components.

其中,RF电路1210可用于收发信息或通话过程中,信号的接收和发送,可将基站的下行信息接收后,给处理器1280处理;也可以将上行的数据发送给基站。通常,RF电路包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器(Low Noise Amplifier,LNA)、双工器等。此外,RF电路1210还可以通过无线通信与网络和其他设备通信。上述无线通信可以使用任一通信标准或协议,包括但不限于全球移动通讯系统(Global System ofMobile communication,GSM)、通用分组无线服务(General Packet Radio Service,GPRS)、码分多址(Code Division Multiple Access,CDMA)、宽带码分多址(Wideband CodeDivision Multiple Access,WCDMA)、长期演进(Long Term Evolution,LTE))、电子邮件、短消息服务(Short Messaging Service,SMS)等。TheRF circuit 1210 can be used for receiving and sending signals during sending and receiving of information or during a call. After receiving the downlink information of the base station, it can be processed by theprocessor 1280; it can also send the uplink data to the base station. Typically, the RF circuit includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like. In addition,RF circuitry 1210 may also communicate with networks and other devices via wireless communications. The above-mentioned wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access) Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE)), email, Short Messaging Service (Short Messaging Service, SMS) and the like.

存储器1220可用于存储软件程序以及模块,处理器1280通过运行存储在存储器1220的软件程序以及模块,从而执行手机的各种功能应用以及数据处理。存储器1220可主要包括程序存储区和数据存储区,其中,程序存储区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能的应用程序、图像播放功能的应用程序等)等;数据存储区可存储根据手机的使用所创建的数据(比如音频数据、通讯录等)等。此外,存储器1220可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。Thememory 1220 can be used to store software programs and modules, and theprocessor 1280 executes various functional applications and data processing of the mobile phone by running the software programs and modules stored in thememory 1220 . Thememory 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 program required for at least one function (such as an application program for a sound playback function, an application program for an image playback function, etc.), etc.; The data storage area may store data (such as audio data, address book, etc.) created according to the usage of the mobile phone, and the like. Additionally,memory 1220 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.

输入单元1230可用于接收输入的数字或字符信息,以及产生与手机1200的用户设置以及功能控制有关的键信号输入。具体地,输入单元1230可包括触控面板1231以及其他输入设备1232。触控面板1231,也可称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板1231上或在触控面板1231附近的操作),并根据预先设定的程式驱动相应的连接装置。在一个实施例中,触控面板1231可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器1280,并能接收处理器1280发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板1231。除了触控面板1231,输入单元1230还可以包括其他输入设备1232。具体地,其他输入设备1232可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)等中的一种或多种。Theinput unit 1230 may be used to receive input numerical or character information, and generate key signal input related to user settings and function control of themobile phone 1200 . Specifically, theinput unit 1230 may include atouch panel 1231 andother input devices 1232 . Thetouch panel 1231, also referred to as a touch screen, can collect the user's touch operations on or near it (such as the user using a finger, a stylus, etc., any suitable object or accessory on or near the touch panel 1231) operation), and drive the corresponding connection device according to the preset program. In one embodiment, thetouch panel 1231 may include two parts, a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the 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 it into contact coordinates, and then sends it to the touch controller. To theprocessor 1280, and can receive the command sent by theprocessor 1280 and execute it. In addition, thetouch panel 1231 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. Besides thetouch panel 1231 , theinput unit 1230 may also includeother input devices 1232 . Specifically,other input devices 1232 may include, but are not limited to, one or more of physical keyboards, function keys (such as volume control keys, switch keys, etc.), and the like.

显示单元1240可用于显示由用户输入的信息或提供给用户的信息以及手机的各种菜单。显示单元1240可包括显示面板1241。在一个实施例中,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板1241。在一个实施例中,触控面板1231可覆盖显示面板1241,当触控面板1231检测到在其上或附近的触摸操作后,传送给处理器1280以确定触摸事件的类型,随后处理器1280根据触摸事件的类型在显示面板1241上提供相应的视觉输出。虽然在图12中,触控面板1231与显示面板1241是作为两个独立的部件来实现手机的输入和输入功能,但是在某些实施例中,可以将触控面板1231与显示面板1241集成而实现手机的输入和输出功能。Thedisplay unit 1240 may be used to display information input by the user or information provided to the user and various menus of the mobile phone. Thedisplay unit 1240 may include adisplay panel 1241 . In one embodiment, thedisplay panel 1241 may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. In one embodiment, thetouch panel 1231 may cover thedisplay panel 1241. When thetouch panel 1231 detects a touch operation on or near it, thetouch panel 1231 transmits it to theprocessor 1280 to determine the type of the touch event, and then theprocessor 1280 determines the type of the touch event according to the The type of touch event provides a corresponding visual output on thedisplay panel 1241 . Although in FIG. 12, thetouch panel 1231 and thedisplay panel 1241 are used as two independent components to realize the input and input functions of the mobile phone, in some embodiments, thetouch panel 1231 and thedisplay panel 1241 can be integrated to form Realize the input and output functions of the mobile phone.

手机1200还可包括至少一种传感器1250,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板1241的亮度,接近传感器可在手机移动到耳边时,关闭显示面板1241和/或背光。运动传感器可包括加速度传感器,通过加速度传感器可检测各个方向上加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换)、振动识别相关功能(比如计步器、敲击)等;此外,手机还可配置陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器等。Cell phone 1200 may also include at least onesensor 1250, such as light sensors, motion sensors, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of thedisplay panel 1241 according to the brightness of the ambient light, and the proximity sensor may turn off thedisplay panel 1241 and/or when the mobile phone is moved to the ear. or backlight. Motion sensors can include acceleration sensors, which can detect the magnitude of acceleration in all directions, and can detect the magnitude and direction of gravity when stationary. It can be used for applications that recognize the posture of mobile phones (such as switching between horizontal and vertical screens), and vibration recognition related functions (such as Pedometer, tapping), etc.; in addition, the mobile phone can also be equipped with other sensors such as gyroscope, barometer, hygrometer, thermometer, infrared sensor, etc.

音频电路1260、扬声器1261和传声器1262可提供用户与手机之间的音频接口。音频电路1260可将接收到的音频数据转换后的电信号,传输到扬声器1261,由扬声器1261转换为声音信号输出;另一方面,传声器1262将收集的声音信号转换为电信号,由音频电路1260接收后转换为音频数据,再将音频数据输出处理器1280处理后,经RF电路1210可以发送给另一手机,或者将音频数据输出至存储器1220以便后续处理。Audio circuit 1260,speaker 1261 andmicrophone 1262 may provide an audio interface between the user and the cell phone. Theaudio circuit 1260 can transmit the received audio data converted electrical signals to thespeaker 1261, and thespeaker 1261 converts them into sound signals for output; on the other hand, themicrophone 1262 converts the collected sound signals into electrical signals, and theaudio circuit 1260 converts the collected sound signals into electrical signals. After receiving, the audio data is converted into audio data, and then the audio data is processed by theoutput processor 1280, and can be sent to another mobile phone via theRF circuit 1210, or the audio data can be output to thememory 1220 for subsequent processing.

WiFi属于短距离无线传输技术,手机通过WiFi模块1270可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图12示出了WiFi模块1270,但是可以理解的是,其并不属于手机1200的必须构成,可以根据需要而省略。WiFi is a short-distance wireless transmission technology. The mobile phone can help users to send and receive emails, browse web pages, and access streaming media through theWiFi module 1270. It provides users with wireless broadband Internet access. Although FIG. 12 shows theWiFi module 1270, it can be understood that it is not a necessary component of themobile phone 1200 and can be omitted as required.

处理器1280是手机的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器1220内的软件程序和/或模块,以及调用存储在存储器1220内的数据,执行手机的各种功能和处理数据,从而对手机进行整体监控。在一个实施例中,处理器1280可包括一个或多个处理单元。在一个实施例中,处理器1280可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等;调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器1280中。Theprocessor 1280 is the control center of the mobile phone, and uses various interfaces and lines to connect various parts of the entire mobile phone, by running or executing the software programs and/or modules stored in thememory 1220, and calling the data stored in thememory 1220. Various functions of the mobile phone and processing data, so as to monitor the mobile phone as a whole. In one embodiment, theprocessor 1280 may include one or more processing units. In one embodiment, theprocessor 1280 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface and application programs, etc.; the modem processor mainly handles wireless communication. It can be understood that, the above-mentioned modulation and demodulation processor may not be integrated into theprocessor 1280.

手机1200还包括给各个部件供电的电源1290(比如电池),优选的,电源可以通过电源管理系统与处理器1280逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。Themobile phone 1200 also includes a power supply 1290 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to theprocessor 1280 through a power management system, so as to manage charging, discharging, and power consumption management functions through the power management system.

在一个实施例中,手机1200还可以包括摄像头、蓝牙模块等。In one embodiment, themobile phone 1200 may further include a camera, a Bluetooth module, and the like.

在本发明实施例中,该移动终端所包括的处理器1280执行存储在存储器上的计算机程序时实现如上所述的CPU监测方法。In this embodiment of the present invention, when theprocessor 1280 included in the mobile terminal executes the computer program stored in the memory, the CPU monitoring method described above is implemented.

本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,的程序可存储于一非易失性计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)等。Those of ordinary skill in the art can understand that the realization of all or part of the processes in the methods of the above embodiments can be accomplished by instructing relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium, When the program is executed, it may include the flow of the embodiments of the above-mentioned methods. The storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), and the like.

以上实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。The above embodiments only represent several embodiments of the present invention, and the descriptions thereof are specific and detailed, but should not be construed as a limitation on the scope of the patent of the present invention. It should be pointed out that for those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can also be made, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention should be subject to the appended claims.

Claims (8)

Translated fromChinese
1.一种CPU监测方法,其特征在于,包括:1. a CPU monitoring method, is characterized in that, comprises:按照预设的第一时间间隔获取系统CPU占用率;Obtain the system CPU occupancy rate according to the preset first time interval;若当前系统CPU占用率与相邻上一次系统CPU占用率的差值超过指定值,将所述当前系统CPU占用率作为第一CPU占用率,所述第一CPU占用率即是异常CPU占用率;If the difference between the current system CPU usage and the adjacent last system CPU usage exceeds the specified value, the current system CPU usage is taken as the first CPU usage, and the first CPU usage is the abnormal CPU usage ;再次按照预设的第一时间间隔获取预设次数的系统CPU占用率,若系统CPU占用率不小于所述第一CPU占用率的持续时长超过指定时长,获取各应用程序CPU占用率;Obtaining the system CPU occupancy rate of a preset number of times again according to the preset first time interval, and obtaining the CPU occupancy rate of each application program if the system CPU occupancy rate is not less than the duration of the first CPU occupancy rate and exceeds the specified time period;所述获取系统CPU占用率包括:The obtaining of the system CPU usage includes:获取连续两次采集的系统CPU累计工作时长的差值作为第一差值;Obtain the difference between the accumulated working hours of the system CPU collected twice in a row as the first difference;根据所述第一差值和所述时间间隔获取系统CPU占用率;Obtaining the system CPU occupancy rate according to the first difference and the time interval;所述方法还包括:The method also includes:根据所述系统CPU占用率获取对应的CPU占用级别;Obtain the corresponding CPU occupancy level according to the system CPU occupancy rate;累计连续维持在所述占用级别的次数;Accumulate the number of times that the occupancy level is continuously maintained;当所述次数达到所述占用级别对应的第三阈值时,确定与所述占用级别对应的繁忙程度。When the number of times reaches the third threshold corresponding to the occupancy level, the busyness level corresponding to the occupancy level is determined.2.根据权利要求1所述的CPU监测方法,其特征在于,在所述获取各应用程序CPU占用率之前,所述方法还包括:2. The CPU monitoring method according to claim 1, characterized in that, before acquiring the CPU occupancy rate of each application program, the method further comprises:查找上一次获取各应用程序CPU占用率的时刻;Find the last time to obtain the CPU usage of each application;若当前时刻与所述上一次获取各应用程序CPU占用率的时刻的时间差超过第一阈值,获取所述各应用程序CPU占用率。If the time difference between the current moment and the last time when the CPU occupancy rate of each application program is obtained exceeds the first threshold, the CPU occupancy rate of each application program is acquired.3.根据权利要求1所述的CPU监测方法,其特征在于,所述方法还包括:3. CPU monitoring method according to claim 1, is characterized in that, described method also comprises:若检测到应用程序对应的CPU占用率超过第二阈值,检测所述应用程序是否满足预设规则;If it is detected that the CPU occupancy rate corresponding to the application program exceeds the second threshold, detecting whether the application program satisfies the preset rule;若否,停止运行所述应用程序对应的进程。If not, stop running the process corresponding to the application program.4.一种CPU监测装置,其特征在于,包括:4. a CPU monitoring device, is characterized in that, comprises:第一获取模块,用于按照预设的第一时间间隔获取系统CPU占用率;a first obtaining module, configured to obtain the system CPU occupancy rate according to a preset first time interval;差值模块,用于若当前系统CPU占用率与相邻上一次系统CPU占用率的差值超过指定值,将所述当前系统CPU占用率作为第一CPU占用率,所述第一CPU占用率即是异常CPU占用率;The difference module is used to use the current system CPU occupancy rate as the first CPU occupancy rate if the difference between the current system CPU occupancy rate and the adjacent last system CPU occupancy rate exceeds a specified value, and the first CPU occupancy rate That is, the abnormal CPU usage;第二获取模块,用于再次按照预设的第一时间间隔获取预设次数的系统CPU占用率,若系统CPU占用率不小于所述第一CPU占用率的持续时长超过指定时长,获取各应用程序CPU占用率;The second obtaining module is configured to obtain the system CPU occupancy rate for a preset number of times again according to the preset first time interval. If the system CPU occupancy rate is not less than the first CPU occupancy rate and the duration exceeds the specified time period, obtain each application. Program CPU usage;所述第一获取模块还用于获取连续两次采集的系统CPU累计工作时长的差值作为第一差值;根据所述第一差值和所述时间间隔获取系统CPU占用率;The first obtaining module is further configured to obtain the difference between the accumulated working hours of the system CPU collected twice in a row as the first difference; obtain the system CPU occupancy rate according to the first difference and the time interval;所述装置还包括:The device also includes:第三获取模块,用于根据所述系统CPU占用率获取对应的CPU占用级别;a third obtaining module, configured to obtain the corresponding CPU occupancy level according to the system CPU occupancy rate;累计模块,用于累计连续维持在所述占用级别的次数;an accumulating module for accumulating the number of times continuously maintained at the occupancy level;确定模块,用于当所述次数达到所述占用级别对应的第三阈值时,确定与所述占用级别对应的繁忙程度。A determining module, configured to determine the busyness level corresponding to the occupancy level when the number of times reaches the third threshold corresponding to the occupancy level.5.根据权利要求4所述的CPU监测装置,其特征在于:5. CPU monitoring device according to claim 4, is characterized in that:所述第二获取模块还用于在所述获取各应用程序CPU占用率之前,查找上一次获取各应用程序CPU占用率的时刻;若当前时刻与所述上一次获取各应用程序CPU占用率的时刻的时间差超过第一阈值,获取所述各应用程序CPU占用率。The second obtaining module is further configured to, before obtaining the CPU occupancy rate of each application program, find the moment when the CPU occupancy rate of each application program was obtained last time; When the time difference exceeds the first threshold, the CPU usage of each application program is obtained.6.根据权利要求4所述的CPU监测装置,其特征在于,所述装置还包括:6. The CPU monitoring device according to claim 4, wherein the device further comprises:关闭模块,用于若检测到应用程序对应的CPU占用率超过第二阈值,检测所述应用程序是否满足预设规则;若否,停止运行所述应用程序对应的进程。The shutdown module is configured to detect whether the application program satisfies the preset rule if it is detected that the CPU occupancy rate corresponding to the application program exceeds the second threshold; if not, stop running the process corresponding to the application program.7.一个或多个包含计算机可执行指令的非易失性计算机可读存储介质,当所述计算机可执行指令被一个或多个处理器执行时,使得所述处理器执行如权利要求1至3中任一项所述的CPU监测方法。7. One or more non-volatile computer-readable storage media containing computer-executable instructions that, when executed by one or more processors, cause the processors to perform the operations of claims 1 to 1. The CPU monitoring method described in any one of 3.8.一种移动终端,包括存储器及处理器,所述存储器中储存有计算机可读指令,所述指令被所述处理器执行时,使得所述处理器执行如权利要求1至3中任一项所述的CPU监测方法。8. A mobile terminal, comprising a memory and a processor, wherein computer-readable instructions are stored in the memory, and when the instructions are executed by the processor, the processor is made to execute any one of claims 1 to 3 The CPU monitoring method described in item.
CN201710648542.3A2017-08-012017-08-01CPU monitoring method and device, computer readable storage medium and mobile terminalActiveCN107368400B (en)

Priority Applications (2)

Application NumberPriority DateFiling DateTitle
CN201710648542.3ACN107368400B (en)2017-08-012017-08-01CPU monitoring method and device, computer readable storage medium and mobile terminal
PCT/CN2018/097535WO2019024804A1 (en)2017-08-012018-07-27Cpu monitoring method, computer readable storage medium, and mobile terminal

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201710648542.3ACN107368400B (en)2017-08-012017-08-01CPU monitoring method and device, computer readable storage medium and mobile terminal

Publications (2)

Publication NumberPublication Date
CN107368400A CN107368400A (en)2017-11-21
CN107368400Btrue CN107368400B (en)2020-02-04

Family

ID=60308754

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201710648542.3AActiveCN107368400B (en)2017-08-012017-08-01CPU monitoring method and device, computer readable storage medium and mobile terminal

Country Status (2)

CountryLink
CN (1)CN107368400B (en)
WO (1)WO2019024804A1 (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN107368400B (en)*2017-08-012020-02-04Oppo广东移动通信有限公司CPU monitoring method and device, computer readable storage medium and mobile terminal
CN107967178B (en)*2017-12-062020-03-17Oppo广东移动通信有限公司Resource allocation method, resource allocation device, mobile terminal and medium
CN110750352B (en)*2018-07-232024-10-25南京中兴新软件有限责任公司 A CPU operation management method, device and storage medium
CN109800124B (en)*2018-12-152023-04-11中国平安人寿保险股份有限公司CPU utilization monitoring method and device, electronic equipment and storage medium
CN109726003B (en)*2019-01-042020-09-15Oppo广东移动通信有限公司 Application thawing processing method, electronic device and computer-readable storage medium
CN111414295B (en)*2020-03-092023-06-30浙江大华技术股份有限公司Statistical method, device, equipment and medium for CPU occupancy rate
CN111930593B (en)*2020-07-272023-03-28长沙景嘉微电子股份有限公司GPU occupancy rate determination method, device, processing system and storage medium
CN112218411A (en)*2020-11-032021-01-12深圳茂硕电子科技有限公司LED power supply state monitoring method
CN113535516B (en)*2021-07-062023-05-30上海上讯信息技术股份有限公司Method and equipment for monitoring CPU occupancy rate abnormality
CN114116405A (en)*2021-11-302022-03-01上海商汤临港智能科技有限公司Application program process control method and device, computer equipment and storage medium
CN114416466A (en)*2021-12-132022-04-29北京罗克维尔斯科技有限公司 CPU usage monitoring method, device, device and storage medium
CN114003367B (en)*2022-01-042022-03-15北京新唐思创教育科技有限公司Risk monitoring method, device, equipment and storage medium
CN114490055A (en)*2022-01-212022-05-13岚图汽车科技有限公司 A mobile device and its CPU load control method and device
CN115794549A (en)*2022-11-222023-03-14中孚安全技术有限公司Method, device and medium for managing and controlling resource occupied by application program

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
KR100730822B1 (en)*2005-06-092007-06-20에스케이 텔레콤주식회사 Calculation method of utilization of central processing unit
CN101876933A (en)*2009-04-282010-11-03深圳富泰宏精密工业有限公司Analysis system and method for CPU utilization rate
CN102110043A (en)*2010-12-302011-06-29上海顶竹通讯技术有限公司Method and device for computing CPU occupancy rate
CN105224439A (en)*2014-07-022016-01-06北京金山安全软件有限公司Method and device for detecting CPU occupancy rate of terminal APP and terminal
CN104239196B (en)*2014-09-172018-06-01北京金山安全软件有限公司Method and device for detecting abnormal operation of application program and mobile terminal
CN105357026B (en)*2015-09-242019-07-23华为技术有限公司A kind of resource information collection method and calculate node
CN105589546A (en)*2015-12-212016-05-18北京金山安全软件有限公司Information detection method and device
CN107368400B (en)*2017-08-012020-02-04Oppo广东移动通信有限公司CPU monitoring method and device, computer readable storage medium and mobile terminal

Also Published As

Publication numberPublication date
CN107368400A (en)2017-11-21
WO2019024804A1 (en)2019-02-07

Similar Documents

PublicationPublication DateTitle
CN107368400B (en)CPU monitoring method and device, computer readable storage medium and mobile terminal
US11099900B2 (en)Memory reclamation method and apparatus
CN107391259B (en) Resource processing method and apparatus, computer-readable storage medium, and mobile terminal
CN107526638B (en) Application processing method, device, mobile terminal and storage medium
CN107577508B (en) Application processing method, device, readable storage medium and mobile terminal
CN107526637B (en)Application processing method and device, mobile terminal and storage medium
CN107562539B (en) Application processing method and apparatus, computer equipment, storage medium
CN103024205B (en)Method, device and terminal for controlling power
CN108681498B (en)CPU occupancy rate monitoring method and device and mobile terminal
JP2020537213A (en) Methods for reducing terminal power consumption, and terminals
CN112703714A (en)Application program processing method and device, computer equipment and computer readable storage medium
CN109992438A (en) Information processing method, apparatus, computer device, and computer-readable storage medium
CN104967896A (en)Method for displaying bulletscreen comment information, and apparatus thereof
CN107544842A (en) Application program processing method and device, computer equipment, storage medium
CN110008008A (en)Applied program processing method and device, electronic equipment, computer readable storage medium
JP7272694B2 (en) Method and terminal for reducing power consumption of terminal
CN106055079B (en)The management method and device of a kind of central processing unit
CN108334345B (en) Application processing method, device, readable storage medium and mobile terminal
JP2018500811A (en) Power management method and power management apparatus for user equipment
CN107402783A (en)Management control method of background application program and user terminal
WO2017206857A1 (en)Response control method and mobile terminal
CN107832131B (en) Application closing method, device, storage medium and electronic device
CN107688498B (en)Application program processing method and device, computer equipment and storage medium
WO2019137187A1 (en)Resource management method and apparatus, mobile terminal and computer-readable storage medium
CN107491349A (en) Application program processing method and device, computer equipment, storage medium

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
CB02Change of applicant information
CB02Change of applicant information

Address after:Changan town in Guangdong province Dongguan 523860 usha Beach Road No. 18

Applicant after:OPPO Guangdong Mobile Communications Co., Ltd.

Address before:Changan town in Guangdong province Dongguan 523860 usha Beach Road No. 18

Applicant before:Guangdong Opel Mobile Communications Co., Ltd.

GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp