CN111913805A - CPU utilization rate calculation method and device - Google Patents

CPU utilization rate calculation method and device Download PDF

Info

Publication number
CN111913805A
CN111913805A CN202010764790.6A CN202010764790A CN111913805A CN 111913805 A CN111913805 A CN 111913805A CN 202010764790 A CN202010764790 A CN 202010764790A CN 111913805 A CN111913805 A CN 111913805A
Authority
CN
China
Prior art keywords
cpu
calculation
calculating
unit time
calculation period
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.)
Granted
Application number
CN202010764790.6A
Other languages
Chinese (zh)
Other versions
CN111913805B (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.)
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Original Assignee
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co 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 Beijing Topsec Technology Co Ltd, Beijing Topsec Network Security Technology Co Ltd, Beijing Topsec Software Co Ltd filed Critical Beijing Topsec Technology Co Ltd
Priority to CN202010764790.6A priority Critical patent/CN111913805B/en
Publication of CN111913805A publication Critical patent/CN111913805A/en
Application granted granted Critical
Publication of CN111913805B publication Critical patent/CN111913805B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5044Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering hardware capabilities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3452Performance evaluation by statistical analysis
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the application provides a method and a device for calculating the utilization rate of a CPU (Central processing Unit), which relate to the technical field of computers, and the method for calculating the utilization rate of the CPU comprises the following steps: firstly, determining various target tasks which are continuously operated in a system, then calculating the actual total calculation period of the CPU when all the target tasks are operated in a preset unit time when the various target tasks are continuously operated in the system, and acquiring the maximum calculation period of the CPU in the preset unit time; and finally, calculating the utilization rate of the CPU according to the maximum calculation period and the actual total calculation period. Therefore, the method can calculate the CPU utilization rate under the condition that the system continuously runs various tasks, has high calculation accuracy and simple calculation method, and is further favorable for improving the calculation efficiency.

Description

