CPU power consumption monitoring method and system based on dynamic weighted fusion integral
Through the dynamic weighted fusion integration method, combined with the trapezoidal rule and Simpson's rule, the misjudgment problem caused by instantaneous fluctuations in CPU power consumption monitoring is solved, and low-latency and high-precision power consumption monitoring is achieved, which is suitable for embedded systems and real-time power consumption monitoring.
Patent Information
- Application Number
- CN202511010392.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-22
- Publication Date
- 2025-10-17
AI Technical Summary
In existing CPU power consumption monitoring technology, the threshold judgment is inaccurate due to instantaneous power consumption mutations. In addition, traditional methods have high computational complexity, poor real-time performance, and weak noise resistance.
A dynamic weighted fusion integration method is adopted to implement parallel integration of trapezoidal rule and Simpson's rule, and dynamically adjust weights in combination with variance to achieve low-latency and high-precision power consumption monitoring, and reduce the computational complexity to O(1).
It improves the accuracy and robustness of CPU power consumption monitoring, reduces computing resource consumption, and is suitable for scenarios with high-frequency sampling and high real-time requirements.
Smart Images

Figure CN120803852A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of CPU power consumption monitoring, and particularly relates to a CPU power consumption monitoring method and system based on dynamic weighted fusion integration. BACKGROUND
[0002] One of the cores of CPU performance optimization is to dynamically balance computing power and power consumption, and accurate power consumption monitoring is a key basis to achieve this goal. Traditional methods include:
[0003] Single-point threshold method: based on instantaneous frequency or power consumption value to monitor CPU reading power consumption data at a certain time, but sensitive to sudden fluctuations.
[0004] Average method: by setting a time window N, the time window updates the data and then calculates the average window average data, but the calculation complexity is high (O(n)), and it cannot effectively filter high-frequency noise and real fluctuations and reflect real power fluctuations.
[0005] Single-point threshold method defects: highly sensitive to instantaneous fluctuations, sudden power spikes are prone to misjudgment; lack of time sequence correlation analysis, cannot identify continuous abnormal state; poor anti-noise ability, easy to be affected by high-frequency interference.
[0006] Average method defects: linear calculation complexity (O(n)) leads to poor real-time performance; fixed time window is difficult to adapt to dynamic load changes; arithmetic average method treats historical data with equal weight, cannot distinguish noise from effective signal; data update needs full recalculation, high memory occupation.
[0007] The present application aims to solve the problem that some indicators are inaccurate in CPU power consumption threshold judgment due to instantaneous power consumption mutation in existing CPU power consumption monitoring technology. SUMMARY
[0008] To solve the above technical problems, the present application provides a CPU power consumption monitoring method and system based on dynamic weighted fusion integration, which improves the monitoring accuracy of power consumption based on the joint integral adaptive adjustment strategy of dynamic weight adjustment, and reduces the calculation complexity of traditional integral algorithm from O(n) to O(1), realizing high-precision, low-delay real-time power consumption monitoring.
[0009] To solve the above technical problems, the present application adopts the following technical solutions:
[0010] A CPU power consumption monitoring method based on dynamic weighted fusion integration, comprising:
[0011] Real-time acquisition of CPU power consumption data sequence;
[0012] The trapezoidal rule integral and Simpson's rule integral are performed in parallel within the current time window of the CPU power consumption data sequence, and the obtained integral is divided by the window length to obtain the trapezoidal rule average power consumption P T and Simpson's law average power consumption P Sp ;
[0013] Calculate the variance of CPU power consumption data within the current time window to evaluate the intensity of power consumption fluctuations;
[0014] The weight coefficient α is dynamically generated according to the variance, and the final power consumption P of the current time window is calculated by the weighted fusion formula. L :P L =αP T +(1-α)P Sp ;
[0015] When the time window slides, only the integral contribution of the newly added CPU power consumption data is calculated through incremental updates.
[0016] In one embodiment, the real-time collection of CPU power consumption data sequence specifically includes:
[0017] Directly collect CPU power consumption data P(t i ), generate CPU power consumption data sequence:
[0018] {P(t0),…,P(t i ),…,P(t n )},t i =t0+i·h;
[0019] t i is the i-th moment; P(t i ) is the CPU power consumption data at the i-th moment.
[0020] In one embodiment, performing trapezoidal rule integration within a current time window of a CPU power consumption data sequence specifically includes:
[0021]
[0022] t k is the index of the kth moment, n1 is the number of time intervals from moment k to moment k+m, S m,k It is the integral of CPU power consumption from time k to time k+m.
[0023] In one embodiment, performing Simpson's law integration within a current time window of a CPU power consumption data sequence specifically includes:
[0024]
[0025] t k is the index of the kth moment, n2 is the number of time intervals from moment k to moment k+m, n2 is rounded up to an even number, S m,k It is the integral of CPU power consumption from time k to time k+m.
[0026] In one embodiment, calculating the variance of CPU power consumption data within the current time window to evaluate the power consumption fluctuation intensity specifically includes:
[0027] Calculate the latest n1 CPU power consumption data using the trapezoidal rule window size The variance σ 2 :
[0028]
[0029] μ represents the average of the latest n1 CPU power consumption data, and k is the index of the kth moment.
[0030] In one embodiment, dynamically generating a weight coefficient α according to the variance specifically includes:
[0031]
[0032] σ max The largest historical variance.
[0033] A CPU power consumption monitoring system based on dynamic weighted fusion integration, comprising:
[0034] Data acquisition module: real-time collection of CPU power consumption data series;
[0035] Parallel integration module: executes trapezoidal rule integration and Simpson's rule integration in parallel within the current time window of the CPU power consumption data sequence, divides the obtained integral by the window length, and obtains the trapezoidal rule average power consumption P and Simpson's rule average power consumption P respectively. T and Simpson's law average power consumption P Sp ;
[0036] Variance calculation module: calculates the variance of CPU power consumption data within the current time window to evaluate the intensity of power consumption fluctuation;
[0037] Weight adjustment module: dynamically generates a weight coefficient α according to the variance;
[0038] Fusion output module: calculates the final power consumption P of the current time window through the weighted fusion formula L , P L =αP T +(1-α)P Sp ;
[0039] When the time window slides, only the integral contribution of the newly added CPU power consumption data is calculated by incremental updating.
[0040] In one embodiment, the real-time CPU power consumption data sequence is collected, specifically including:
[0041] The CPU power consumption data P(t i ) is directly collected at a fixed time interval h to generate a CPU power consumption data sequence:
[0042] {P(t0),…,P(t i ),…,P(t n )},t i =t0+i·h;
[0043] t i is the i-th time; P(t i ) is the CPU power consumption data at the i-th time.
[0044] In one embodiment, the trapezoidal rule integration is performed within the current time window of the CPU power consumption data sequence, specifically including:
[0045]
[0046] t k is the index of the k-th time, n1 is the number of time intervals from the k-th time to the k+m-th time, S m,k is the CPU power consumption integral from the k-th time to the k+m-th time.
[0047] In one embodiment, the Simpson rule integration is performed within the current time window of the CPU power consumption data sequence, specifically including:
[0048]
[0049] t k is the index of the k-th time, n2 is the number of time intervals from the k-th time to the k+m-th time, n2 is an even number, S m,k is the CPU power consumption integral from the k-th time to the k+m-th time.
[0050] Compared with the prior art, the present application has the beneficial technical effects of:
[0051] 1. Strong anti-burst interference capability: The present application uses the integral area of CPU power consumption as a monitoring indicator by sliding window integration and averaging, replacing the traditional single-point value or simple window average. This method can effectively smooth out sudden power consumption peaks (such as instantaneous high load), avoid false positives caused by instantaneous fluctuations, and enhance the robustness of the system to abnormal power consumption.
[0052] 2. Dynamic optimization of precision and stability: The present application uses two integration rules in parallel: the trapezoidal rule and the Simpson rule. By calculating the variance of the results of the two rules in real time, the weights are dynamically adjusted. When the data is stable, the high-precision algorithm such as the Simpson rule is preferred; when the fluctuation is large, the robust algorithm such as the trapezoidal rule is preferred; both real-time and accuracy are considered to improve the reliability of the overall results.
[0053] 3. Significant improvement in computational efficiency: The present application uses a sliding window incremental calculation mechanism. Only one data point integration result needs to be updated each time the window slides, reducing the complexity from O(n) of the traditional integration to O(1). This optimization greatly reduces resource consumption, especially for high-frequency sampling or real-time requirements (such as embedded systems, real-time power monitoring). BRIEF DESCRIPTION OF DRAWINGS
[0054] Figure 1 The method flowchart in the embodiment of the present application is shown in the figure;
[0055] Figure 2 The system module schematic diagram in the embodiment of the present application is shown in the figure;
[0056] Figure 3 The smooth power consumption effect schematic diagram in the embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0057] A preferred embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0058] When using the CPU power consumption at a certain time as a threshold for identification or monitoring CPU power consumption, sudden changes in power consumption often occur. In order to more accurately reflect the trend of CPU power consumption, the present application considers integrating the CPU power consumption over a period of time to obtain the area of the power consumption, and then dividing by the length of the integration interval. In this way, the area can effectively smooth the data of the sudden changes in CPU operation. Wherein, f(t) represents the CPU power consumption at time t. However, since the value of f(t) can only be obtained intermittently, it is not possible to directly calculate the continuous integral accurately. Therefore, a mathematical method can be used to convert the continuous integral into the form of the sum of discrete function values, thereby realizing the approximate integral calculation of CPU power consumption.
[0059] Newton-Cotes formula:
[0060] Lagrange interpolation: Choose equidistant time nodes x0, x1, …, x n , construct an interpolation polynomial Pn(x) to approximate the original function f(x), and the integral is converted to a weighted sum of basis functions:
[0061]
[0062] Trapezoidal rule:
[0063] When n = 1, x0= a, x1= b, the corresponding formula is called the trapezoidal rule, in which case
[0064]
[0065] Thus The trapezoidal rule is obtained:
[0066]
[0067] The error of the trapezoidal rule is where M1= max ξ∈(a,b) f (2) (ξ).
[0068] Simpson's rule:
[0069] When n = 2, x0= a, x2= b, the corresponding formula is called Simpson's rule, in which case
[0070]
[0071] Thus Simpson's rule is obtained:
[0072]
[0073] The error of Simpson's rule is where M2= max ξ∈(a,b) f (4) (ξ).
[0074] Comparing the errors of the trapezoidal rule and Simpson's rule, it is not difficult to find that the trapezoidal rule has smaller calculation amount and faster response but larger error, while Simpson's rule has smaller error but larger calculation amount. In fact, with the increase of n, the accuracy of Newton-Cotes formula will be higher and higher, but the integral calculation of A i will also be more and more complex. Moreover, in practical applications, it is necessary to ensure that the integral calculation is always carried out, so in order to reduce the complexity from O(n) to O(1), it is necessary to make the coefficients of O(n) points in each step as same as possible. Therefore, it is considered to use the trapezoidal rule or Simpson's rule for each interval [x i-1 , x i ], i = 1, 2,..., n.
[0075] The specific algorithm flow is shown in Figure 1 , and specifically includes:
[0076] 1. Data acquisition and pretreatment: directly acquire power consumption P(ti) at a fixed time interval h to generate a sequence:
[0077] {P(t0),…,P(t i ),…,P(t n )},t i =t0+i·h;
[0078] 2. Joint integration strategy: sliding window update, complexity O(1).
[0079] Trapezoidal rule (step size 1):
[0080]
[0081] Simpson's rule (step 2):
[0082]
[0083] Only the integral and boundary values of the current window need to be retained, such as P(t k-2 )to
[0084] After the improvement, both complexities are O(1). The trapezoidal rule requires less initial preparation (a stride of 1), while the Simpson's rule has a smaller error and better results. When data fluctuates violently, the trapezoidal rule is preferred (fast response but low accuracy); when data is stable, switch to the Simpson's rule (high accuracy but slow response).
[0085] 3. Weighted fusion integration: Run two integration methods simultaneously and output weighted results:
[0086] P l =αP T +(1-α)P Sp ;
[0087] Among them, the weight α∈[0,1] is dynamically determined by the current data fluctuation intensity.
[0088] 4. Weight calculation: Based on the window size n1 of the trapezoidal rule, calculate the latest n1 power consumption data Variance of:
[0089]
[0090] Using the sliding window feature, recursively update the mean and variance, maintain O(1) complexity, and calculate the variance σ of n1 power consumption data in the most recent window 2 .
[0091] Dynamically set weights:
[0092]
[0093] σ maxThe maximum variance for history needs to be dynamically updated: sigma max = max(sigma max , sigma 2 ).
[0094] The greater the fluctuation (sigma 2 ), the higher the trapezoidal rule weight alpha, and the faster response is given priority; otherwise, the Simpson rule dominates to improve accuracy.
[0095] Based on the description of the method embodiments described above, the present application also provides a system. The system can be a software (application), module, component, server, client, etc. using the method described in the embodiments of the present application, combined with the necessary implementation hardware. Based on the same innovative concept, the system in one or more embodiments provided by the embodiments of the present application is described as follows. Since the implementation scheme of the system to solve the problem is similar to the method, the implementation of the specific system in the embodiments of the present application can be referred to the implementation of the foregoing method, and the repeated parts will not be described herein. The term "module" or "module" used below refers to a combination of software and / or hardware that can implement a predetermined function. Although the system described in the following embodiments is preferably implemented in software, hardware, or a combination of software and hardware implementation is also possible and is conceived.
[0096] As shown in Figure 2 , a CPU power consumption monitoring system based on dynamic weighted fusion integration in the present application comprises:
[0097] Data acquisition module: real-time acquisition of CPU power consumption data sequence through MSR 0x611 register;
[0098] Parallel integration module: parallel execution of trapezoidal rule integration and Simpson rule integration in the current time window of the CPU power consumption data sequence, and the obtained integrals are divided by the window length to obtain the trapezoidal rule average power P T and Simpson rule average power P Sp , respectively;
[0099] Variance calculation module: calculate the variance of the CPU power consumption data in the current time window to evaluate the fluctuation strength of the power consumption;
[0100] Weight adjustment module: dynamically generate weight coefficient alpha according to the variance;
[0101] Fusion output module: calculate the final power consumption P L of the current time window through the weighted fusion formula, P L = alpha P T + (1-alpha) P Sp ;
[0102] When the time window slides, only the integral contribution of the newly added CPU power consumption data is calculated by incremental updating.
[0103] Figure 3 The change trend of CPU power consumption over time is shown, and three curves are shown: original power consumption data (obvious fluctuation), sliding average processing data (noise is reduced by smoothing), and dynamic fusion integral result (combining trapezoidal rule and Simpson rule, dynamically adjusting weight alpha based on variance, balancing accuracy and stability). Through comparison, it can be seen that the dynamic fusion integral retains the advantages of sliding average smoothing, further optimizes the reliability and adaptability of the integral result, and finally presents a more stable CPU power consumption analysis output.
[0104] In summary, the present application adopts the method of sliding window integral average of CPU power consumption, and uses the calculation of average CPU power consumption area instead of single point value and window average monitoring CPU power consumption. Two integral rules are used to calculate CPU power consumption, and the weights of the two integral results are adjusted according to the data fluctuation by variance weighting. The CPU power consumption is divided into several intervals according to time, and integral rule is used in each interval. Through window sliding, only one data is calculated each time, and the calculation complexity is reduced from O(n) to O(1).
[0105] It should be understood that although each step in the flowchart of the accompanying drawings is shown in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other sequences. Moreover, at least part of the steps in the flowchart of the accompanying drawings can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or steps or stages in other steps.
[0106] The technical features of the above embodiments can be combined in any way. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described, but as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application.
[0107] It will be obvious to a person skilled in the art that the application is not limited to the details of the foregoing exemplary embodiments and can be implemented in other concrete forms without departing from the spirit or essential characteristics of the application. The embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein and no
[0108] Furthermore, it should be understood that although the description is made on the basis of the embodiments, not every embodiment contains only one independent technical solution, and the description is made in this way only for the sake of clarity, and a person skilled in the art should consider the description as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by a person skilled in the art.
Claims
1. A CPU power consumption monitoring method based on dynamic weighted fusion integration, characterized in that: include: Real-time collection of CPU power consumption data series; The trapezoidal rule integral and Simpson's rule integral are performed in parallel within the current time window of the CPU power consumption data sequence, and the obtained integral is divided by the window length to obtain the trapezoidal rule average power consumption P T and Simpson's law average power consumption P Sp ; Calculate the variance of CPU power consumption data within the current time window to evaluate the intensity of power consumption fluctuations; The weight coefficient α is dynamically generated according to the variance, and the final power consumption P of the current time window is calculated by the weighted fusion formula. L :P L =αP T +(1-α)P Sp ; When the time window slides, only the integral contribution of the newly added CPU power consumption data is calculated through incremental updates.
2. The CPU power consumption monitoring method based on dynamic weighted fusion integration according to claim 1, characterized in that: The real-time collection of CPU power consumption data sequence specifically includes: Directly collect CPU power consumption data P(t i ), generate CPU power consumption data sequence: {P(t0),…,P(t i ),…,P(t n )},t i =t0+i·h; t i is the i-th moment; P(t i ) is the CPU power consumption data at the i-th moment.
3. The CPU power consumption monitoring method based on dynamic weighted fusion integration according to claim 2 is characterized in that: Perform trapezoidal rule integration within the current time window of the CPU power consumption data series, including: t k is the index of the kth moment, n1 is the number of time intervals from moment k to moment k+m, S m,k It is the integral of CPU power consumption from time k to time k+m.
4. The CPU power consumption monitoring method based on dynamic weighted fusion integration according to claim 2, characterized in that: Perform Simpson's law integration within the current time window of the CPU power consumption data series, including: t k is the index of the kth moment, n2 is the number of time intervals from moment k to moment k+m, n2 takes an even number, S m,k It is the integral of CPU power consumption from time k to time k+m.
5. The CPU power consumption monitoring method based on dynamic weighted fusion integration according to claim 2, characterized in that: Calculating the variance of the CPU power consumption data within the current time window to evaluate the power consumption fluctuation intensity specifically includes: Calculate the latest n1 CPU power consumption data using the trapezoidal rule window size The variance σ 2 : μ represents the average of the latest n1 CPU power consumption data, and k is the index of the kth moment.
6. The CPU power consumption monitoring method based on dynamic weighted fusion integration according to claim 5, characterized in that: The dynamically generating weight coefficient α according to the variance specifically includes: σ max The largest historical variance.
7. A CPU power consumption monitoring system based on dynamic weighted fusion integration, characterized in that: include: Data acquisition module: real-time collection of CPU power consumption data series; Parallel integration module: executes trapezoidal rule integration and Simpson's rule integration in parallel within the current time window of the CPU power consumption data sequence, divides the obtained integral by the window length, and obtains the trapezoidal rule average power consumption P and Simpson's rule average power consumption P respectively. T and Simpson's law average power consumption P Sp ; Variance calculation module: calculates the variance of CPU power consumption data within the current time window to evaluate the intensity of power consumption fluctuation; Weight adjustment module: dynamically generates a weight coefficient α according to the variance; Fusion output module: calculates the final power consumption P of the current time window through the weighted fusion formula L , P L =αP T +(1-α)P Sp ; Among them, when the time window slides, only the integral contribution of the newly added CPU power consumption data is calculated through incremental updating.
8. The CPU power consumption monitoring system based on dynamic weighted fusion integration according to claim 7, characterized in that: The real-time collection of CPU power consumption data sequence specifically includes: Directly collect CPU power consumption data P(t i ), generate CPU power consumption data sequence: {P(t0),…,P(t i ),…,P(t n )},t i =t0+i·h; t i is the i-th moment; P(t i ) is the CPU power consumption data at the i-th moment.
9. The CPU power consumption monitoring system based on dynamic weighted fusion integration according to claim 8, characterized in that: Perform trapezoidal rule integration within the current time window of the CPU power consumption data series, including: t k is the index of the kth moment, n1 is the number of time intervals from moment k to moment k+m, S m,k It is the integral of CPU power consumption from time k to time k+m.
10. The CPU power consumption monitoring system based on dynamic weighted fusion integration according to claim 8, characterized in that: Perform Simpson's law integration within the current time window of the CPU power consumption data series, including: t k is the index of the kth moment, n2 is the number of time intervals from moment k to moment k+m, n2 is rounded up to an even number, S m,k It is the integral of CPU power consumption from time k to time k+m.