CPU utilization rate calculation method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for calculating a CPU utilization.
Background
At present, computers are developed rapidly, a Central Processing Unit (CPU) occupies a large proportion of the cost of the computer, and how to measure the CPU utilization effectively becomes a key problem for improving the resource efficiency of the computer system. The existing CPU utilization rate calculation method generally comprises the steps of sampling the CPU operation condition periodically, recording the proportion of time slices consumed by each CPU in a multi-core system to a system and a process, and then calculating the utilization rate of the CPU according to the proportion corresponding to each CPU, wherein the calculation efficiency is low and the error is large. Meanwhile, in practice, it is found that, in order to improve the system efficiency, the CPU uninterruptedly runs a plurality of fixed tasks in a dead loop manner, and the CPU utilization of the uninterruptedly running the plurality of fixed tasks cannot be calculated by using the existing CPU utilization calculation method (the CPU utilization obtained by calculation is one hundred percent). Therefore, the CPU utilization rate of a plurality of fixed tasks which run uninterruptedly cannot be calculated by the conventional CPU utilization rate calculation method, the calculation efficiency is low, and the error is large.
Disclosure of Invention
The embodiment of the application aims to provide a method and a device for calculating the CPU utilization rate, which can calculate the CPU utilization rate under the condition that a system continuously runs various tasks, have high calculation accuracy and simple calculation method, and are further beneficial to improving the calculation efficiency.
A first aspect of an embodiment of the present application provides a method for calculating a CPU utilization, including:
determining a plurality of target tasks which run uninterruptedly in the system;
when various target tasks are continuously operated in the system, calculating the actual total calculation period of the CPU when all the target tasks are operated in a preset unit time;
acquiring the maximum calculation period of the CPU in the preset unit time;
and calculating the utilization rate of the CPU according to the maximum calculation period and the actual total calculation period.
In the implementation process, various target tasks which are continuously operated in the system are determined, then when the various target tasks are continuously operated in the system, the actual total calculation period of the CPU when all the target tasks are operated in the preset unit time is calculated, and the maximum calculation period of the CPU in the preset unit time is obtained; and finally, calculating the utilization rate of the CPU according to the maximum calculation period and the actual total calculation period. Therefore, the method can calculate the CPU utilization rate under the condition that the system continuously runs various tasks, has high calculation accuracy and simple calculation method, and is further favorable for improving the calculation efficiency.
Further, when the plurality of target tasks are continuously operated in the system, calculating an actual total calculation period of the CPUs when all the target tasks are operated in a preset unit time includes:
calculating the calculation period of a CPU when each target task runs once in the system;
when various target tasks run in the system continuously, acquiring the actual running times of each target task in the preset unit time;
and calculating the actual total calculation period of the CPU when all the target tasks are operated in the preset unit time according to the actual operation times and the calculation period.
In the implementation process, the calculation period of the CPU required for once running of each type of target task is calculated, then the actual running times of each type of target task in a preset unit time in the running state of the actual system are calculated, further, the actual total calculation period of all target tasks in the actual running state of the system can be calculated according to the actual running times and the calculation period of the CPU required for once running of each type of target task, the calculation method is simple, the actual total calculation period is calculated according to the actual running times and the calculation period of once running, the actual calculation period obtained by calculation is more in line with the actual running state, and the accuracy of the utilization rate of the CPU in subsequent calculation is further improved.
Further, the calculating the calculation cycle of the CPU when each target task runs once in the system includes:
acquiring CPU main frequency information and the maximum running times of each target task in preset unit time;
and calculating the calculation cycle of the CPU when each target task runs once in the system according to the CPU main frequency information and the maximum running times.
In the implementation process, when calculating the calculation period of the CPU in which each target task runs once in the system, the target task is first run in a dead-cycle manner in the system, then the running times in unit time are counted, that is, the maximum running times of the target task, and then the calculation period when the target task runs once is calculated according to the CPU master frequency information and the maximum running times, so that the calculated calculation period is minimally affected by actual running, and the accuracy of subsequently calculating the utilization rate of the CPU is favorably improved.
Further, the calculating an actual total calculation period of the CPUs operating all the target tasks within the preset unit time according to the actual operation times and the calculation period includes:
calculating an actual calculation period corresponding to each target task in the preset unit time according to the actual operation times and the calculation period;
and summing the actual calculation periods corresponding to each target task to obtain the actual total calculation periods corresponding to all the target tasks.
In the implementation process, the actual calculation period of each target task is calculated first, then the actual calculation periods of all the target tasks are summed, so that the actual total calculation period is obtained, the actual calculation period obtained by calculation can accurately reflect the calculation conditions of the CPUs in actual operation of all the target tasks, and the accuracy of the utilization rate of the CPUs in subsequent calculation is improved.
Further, the acquiring the maximum calculation cycle of the CPU in the preset unit time includes:
and calculating the maximum calculation period of the CPU in the preset unit time according to a preset calculation rule and the CPU main frequency information.
In the implementation process, the calculated maximum calculation period is a calculation period within a unit time theoretically preset by the CPU, the calculation is carried out according to the preset calculation rule and the CPU main frequency information, the calculation result is accurate and is not influenced by actual operation data, the calculation method is simple, and the accuracy and the speed of the subsequent calculation of the utilization rate of the CPU are improved.
A second aspect of the embodiments of the present application provides a CPU utilization calculating apparatus, including:
the system comprises a determining module, a processing module and a processing module, wherein the determining module is used for determining various target tasks which run uninterruptedly in the system;
the first calculation module is used for calculating the actual total calculation period of the CPU when all the target tasks are operated in a preset unit time when various target tasks are continuously operated in the system;
the acquisition module is used for acquiring the maximum calculation period of the CPU in the preset unit time;
and the second calculation module is used for calculating the utilization rate of the CPU according to the maximum calculation period and the actual total calculation period.
In the implementation process, the determining module determines various target tasks which continuously run in the system, then the first calculating module calculates the actual total calculating period of the CPU when all the target tasks run in the preset unit time when the various target tasks continuously run in the system, and the acquiring module acquires the maximum calculating period of the CPU in the preset unit time; and finally, the second calculation module calculates the utilization rate of the CPU according to the maximum calculation period and the actual total calculation period, can calculate the utilization rate of the CPU under the condition that the system continuously runs various tasks, and is high in calculation accuracy, simple in calculation method and further beneficial to improving the calculation efficiency.
Further, the first computing module includes:
the first calculation submodule is used for calculating the calculation period of the CPU when each target task runs once in the system;
the first obtaining sub-module is used for obtaining the actual running times of each target task in the preset unit time when various target tasks run in the system continuously;
and the second calculation submodule is used for calculating the actual total calculation period of the CPU when all the target tasks are operated in the preset unit time according to the actual operation times and the calculation period.
In the implementation process, the first calculation submodule calculates a calculation period of the CPU required for each type of target task to run once, then the first obtaining submodule obtains an actual running time of each type of target task in a preset unit time in an actual system running state, further, the second calculation submodule calculates an actual total calculation period of all target tasks in the system when the target tasks actually run according to the actual running time and the calculation period of the CPU required for each type of target task to run once, the calculation method is simple, the actual total calculation period is calculated according to the actual running time and the calculation period of one running time, the calculated actual calculation period is more in line with the actual running state, and therefore the accuracy of subsequently calculating the utilization rate of the CPU is improved.
Further, the first computation submodule includes:
the acquisition unit is used for acquiring CPU main frequency information and the maximum operation times of each target task in preset unit time;
and the first calculating unit is used for calculating the calculating period of the CPU when each target task runs once in the system according to the CPU main frequency information and the maximum running times.
In the implementation process, when calculating the calculation period of the CPU in which each target task runs once in the system, the obtaining unit first runs the target task in a dead-cycle manner under the system, then counts the running times in unit time, that is, the maximum running time of the target task, and then the first calculating unit calculates the calculation period when the target task runs once according to the master frequency information and the maximum running time of the CPU, so that the calculated calculation period is minimally affected by actual running, and the accuracy of subsequently calculating the utilization rate of the CPU is improved.
A third aspect of the embodiments of the present application provides an electronic device, including a memory and a processor, where the memory is used to store a computer program, and the processor runs the computer program to make the electronic device execute the CPU utilization calculation method described in any one of the first aspect of the embodiments of the present application.
A fourth aspect of the present embodiment provides a computer-readable storage medium, which stores computer program instructions, where the computer program instructions, when read and executed by a processor, perform the CPU utilization calculation method according to any one of the first aspect of the present embodiment.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 is a schematic flowchart of a method for calculating a CPU utilization according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of a method for calculating a CPU utilization according to a second embodiment of the present application;
fig. 3 is a schematic structural diagram of a CPU utilization computing device according to a third embodiment of the present application;
fig. 4 is a schematic structural diagram of a CPU utilization calculating apparatus according to a fourth embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
Example 1
Referring to fig. 1, fig. 1 is a schematic flow chart of a CPU utilization calculating method according to an embodiment of the present disclosure. The CPU utilization rate calculation method comprises the following steps:
s101, determining various target tasks which run uninterruptedly in the system.
In the embodiment of the present application, the method is applied to a system with a multi-core architecture, and is particularly applied to a scenario of calculating a CPU utilization rate when various tasks are continuously run in the system with the multi-core architecture.
In the embodiment of the application, in order to improve the system efficiency under the multi-core architecture, the CPU processes several fixed target tasks in a dead-cycle manner.
In the embodiment of the present application, the multi-core architecture includes a multi-core CPU, and multiple CPU cores are integrated into a single chip, and each CPU core is a separate processor.
In the embodiment of the application, multiple tasks are continuously run in the system, namely multiple tasks are continuously run in the system with the multi-core architecture.
In the embodiment of the present application, a Central Processing Unit (CPU) is a final execution unit for information processing and program operation, and serves as an operation and control core of a computer system.
S102, when various target tasks continuously run in the system, calculating the actual total calculation period of the CPU when all the target tasks run in the preset unit time.
In the embodiment of the present application, the preset unit time may be preset, specifically, may be 1 second, 2 seconds, and the like, and is not limited in this embodiment of the present application. In actual use, the preset unit time is usually 1 second.
In the embodiment of the present application, the actual total calculation period of the CPU when all the target tasks are run within the preset unit time, that is, the calculation period actually consumed by the CPU when all the target tasks are run without interruption within the preset unit time is the actual total calculation period.
In the embodiment of the application, multiple target tasks are continuously operated in the system, namely, each target task is independently operated in a system dead loop.
S103, acquiring the maximum calculation period of the CPU in the preset unit time.
In the embodiment of the application, in actual use, the maximum calculation cycle of the CPU in unit time is preset, that is, the maximum calculation cycle that the CPU can reach in unit time is theoretically preset.
And S104, calculating the utilization rate of the CPU according to the maximum calculation period and the actual total calculation period.
In the embodiment of the present application, the maximum calculation period is a theoretical value, and the actual total calculation period is an actual value, and then the utilization rate can be calculated according to the actual value and the theoretical value, specifically, the formula for calculating the utilization rate η of the CPU is as follows:
Figure BDA0002613367480000081
wherein n is1For the actual total calculation period, n2Is the maximum calculation period.
In the embodiment of the present application, the execution subject of the method may be a computing device such as a computer and a server, and is not limited in this embodiment.
As an optional implementation manner, after calculating the utilization rate of the CPU, the following steps may be further included:
acquiring task identifiers of a plurality of target tasks;
generating a CPU utilization rate calculation report according to the maximum calculation period, the actual total calculation period, the CPU utilization rate, the task identification and the preset unit time;
and outputting the CPU utilization rate calculation report.
As another optional implementation, after calculating the utilization rate of the CPU, the following steps may be further included:
analyzing the multi-core architecture operation performance of the system according to the utilization rate of the CPU to obtain an analysis result;
matching suggestion information for improving the operation performance of the multi-core architecture according to the analysis result;
generating a multi-core architecture operation performance analysis report according to the utilization rate of the CPU, the analysis result and the suggestion information;
and outputting the multi-core architecture operation performance analysis report.
Therefore, the CPU utilization rate calculation method described in the figure 1 can be implemented to calculate the CPU utilization rate under the condition that the system continuously runs various tasks, the calculation accuracy is high, the calculation method is simple, and the calculation efficiency is further improved.
Example 2
Referring to fig. 2, fig. 2 is a schematic flowchart of a CPU utilization calculating method according to an embodiment of the present disclosure. As shown in fig. 2, the CPU utilization calculating method includes:
s201, determining various target tasks which run uninterruptedly in the system.
S202, acquiring CPU main frequency information and the maximum running times of each target task in preset unit time.
In the embodiment of the application, multiple target tasks are continuously operated in the system, namely, each target task is independently operated in a system dead cycle, and then the maximum operation times of each target task in the system in a preset unit time are recorded.
In the embodiment of the application, the CPU master frequency information is the oscillation speed of the digital pulse signal in the CPU, that is, the theoretical calculation period that the CPU can execute in unit time.
And S203, calculating the calculation cycle of the CPU when each target task runs once in the system according to the CPU main frequency information and the maximum running times.
In the embodiment of the present application, for one of the target tasks, the calculation formula of the calculation cycle of the CPU when the target task runs once in the system is as follows:
Figure BDA0002613367480000091
for example, the preset unit time is 1 second, and the CPU master frequency information is 1.6 × 1016A calculation periodFor one of the target tasks a1, the maximum running time in the system in 1 second is 1000000, and then the calculation cycle of the CPU when the target task a1 runs in the system once is:
Figure BDA0002613367480000092
further, the calculation cycle of the CPU is 1.6 x 10 when the target task a1 runs in the system once6A calculation period.
In the embodiment of the present application, by implementing the above steps S202 to S203, the calculation cycle of the CPU can be calculated when each target task runs once in the system.
After step S203, the following steps are also included:
and S204, when various target tasks continuously run in the system, acquiring the actual running times of each target task in a preset unit time.
In the embodiment of the application, after the calculation period of the CPU when each target task runs once in the system is calculated, various target tasks are actually and uninterruptedly run in the system, and then the actual running times of each target task in the preset unit time are obtained.
And S205, calculating the actual calculation period corresponding to each target task in the preset unit time according to the actual operation times and the calculation period.
In the embodiment of the present application, for each of the target tasks a1, the target task a1 corresponds to an actual operation number and a calculation period of the CPU when the target task a1 is operated once in the system, where the calculation formula of the actual calculation period of the target task a1 is:
and the actual calculation period is the actual operation times.
Similarly, the actual calculation period of each target task can be calculated according to the above formula.
After step S205, the following steps are also included:
and S206, summing the actual calculation periods corresponding to each target task to obtain the actual total calculation periods corresponding to all the target tasks.
In the embodiment of the application, after the actual calculation period of each target task is calculated, the actual calculation periods of all the target tasks are summed to obtain the actual total calculation period.
In the embodiment of the present application, by implementing the above-mentioned steps S205 to S206, the actual total calculation cycle of the CPU when all the target tasks are executed in the preset unit time can be calculated according to the actual execution times and the calculation cycle.
In the embodiment of the present application, by implementing the steps S202 to S206, when a plurality of target tasks are continuously run in the system, the actual total calculation period of the CPU when all the target tasks are run in the preset unit time can be calculated.
And S207, calculating the maximum calculation period of the CPU in the preset unit time according to the preset calculation rule and the CPU main frequency information.
In the embodiment of the present application, by implementing the step S208, the maximum calculation cycle of the CPU in the preset unit time can be obtained.
In the embodiment of the present application, the preset calculation rule includes a preset coefficient and the like, which is not limited in the embodiment of the present application.
In practical use, the predetermined coefficient is usually 1016Then the formula for calculating the maximum calculation period of the CPU may be;
maximum calculation period is CPU main frequency information 1016
After step S207, the following steps are also included:
and S208, calculating the utilization rate of the CPU according to the maximum calculation period and the actual total calculation period.
Therefore, the CPU utilization rate calculation method described in the figure 2 can be implemented to calculate the CPU utilization rate under the condition that the system continuously runs various tasks, the calculation accuracy is high, the calculation method is simple, and the calculation efficiency is further improved.
Example 3
Referring to fig. 3, fig. 3 is a schematic structural diagram of a CPU utilization calculating device according to an embodiment of the present disclosure. As shown in fig. 3, the CPU utilization calculating apparatus includes:
a determination module 300 for determining a plurality of target tasks that are to be run without interruption in the system.
The first calculating module 400 is configured to calculate an actual total calculating period of the CPU when all the target tasks are operated within a preset unit time when the plurality of target tasks are continuously operated in the system.
The obtaining module 500 is configured to obtain a maximum computation cycle of the CPU within a preset unit time.
And a second calculating module 600, configured to calculate a utilization rate of the CPU according to the maximum calculating period and the actual total calculating period.
In this embodiment, for the explanation of the CPU utilization calculating apparatus, reference may be made to the description in embodiment 1 or embodiment 2, and details are not repeated in this embodiment.
Therefore, the CPU utilization rate calculating device described in the figure 3 can calculate the CPU utilization rate under the condition that the system continuously runs various tasks, the calculation accuracy is high, the calculation method is simple, and the calculation efficiency is further improved.
Example 4
Referring to fig. 4, fig. 4 is a schematic structural diagram of another CPU utilization calculating device according to an embodiment of the present disclosure. The CPU utilization calculating device shown in fig. 4 is optimized by the CPU utilization calculating device shown in fig. 3. As shown in fig. 4, the first calculation module 400 includes:
the first calculation sub-module 410 is used for calculating the calculation period of the CPU when each target task runs once in the system.
The first obtaining sub-module 420 is configured to obtain an actual operation time of each target task in a preset unit time when multiple target tasks are continuously operated in the system.
And the second calculating sub-module 430 is configured to calculate an actual total calculating period of the CPU when all the target tasks are operated within a preset unit time according to the actual operation times and the calculating period.
As an alternative embodiment, the first calculation submodule 410 includes:
the acquiring unit 411 is configured to acquire CPU master frequency information and the maximum operation times of each target task in a preset unit time;
and a first calculating unit 412, configured to calculate, according to the CPU main frequency information and the maximum operation times, a calculation cycle of the CPU when each target task operates once in the system.
As an alternative embodiment, the second calculation submodule 430 includes:
the second calculating unit 431 is used for calculating the actual calculating period corresponding to each target task in the preset unit time according to the actual running times and the calculating period;
and the summing unit 432 is configured to perform summing processing on the actual computing period corresponding to each target task to obtain the actual total computing periods corresponding to all target tasks.
As an optional implementation manner, the obtaining module 500 is specifically configured to calculate a maximum calculation cycle of the CPU in a preset unit time according to a preset calculation rule and CPU main frequency information.
In this embodiment, for the explanation of the CPU utilization calculating apparatus, reference may be made to the description in embodiment 1 or embodiment 2, and details are not repeated in this embodiment.
Therefore, the CPU utilization rate calculating device described in the figure 4 can calculate the CPU utilization rate under the condition that the system continuously runs various tasks, the calculation accuracy is high, the calculation method is simple, and the calculation efficiency is further improved.
An embodiment of the present application provides an electronic device, including a memory and a processor, where the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the CPU utilization calculation method in any one of embodiment 1 or embodiment 2 of the present application.
An embodiment of the present application provides a computer-readable storage medium, which stores computer program instructions, and when the computer program instructions are read and executed by a processor, the method for calculating a CPU utilization in any one of embodiment 1 or embodiment 2 of the present application is executed.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

Claims (10)

1. A CPU utilization calculation method is characterized by comprising the following steps:
determining a plurality of target tasks which run uninterruptedly in the system;
when various target tasks are continuously operated in the system, calculating the actual total calculation period of the CPU when all the target tasks are operated in a preset unit time;
acquiring the maximum calculation period of the CPU in the preset unit time;
and calculating the utilization rate of the CPU according to the maximum calculation period and the actual total calculation period.
2. The method according to claim 1, wherein the calculating an actual total calculation period of the CPUs that operate all the target tasks within a preset unit time while the plurality of target tasks are continuously operated in the system comprises:
calculating the calculation period of a CPU when each target task runs once in the system;
when various target tasks run in the system continuously, acquiring the actual running times of each target task in the preset unit time;
and calculating the actual total calculation period of the CPU when all the target tasks are operated in the preset unit time according to the actual operation times and the calculation period.
3. The method according to claim 2, wherein the calculating a calculation cycle of the CPU when each of the target tasks runs once in the system includes:
acquiring CPU main frequency information and the maximum running times of each target task in preset unit time;
and calculating the calculation cycle of the CPU when each target task runs once in the system according to the CPU main frequency information and the maximum running times.
4. The method for calculating the CPU utilization according to claim 2, wherein the calculating an actual total calculation period of the CPU when all the target tasks are operated in the preset unit time according to the actual operation times and the calculation period includes:
calculating an actual calculation period corresponding to each target task in the preset unit time according to the actual operation times and the calculation period;
and summing the actual calculation periods corresponding to each target task to obtain the actual total calculation periods corresponding to all the target tasks.
5. The method according to claim 3, wherein the obtaining the maximum computation cycle of the CPU in the preset unit time includes:
and calculating the maximum calculation period of the CPU in the preset unit time according to a preset calculation rule and the CPU main frequency information.
6. A CPU utilization calculating apparatus, comprising:
the system comprises a determining module, a processing module and a processing module, wherein the determining module is used for determining various target tasks which run uninterruptedly in the system;
the first calculation module is used for calculating the actual total calculation period of the CPU when all the target tasks are operated in a preset unit time when various target tasks are continuously operated in the system;
the acquisition module is used for acquiring the maximum calculation period of the CPU in the preset unit time;
and the second calculation module is used for calculating the utilization rate of the CPU according to the maximum calculation period and the actual total calculation period.
7. The CPU utilization computing device of claim 6, wherein the first computing module comprises:
the first calculation submodule is used for calculating the calculation period of the CPU when each target task runs once in the system;
the first obtaining sub-module is used for obtaining the actual running times of each target task in the preset unit time when various target tasks run in the system continuously;
and the second calculation submodule is used for calculating the actual total calculation period of the CPU when all the target tasks are operated in the preset unit time according to the actual operation times and the calculation period.
8. The CPU utilization computing arrangement of claim 7, wherein the first computing submodule comprises:
the acquisition unit is used for acquiring CPU main frequency information and the maximum operation times of each target task in preset unit time;
and the first calculating unit is used for calculating the calculating period of the CPU when each target task runs once in the system according to the CPU main frequency information and the maximum running times.
9. An electronic device, comprising a memory for storing a computer program and a processor for executing the computer program to cause the electronic device to perform the CPU utilization calculation method according to any one of claims 1 to 5.
10. A readable storage medium storing computer program instructions, which when read and executed by a processor, perform the CPU utilization calculation method according to any one of claims 1 to 5.
CN202010764790.6A 2020-07-31 2020-07-31 CPU utilization rate calculation method and device Active CN111913805B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010764790.6A CN111913805B (en) 2020-07-31 2020-07-31 CPU utilization rate calculation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010764790.6A CN111913805B (en) 2020-07-31 2020-07-31 CPU utilization rate calculation method and device

Publications (2)

Publication Number Publication Date
CN111913805A true CN111913805A (en) 2020-11-10
CN111913805B CN111913805B (en) 2023-11-28

Family

ID=73287519

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010764790.6A Active CN111913805B (en) 2020-07-31 2020-07-31 CPU utilization rate calculation method and device

Country Status (1)

Country Link
CN (1) CN111913805B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1403912A (en) * 2001-09-06 2003-03-19 Lg电子株式会社 Method and apparatus for measuring task occupancy of centhal processor in real-time system
CN101145125A (en) * 2006-09-11 2008-03-19 中兴通讯股份有限公司 Method for measuring task CPU occupancy rate in multitasking operation system
CN101178688A (en) * 2007-11-29 2008-05-14 中兴通讯股份有限公司 CPU occupancy rate detection method and system of system task
CN102110043A (en) * 2010-12-30 2011-06-29 上海顶竹通讯技术有限公司 Method and device for computing CPU occupancy rate
CN106708709A (en) * 2015-07-30 2017-05-24 中兴通讯股份有限公司 CPU occupancy rate detection method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1403912A (en) * 2001-09-06 2003-03-19 Lg电子株式会社 Method and apparatus for measuring task occupancy of centhal processor in real-time system
CN101145125A (en) * 2006-09-11 2008-03-19 中兴通讯股份有限公司 Method for measuring task CPU occupancy rate in multitasking operation system
CN101178688A (en) * 2007-11-29 2008-05-14 中兴通讯股份有限公司 CPU occupancy rate detection method and system of system task
CN102110043A (en) * 2010-12-30 2011-06-29 上海顶竹通讯技术有限公司 Method and device for computing CPU occupancy rate
CN106708709A (en) * 2015-07-30 2017-05-24 中兴通讯股份有限公司 CPU occupancy rate detection method and device

Also Published As

Publication number Publication date
CN111913805B (en) 2023-11-28

Similar Documents

Publication Publication Date Title
CN106407190B (en) Event record query method and device
US10452983B2 (en) Determining an anomalous state of a system at a future point in time
KR101879416B1 (en) Apparatus and method for detecting abnormal financial transaction
US8516499B2 (en) Assistance in performing action responsive to detected event
EP3413197B1 (en) Task scheduling method and device
WO2012018694A1 (en) Predicting a user behavior number of a word
CN106033574B (en) Method and device for identifying cheating behaviors
CN112600919B (en) Equipment computing power evaluation method and system based on PoW consensus mechanism
WO2021169386A1 (en) Graph data processing method, apparatus and device, and medium
CN111062642A (en) Method and device for identifying industrial risk degree of object and electronic equipment
CN113360270A (en) Data cleaning task processing method and device
CN115794342A (en) Method and device for estimating remaining time of pipeline task and electronic equipment
CN112579327A (en) Fault detection method, device and equipment
CN108595685B (en) Data processing method and device
CN110928636A (en) Virtual machine live migration method, device and equipment
CN111913805B (en) CPU utilization rate calculation method and device
CN111783883A (en) Abnormal data detection method and device
CN115935723A (en) Equipment combination analysis method and system for gallium nitride preparation scene
CN116303820A (en) Label generation method, label generation device, computer equipment and medium
CN107516114B (en) Time sequence processing method and device
JP2008191812A (en) Program file importance determination device and program file importance determination method
CN115269288A (en) Fault determination method, device, equipment and storage medium
CN114398235A (en) Memory recovery trend early warning device and method based on fusion learning and hypothesis testing
JP2008191813A (en) File importance determination device, file importance determination method and file importance determination program
CN113297245A (en) Method and device for acquiring execution information

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant