A computer performance data collection method and system
By using trend baselines and acquisition overhead values for load prediction during computer performance data acquisition and dynamically adjusting the sampling interval, the problem of the acquisition frequency being out of sync with the load status in existing technologies is solved. This achieves adaptive sampling frequency adjustment and improves the accuracy and efficiency of performance analysis.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGSU VOCATIONAL COLLEGE OF BUSINESS
- Filing Date
- 2026-06-05
- Publication Date
- 2026-07-03
AI Technical Summary
Existing computer performance data acquisition methods ignore the dynamic fluctuation characteristics of computer operating status, which increases system pressure during high load phases and fails to capture occasional stutters during low load phases. This causes performance analysis results to deviate from the actual operating state and cannot accurately support subsequent optimization or anomaly diagnosis.
By collecting processing utilization, memory utilization, thread switching rate and interaction frequency in each sampling period, a state set is generated. The trend base value is calculated by sliding accumulation, and the load is predicted by combining the collection overhead value. The sampling interval is dynamically adjusted to achieve adaptive sampling frequency adjustment.
It enables automatic adjustment of the sampling frequency based on load prediction values, avoiding the exacerbation of congestion during high load collection, capturing hidden fluctuations during low load, improving the accuracy and efficiency of performance analysis, and avoiding misjudgments and resource scheduling errors.
Smart Images

Figure CN122332222A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer data processing technology, specifically to a method and system for acquiring computer performance data. Background Technology
[0002] As modern computing devices continue to evolve, people are no longer satisfied with simply knowing whether a computer can perform a certain function, but are increasingly concerned with the performance behavior characteristics exhibited by computers during actual operation. Therefore, computer performance data collection is no longer limited to basic resource usage records, but has gradually evolved into a key technical means that permeates operating system scheduling, application behavior analysis, and runtime performance awareness. Whether used for evaluating the user experience of personal devices or for monitoring the operational status of enterprise-level servers, computer performance data collection has become a bridge connecting computing resources and intelligent optimization strategies; the rationality and efficiency of its collection methods directly determine the reliability of subsequent analysis and scheduling.
[0003] However, in existing performance data acquisition mechanisms, the sampling frequency is often set to a constant value, such as recording CPU utilization every 100ms or memory status every 500ms. While this "uniform sampling" method is simple to implement, it ignores the dynamic fluctuations in computer operating states: during high-load phases, high-frequency sampling may further increase system pressure, causing the sampling behavior itself to negatively impact performance; while during low-load or idle phases, fixed low-frequency sampling makes it difficult to capture hidden problems such as occasional stuttering or frequent background thread wake-ups in a timely manner. Long-term reliance on static sampling will cause performance analysis results to deviate from the true operating state characteristics, failing to accurately support subsequent performance tuning or anomaly diagnosis.
[0004] This disconnect between data collection frequency and load status can lead to two types of abnormal consequences in practical use: First, when the data collection thread runs continuously on a high-load device, it can cause the CPU to be continuously fully loaded, the fan speed to rise abnormally, and even the system response to be delayed. Users or maintenance personnel may find it difficult to distinguish whether the device is "naturally busy" or "being dragged down by monitoring." Second, if the data collection frequency is too low during idle periods, it is easy to miss sudden performance spikes, making the monitoring results appear "stable on the surface, but actually intermittently abnormal." If the system's operating status is judged based on such distorted data, it may lead to incorrect maintenance decisions, and even cause misjudgments in resource scheduling in server scenarios, triggering a chain reaction of performance degradation problems. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a computer performance data acquisition method and system, which solves the problems mentioned in the background section.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a computer performance data acquisition method, comprising the following steps: S1. In each sampling period, the processing utilization Cpuu, memory utilization Memu, thread switching rate Ths, and interaction frequency Uih are collected through the computer system resource interface, and written into the state set Stc according to a unified time sequence index. S2. Perform a sliding accumulation operation on the state set Stc generated in two or more consecutive sampling periods in chronological order to obtain the trend base value Tbs; S3. Record the execution time of the acquisition thread in the previous sampling period as the acquisition cost value Coi. Input the trend base value Tbs and the acquisition cost value Coi into the load mapping function and compare and calibrate them to obtain the load prediction value Ldp. Generate the sampling adjustment coefficient Frs based on the load prediction value Ldp. S4. Calculate the sampling interval Del by performing a reciprocal mapping based on the sampling adjustment coefficient Frs, and then perform a multiple correction on the sampling interval Del based on the load prediction value Ldp. Apply the corrected sampling interval Del to the scheduling control of the next sampling period.
[0007] Preferably, S1 includes S11; S11. Using the resource monitoring interface or process management instructions provided by the computer operating system, call the system call function at a single sampling moment to read the proportion of computation time occupied in the current time slice in the processor scheduling module, and record the proportion of computation time as the processing utilization rate Cpuu. At the same time, the ratio of the number of allocated memory pages to the number of available memory pages is read through the memory management interface and recorded as the memory utilization rate (Memu). Processing utilization (Cpuu) and memory utilization (Memu) are stored as percentages and appended with a uniform time-series index.
[0008] Preferably, S1 further includes S12; S12. After collecting the processing utilization Cpuu and memory utilization Memu, call the thread scheduling record interface within the same collection period to obtain the number of context switches that occurred in the scheduler within that period, record it as the thread switching rate Ths, and attach a unified time sequence index. Accumulate the number of keyboard key presses and mouse clicks, record the total number of keyboard key presses and mouse clicks as the interaction frequency Uih, and attach a unified time-series index; The processing utilization Cpuu, memory utilization Memu, thread switching rate Ts, and interaction frequency Uih are written into the constructed state set Stc in the order of the collection time sequence index.
[0009] Preferably, S2 includes S21; S21. The state set Stc generated in the previous sampling period and the state set Stc recorded in several historical periods are arranged in chronological order to form a continuous sequence, and the processing utilization Cpuu, memory utilization Memu and thread switching rate Ths are extracted as the basic data for trend analysis. The processing utilization Cpuu, memory utilization Memu, and thread switching rate Ts are calculated by sliding accumulation with time decay to generate the processing trend value Cptv, memory trend value Mmtv, and switching trend value Tstv. Min-Max normalization is then used for normalization, followed by weighted averaging to generate the comprehensive trend value trend base value Tbs. The comprehensive trend value, the trend base value Tbs, is obtained through the following calculation formula: Tbs=t1×Cptv+t2×Mmtv+t3×Tstv; In the formula, t1, t2 and t3 represent the weighting coefficients of the processing trend value Cptv, the memory trend value Mmtv and the switching trend value Tstv, respectively, and t1+t2+t3=1. The specific values are set by the user.
[0010] Preferably, S2 further includes S22; S22. Use the generated trend base value Tbs and the acquisition overhead value Coi calculated by the acquisition thread execution time recorded in the previous acquisition cycle as prediction input parameters, and substitute them into the load mapping function for calculation. The acquisition cost value Coi is obtained through the following calculation process: In the previous acquisition cycle, the time identifier when the acquisition thread enters the acquisition logic is recorded as the start time Tst, and the time identifier when the acquisition logic finishes execution is recorded as the end time Ted. The acquisition processing time of the previous acquisition cycle is obtained by subtracting the start time Tst from the end time Ted. The acquisition processing time is then processed according to the unified dimensionless processing rules, and the dimensionless result after processing is recorded as the acquisition overhead value Coi. The load mapping function uses a multiply-accumulate model to calculate the theoretical load value by combining the trend base value Tbs and the acquisition overhead value Coi in a fixed ratio, and then compares and calibrates the theoretical load value with the processing trend value Cptv of the current sampling period. When the difference between the theoretical load value and the processed trend value Cptv is within the preset allowable range, the theoretical load value is used as the prediction result. When the difference between the theoretical load value and the processed trend value Cptv exceeds the preset allowable range, the average value of the theoretical load value and the processed trend value Cptv is used as the prediction result. Finally, the calibrated prediction results are compared and recorded as the load prediction value Ldp. The load prediction value Ldp is normalized using Min-Max normalization, and its value range is limited to [0, 1]. Here, 0 represents a completely idle state and 1 represents the highest load state. When the load prediction value Ldp is compared with the conditions, the dimensionless value within this normalization range is used for judgment.
[0011] Preferably, S3 includes S31; S31. Compare and judge the load prediction value Ldp with the preset sampling adjustment range, and generate different sampling adjustment marks based on the comparison and judgment results as input data for the mapping rules; The sampling adjustment range includes a high load threshold and a low load threshold. When the predicted load value Ldp is higher than the high load threshold, a low-frequency acquisition marker is generated and recorded as the sampling coefficient Lof; When the load prediction value Ldp is between the high load threshold and the low load threshold, a regular acquisition marker is generated and recorded as the sampling coefficient Nom; When the predicted load value Ldp is lower than the low load threshold, a high-frequency acquisition marker is generated and recorded as the sampling coefficient Hif.
[0012] Preferably, S3 includes S32; S32. When the input data is the sampling coefficient Lof, the sampling coefficient Lof is converted into the sampling adjustment ratio according to the fixed low-frequency mapping rule. Specifically, the sampling adjustment coefficient Frs is generated by multiplying the low-frequency adjustment reference value by a multiplier of one. When the input data is the sampling coefficient Nom, the sampling adjustment coefficient Frs is generated by multiplying the intermediate frequency adjustment reference value by a factor of two. When the input data is the sampling coefficient Hif, the sampling adjustment coefficient Frs is generated by multiplying the high-frequency adjustment reference value by a factor of three. Among them, multiplier one, multiplier two and multiplier three are dynamically adjusted based on the combined effect of load prediction value Ldp and interaction frequency Uih; When the load prediction value Ldp increases, the multiplier is reduced; when the interaction frequency Uih decreases, the multiplier is increased, and the sampling adjustment coefficient Frs is obtained.
[0013] Preferably, S4 includes S41; S41. Based on the obtained sampling adjustment coefficient Frs, perform a reciprocal mapping process with the preset basic interval constant, calculate the delay time required for the next sampling period by dividing the basic interval constant by the sampling adjustment coefficient Frs, and record the delay time as the sampling interval Del. Wherein, the sampling adjustment coefficient Frs is a dimensionless parameter after being uniformly dimensionless, and the basic interval constant is a parameter with time dimension, so that the calculated sampling interval Del is still a parameter with time dimension.
[0014] Preferably, S4 further includes S42; S42. The generated sampling interval Del is compared with the load prediction value Ldp and the interaction frequency Uih again, and a new sampling interval Del is generated based on the comparison result. The specific details of the condition comparison are as follows: When the normalized load prediction value Ldp is greater than 0.8 for three consecutive sampling periods, it is determined to be a high load continuous state, and the sampling interval Del is recalculated as three times the current duration as a new sampling interval Del; When the interaction frequency Uih is equal to zero for three consecutive sampling periods and the normalized load prediction value Ldp is less than 0.2, it is determined to be a long-term idle state, and the sampling interval Del is shortened to one-third of the current duration, and a new sampling interval Del is generated. The new sampling interval Del is directly applied to the scheduling control of the next sampling period.
[0015] A computer performance data acquisition system includes a computer data acquisition module, a status trend analysis module, a calibration frequency module, and an acquisition cycle control module; In each sampling period, the computer data acquisition module collects the processing utilization Cpuu, memory utilization Memu, thread switching rate Ths, and interaction frequency Uih through the computer system resource interface, and writes them into the status set Stc according to a unified time sequence index. The state trend analysis module performs a sliding accumulation operation on the state set Stc generated in two or more consecutive sampling periods in chronological order to obtain the trend base value Tbs; The calibration frequency module records the execution time of the acquisition thread in the previous sampling period as the acquisition overhead value Coi. The trend base value Tbs and the acquisition overhead value Coi are input into the load mapping function and compared and calibrated to obtain the load prediction value Ldp. Based on the load prediction value Ldp, the sampling adjustment coefficient Frs is generated. The acquisition cycle control module calculates the sampling interval Del by performing a reciprocal mapping based on the sampling adjustment coefficient Frs, and then performs a multiple correction on the sampling interval Del based on the load prediction value Ldp. The corrected sampling interval Del is then applied to the scheduling control of the next sampling cycle.
[0016] This invention provides a method and system for acquiring computer performance data, which has the following beneficial effects: (1) Automatically adjust its own operating rhythm according to the load prediction value Ldp: When the equipment is under high pressure, the sampling adjustment coefficient Frs is suppressed due to the increase of the acquisition overhead value Coi, which in turn causes the sampling interval Del to be dynamically lengthened, thereby avoiding the acquisition behavior from exacerbating congestion; while when the equipment is idle, the processing utilization Cpuu, memory utilization Memu and thread switching rate Ths are continuously at low values, and the load prediction value Ldp derived by the trend base value Tbs and the acquisition overhead value Coi is at a low level, so the sampling interval Del is actively shortened, which can capture hidden fluctuations in advance when the user does not operate but the background program gradually increases. Traditional fixed frequency acquisition methods often cannot identify the performance degradation inflection point in time, while this method can trigger the sampling frequency increase in the early stage by continuously accumulating the trend base value Tbs.
[0017] (2) By combining the trend base value Tbs with the acquisition overhead value Coi to generate the load prediction value Ldp, the development direction of performance changes can be identified in advance before the sampling thread intervenes, rather than just a static numerical judgment at a certain moment. Since the trend base value Tbs can continuously accumulate the historical upward trend, while the acquisition overhead value Coi reflects the interference caused by the sampling behavior itself, the combination of the two can avoid the judgment bias of a short-term rise in equipment temperature being mistaken for continuous high pressure, or an update download occupying the network but the CPU being idle being mistaken for no system load, thus achieving a dynamic perception effect dominated by trends rather than triggered by single points.
[0018] (3) By establishing a tiered logic between the load prediction value Ldp and the preset threshold, and using sampling coefficients Lof, Nom, and Hif as explicit markers for output, different load stages have clear sampling strategy identities. Compared with the traditional polling method with fixed sampling time, this can automatically avoid the reverse intervention phenomenon of more monitoring leading to more lag in actual operation. Attached Figure Description
[0019] Figure 1 This is a schematic diagram illustrating the steps of a computer performance data acquisition method according to the present invention; Figure 2 This is a schematic diagram of a computer performance data acquisition system according to the present invention; Figure 3 This diagram illustrates the combined trend of CPU utilization (Cpuu) and memory utilization (Memu). Detailed Implementation
[0020] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0021] Example 1: This invention provides a method for acquiring computer performance data. Please refer to [link / reference]. Figure 1 This includes the following steps: S1. In each sampling period, the processing utilization Cpuu, memory utilization Memu, thread switching rate Ths, and interaction frequency Uih are collected through the computer system resource interface, and written into the state set Stc according to a unified time sequence index. S2. Perform a sliding accumulation operation on the state set Stc generated in two or more consecutive sampling periods in chronological order to obtain the trend base value Tbs; S3. Record the execution time of the acquisition thread in the previous sampling period as the acquisition cost value Coi. Input the trend base value Tbs and the acquisition cost value Coi into the load mapping function and compare and calibrate them to obtain the load prediction value Ldp. Generate the sampling adjustment coefficient Frs based on the load prediction value Ldp. S4. Calculate the sampling interval Del by performing a reciprocal mapping based on the sampling adjustment coefficient Frs, and then perform a multiple correction on the sampling interval Del based on the load prediction value Ldp. Apply the corrected sampling interval Del to the scheduling control of the next sampling period.
[0022] In this embodiment, through steps S1 to S4, the device automatically adjusts its operating rhythm based on the load prediction value Ldp: When the device is under high pressure, the sampling adjustment coefficient Frs is suppressed due to the increase in the acquisition overhead value Coi, which in turn dynamically lengthens the sampling interval Del, thereby preventing the acquisition behavior from exacerbating congestion. When the device is idle, the processing utilization Cpuu, memory utilization Memu, and thread switching rate Ths remain at low values, and the load prediction value Ldp derived from the trend base value Tbs and the acquisition overhead value Coi is low, causing the sampling interval Del to be actively shortened. This allows for the early detection of hidden fluctuations even when the user is not operating but the background program is gradually increasing. For example, during long-term online video conferencing, the processing utilization Cpuu continuously increases due to the low interaction frequency Uih. Traditional fixed-frequency acquisition methods often cannot identify the performance degradation inflection point in time, while this method can trigger an increase in the sampling frequency early through the continuous accumulation of the trend base value Tbs.
[0023] Example 2: Please refer to Figure 1 and Figure 3 Specifically: S1 includes S11; S11. Using the resource monitoring interface or process management instructions provided by the computer operating system, call the system call function at a single sampling moment to read the proportion of computation time occupied in the current time slice in the processor scheduling module, and record the proportion of computation time as the processing utilization rate Cpuu. At the same time, the ratio of the number of allocated memory pages to the number of available memory pages is read through the memory management interface and recorded as the memory utilization rate (Memu). Processing utilization (Cpuu) and memory utilization (Memu) are stored as percentages and a uniform time-series index is attached to ensure consistent collection time. It should be noted that: Processing utilization (Cpuu) is used to reflect the busy / idle status of the processor in the current cycle of the target device. Its acquisition method is not limited to using the system's built-in monitoring instructions, but can also be measured by the application layer polling method. Memory utilization (Memu) is used to reflect the real-time level of memory resource usage of a device. When both processing utilization (Cpuu) and memory utilization (Memu) are at high values, the device is considered to be in a resource-scarce range, providing a basis for subsequent sampling frequency adjustment.
[0024] S1 further includes S12; S12. After collecting the processing utilization Cpuu and memory utilization Memu, call the thread scheduling record interface within the same collection period to obtain the number of context switches that occurred in the scheduler within that period, record it as the thread switching rate Ths, and attach a unified time sequence index. Accumulate the number of keyboard key presses and mouse clicks, record the total number of keyboard key presses and mouse clicks as the interaction frequency Uih, and attach a unified time-series index; The processing utilization Cpuu, memory utilization Memu, thread switching rate Ts, and interaction frequency Uih are written into the constructed state set Stc in the order of the collection time sequence index. It should be noted that: The thread switching rate (Ths) represents the current level of thread contention. When both the thread switching rate (Ths) and the processing utilization (Cpuu) increase, it indicates an increase in the degree of processor scheduling disorder. The interaction frequency Uih is used to reflect whether the current device is in a state of frequent operation. When the interaction frequency Uih is zero for a long time and the simultaneous processing utilization Cpuu is low, it can be inferred that the device is in an idle state.
[0025] In this embodiment, by simultaneously collecting processing utilization (Cpuu), memory utilization (Memu), thread switching rate (Ths), and interaction frequency (Uih), this method can simultaneously identify whether the device is in a "performance-intensive" or "actively operated" state within a single sampling period. This avoids the traditional sampling scheme's mistake of judging system busy solely based on processing utilization, which could lead to the misclassification of "users playing games" and "devices being overwhelmed by background programs" as the same type of load. For example, in a scenario where high-definition videos are played in full-screen mode, processing utilization (Cpuu) and memory utilization (Memu) may be high, but interaction frequency (Uih) may remain at zero for an extended period. If only processing utilization is used for sampling and adjustment, entertainment loads may be mistakenly identified as computational stress sources. However, by introducing joint judgment of thread switching rate (Ths) and interaction frequency (Uih), the state can be identified as a stable high load situation that does not require frequent intervention, reducing the risk of misjudgment from the source and improving the contextual accuracy of subsequent sampling and adjustment judgments.
[0026] Example 3: Specifically: S2 includes S21; S21. The state set Stc generated in the previous sampling period and the state set Stc recorded in several historical periods are arranged in chronological order to form a continuous sequence, and the processing utilization Cpuu, memory utilization Memu and thread switching rate Ths are extracted as the basic data for trend analysis. The processing utilization Cpuu, memory utilization Memu, and thread switching rate Ts are calculated by sliding accumulation with time decay to generate the processing trend value Cptv, memory trend value Mmtv, and switching trend value Tstv. Min-Max normalization is then used for normalization, followed by weighted averaging to generate the comprehensive trend value trend base value Tbs. The formula for calculating the trend value Cptv is as follows: ; In the formula, n represents the total number of consecutive sampling periods used for trend analysis, i represents the i-th sampling period, and Cpuu(i) represents the processing utilization of the i-th sampling period; This represents the time decay coefficient, which ranges from [0, 1]. The closer it is to 1, the more it emphasizes historical trends, and the closer it is to 0, the more it emphasizes the latest data. The formula for calculating the memory trend value Mmtv is as follows: ; In the formula, Mumu(i) represents the memory utilization rate of the i-th sampling period; The formula for calculating the trend value Tstv is as follows: ; In the formula, Ths(i) represents the thread switching rate in the i-th sampling period; The comprehensive trend value, the trend base value Tbs, is obtained through the following calculation formula: Tbs=t1×Cptv+t2×Mmtv+t3×Tstv; In the formula, t1, t2 and t3 represent the weighting coefficients of the processing trend value Cptv, the memory trend value Mmtv and the switching trend value Tstv, respectively, and t1+t2+t3=1. The specific values are set by the user. It should be noted that: The processing trend value Cptv is used to reflect the direction of fluctuation of processor resources over a continuous period; The memory trend value Mmtv is used to reflect the tendency of memory usage to increase or decrease. The switching trend value Tstv is used to reflect the degree of accumulated pressure on the scheduler. The trend base value Tbs formed by weighting the three factors serves as a comprehensive representation of the overall operating status. When both the processing trend value Cptv and the switching trend value Tstv increase simultaneously, it can be considered that the processor scheduling is about to enter a congested state. When the memory trend value Mmtv increases while the processing trend value Cptv remains stable, it can be considered as a cache-occupying load increase.
[0027] S2 further includes S22; S22. Use the generated trend base value Tbs and the acquisition overhead value Coi calculated by the acquisition thread execution time recorded in the previous acquisition cycle as prediction input parameters, and substitute them into the load mapping function for calculation. The acquisition cost value Coi is obtained through the following calculation process: In the previous acquisition cycle, the time identifier when the acquisition thread enters the acquisition logic is recorded as the start time Tst, and the time identifier when the acquisition logic finishes execution is recorded as the end time Ted. The acquisition processing time of the previous acquisition cycle is obtained by subtracting the start time Tst from the end time Ted. The acquisition processing time is then processed according to the unified dimensionless processing rules, and the dimensionless result after processing is recorded as the acquisition overhead value Coi. The load mapping function uses a multiply-accumulate model to calculate the theoretical load value by combining the trend base value Tbs and the acquisition overhead value Coi in a fixed ratio, and then compares and calibrates the theoretical load value with the processing trend value Cptv of the current sampling period. The fixed proportion of the theoretical load value is calculated as follows: Theoretical load value = k1 × Tbs + k2 × Coi; In the formula, k1 and k2 represent the fixed mapping ratio coefficients between the trend base value Tbs and the collection cost value Coi, respectively, and k1+k2=1, the specific values of which are set by the user. When the difference between the theoretical load value and the processed trend value Cptv is within the preset allowable range, the theoretical load value is used as the prediction result. When the difference between the theoretical load value and the processed trend value Cptv exceeds the preset allowable range, the average value of the theoretical load value and the processed trend value Cptv is used as the prediction result. Finally, the calibrated prediction results are compared and recorded as the load prediction value Ldp. The load prediction value Ldp is normalized using Min-Max normalization, and its value range is limited to [0, 1]. Here, 0 represents a completely idle state and 1 represents the highest load state. When the load prediction value Ldp is compared with the conditions, the dimensionless value within this normalization range is used for judgment. It should be noted that: The load prediction value Ldp is used to represent the resource consumption level that the target device may reach in the next sampling period; the acquisition overhead value Coi is used to correct the interference caused by the sampling thread itself; and the processing trend value Cptv is used to prevent the prediction value from being distorted under the sudden behavior of the processor. By combining the three to generate the load prediction value Ldp, it can be ensured that the subsequent sampling frequency adjustment mechanism has higher stability and reliability.
[0028] In this embodiment, by combining the trend baseline value Tbs with the acquisition overhead value Coi to generate the load prediction value Ldp, this method can identify the "development direction" of performance changes in advance before the sampling thread intervenes, rather than just relying on static numerical judgments at a certain moment. Since the trend baseline value Tbs can continuously accumulate historical upward trends, and the acquisition overhead value Coi reflects the interference caused by the sampling behavior itself, combining the two can avoid judgment biases such as "a brief increase in device temperature being misjudged as continuous high pressure" or "updating and downloading consuming network resources but the CPU being idle being misjudged as having no system load." For example, during the decompression of a large file, the processing utilization (Cpuu) may increase in a stepwise manner, but if the acquisition overhead value Coi remains low, it can be inferred that the load has short-cycle pulse characteristics. In this case, the load prediction value Ldp will be calibrated to the median level, thereby preventing the sampling thread from excessively reducing its frequency. Conversely, when users continuously run virtual machine compilation projects, the processing trend value Cptv and the collection cost value Coi rise simultaneously, causing the load prediction value Ldp to be steadily pushed up. This allows the sampling strategy to be switched to a conservative mode in advance, achieving a dynamic perception effect that is trend-driven rather than single-point triggered.
[0029] Example 4: Specifically: S3 includes S31; S31. Compare and judge the load prediction value Ldp with the preset sampling adjustment range, and generate different sampling adjustment marks based on the comparison and judgment results as input data for the mapping rules. The sampling adjustment range includes a high load threshold and a low load threshold. When the predicted load value Ldp is higher than the high load threshold, a low-frequency acquisition marker is generated and recorded as the sampling coefficient Lof. When the load prediction value Ldp is between the high load threshold and the low load threshold, a regular acquisition marker is generated and recorded as the sampling coefficient Nom; When the predicted load value Ldp is lower than the low load threshold, a high-frequency acquisition marker is generated and recorded as the sampling coefficient Hif. It should be noted that: The sampling coefficient Lof is used to indicate that a low-frequency monitoring mode should be entered at present. It is suitable for use when the system is under excessive pressure to avoid interference with the performance of the acquisition thread. The sampling coefficient Nom is used to indicate the sampling interval that maintains a stable performance under normal load. The sampling coefficient Hif is used to indicate increasing the sampling frequency under idle or light load conditions to capture hidden fluctuations. All three sampling coefficients mentioned above are discrete enumeration markers used to guide further mapping of the sampling interval.
[0030] S3 includes S32; S32. When the input data is the sampling coefficient Lof, the sampling coefficient Lof is converted into the sampling adjustment ratio according to the fixed low-frequency mapping rule. Specifically, the sampling adjustment coefficient Frs is generated by multiplying the low-frequency adjustment reference value by a factor of one. When the input data is the sampling coefficient Nom, the sampling adjustment coefficient Frs is generated by multiplying the intermediate frequency adjustment reference value by a factor of two. When the input data is the sampling coefficient Hif, the sampling adjustment coefficient Frs is generated by multiplying the high-frequency adjustment reference value by a factor of three. Among them, the low-frequency adjustment reference value, the medium-frequency adjustment reference value and the high-frequency adjustment reference value are all dimensionless reference values after unified dimensionless processing. Multiplier 1, multiplier 2 and multiplier 3 are all dimensionless multipliers. The sampling adjustment coefficient Frs generated by multiplying the dimensionless reference value and the dimensionless multiplier is a dimensionless parameter. Among them, multiplier one, multiplier two and multiplier three are dynamically adjusted based on the combined effect of load prediction value Ldp and interaction frequency Uih; When the load prediction value Ldp increases, the multiplier is reduced; when the interaction frequency Uih decreases, the multiplier is increased, and the sampling adjustment coefficient Frs is obtained. It should be noted that: The low-frequency, mid-frequency, and high-frequency references correspond to the upper limit, median, and lower limit of the sampling interval, respectively. The dynamic adjustment mechanism of multiplier one, multiplier two, and multiplier three is used to further widen the difference in sampling frequency resolution under different load conditions. For example, in the high-frequency sampling mode corresponding to the sampling coefficient Hif, when the interaction frequency Uih is continuously zero, multiplier three can be automatically increased to the maximum value to achieve extremely high resolution acquisition. When the load prediction value Ldp increases, multiplier three is reduced to avoid reverse interference caused by the sampling thread. The sampling adjustment coefficient Frs obtained through the above dual adjustment method has adaptive and flexible adjustment characteristics, providing a continuous calculation basis for subsequent sampling interval mapping.
[0031] In this embodiment, by establishing a tiered logic between the load prediction value Ldp and a preset threshold, this method can divide the system's operating state into three behavioral intervals: "needs to yield," "can be balanced," and "should be amplified." These intervals are explicitly marked with sampling coefficients Lof, Nom, and Hif, respectively, thus giving different load stages a clear sampling strategy identity. Compared to the traditional method of polling at fixed sampling times, this mechanism can automatically avoid the reverse intervention phenomenon of "the more monitoring, the more sluggish" in actual operation. For example, during peak periods such as video rendering or game loading, the load prediction value Ldp will rise rapidly, triggering the sampling coefficient Lof and forcibly lowering the sampling adjustment coefficient Frs to prevent the sampling thread and rendering thread from competing for computing resources. Furthermore, when a user briefly leaves the system, causing the interaction frequency Uih to remain at zero, even if the processing utilization Cpuu is at a mid-level, the sampling coefficient Hif can be triggered, and the sampling adjustment coefficient Frs can be raised to a high level to proactively capture sudden usage by background automatic synchronization programs or malicious processes.
[0032] Example 5: Specifically: S4 includes S41; S41. Based on the obtained sampling adjustment coefficient Frs, perform a reciprocal mapping process with the preset basic interval constant, calculate the delay time required for the next sampling period by dividing the basic interval constant by the sampling adjustment coefficient Frs, and record the delay time as the sampling interval Del. Among them, the sampling adjustment coefficient Frs is a dimensionless parameter, and the basic interval constant is a parameter with time dimension, so that the calculated sampling interval Del is still a parameter with time dimension.
[0033] S4 also includes S42; S42. The generated sampling interval Del is compared with the load prediction value Ldp and the interaction frequency Uih again, and a new sampling interval Del is generated based on the comparison result. The specific details of the condition comparison are as follows: When the normalized load prediction value Ldp is greater than 0.8 for three consecutive sampling periods, it is determined to be a high load continuous state, and the sampling interval Del is recalculated as three times the current duration as a new sampling interval Del; When the interaction frequency Uih is equal to zero for three consecutive sampling periods and the normalized load prediction value Ldp is less than 0.2, it is determined to be a long-term idle state, and the sampling interval Del is shortened to one-third of the current duration, and a new sampling interval Del is generated. The new sampling interval Del is directly applied to the scheduling control of the next sampling period.
[0034] In this embodiment, by mapping the sampling adjustment coefficient Frs to the reciprocal of the basic interval constant, the sampling interval Del can be flexibly adjusted according to the real-time changes in device load, thereby effectively avoiding the problem of "inappropriate sampling frequency" under different load conditions. For example, when the device's load prediction value Ldp remains high, the system automatically lengthens the sampling interval Del to prevent excessive interference of the sampling thread to system resources; conversely, when the device is idle or under low load, the system automatically shortens the sampling interval Del to more quickly capture small fluctuations in the system. This adjustment mechanism not only effectively improves sampling efficiency but also enhances sampling sensitivity without interfering with system performance, especially in scenarios that require capturing short-term changes or hiding load fluctuations. For example, when handling multiple tasks, the system continuously monitors the interaction frequency Uih to promptly determine user activity and device idle status. When the user stops operating, the sampling frequency automatically increases, and even if the device itself is under low load, it can promptly capture abnormal behavior of background processes, such as virus scanning or system updates.
[0035] Example 6: A computer performance data acquisition system, please refer to... Figure 2 Specifically, it includes a computer data acquisition module, a status trend analysis module, a calibration frequency module, and an acquisition cycle control module; In each sampling period, the computer data acquisition module collects the processing utilization Cpuu, memory utilization Memu, thread switching rate Ths, and interaction frequency Uih through the computer system resource interface, and writes them into the status set Stc according to a unified time sequence index. The state trend analysis module performs a sliding accumulation operation on the state set Stc generated in two or more consecutive sampling periods in chronological order to obtain the trend base value Tbs; The calibration frequency module records the execution time of the acquisition thread in the previous sampling period as the acquisition overhead value Coi. The trend base value Tbs and the acquisition overhead value Coi are input into the load mapping function and compared and calibrated to obtain the load prediction value Ldp. Based on the load prediction value Ldp, the sampling adjustment coefficient Frs is generated. The acquisition cycle control module calculates the sampling interval Del by performing a reciprocal mapping based on the sampling adjustment coefficient Frs, and then performs a multiple correction on the sampling interval Del based on the load prediction value Ldp. The corrected sampling interval Del is then applied to the scheduling control of the next sampling cycle.
[0036] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and variations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for acquiring computer performance data, characterized in that: Includes the following steps: S1. In each sampling period, the processing utilization Cpuu, memory utilization Memu, thread switching rate Ths, and interaction frequency Uih are collected through the computer system resource interface, and written into the state set Stc according to a unified time sequence index. S2. Perform a sliding accumulation operation on the state set Stc generated in two or more consecutive sampling periods in chronological order to obtain the trend base value Tbs; S3. Record the execution time of the acquisition thread in the previous sampling period and use it as the acquisition overhead value Coi after uniform dimensionless processing. Input the trend base value Tbs and the acquisition overhead value Coi into the load mapping function and compare and calibrate to obtain the normalized load prediction value Ldp. Based on the load prediction value Ldp and the interaction frequency Uih, generate the sampling adjustment coefficient Frs after uniform dimensionless processing. When the load prediction value Ldp increases, the multiplier corresponding to the sampling adjustment coefficient Frs is decreased. When the interaction frequency Uih decreases, the multiplier corresponding to the sampling adjustment coefficient Frs is increased. S4. Calculate the sampling interval Del using the reciprocal mapping of the dimensionless sampling adjustment coefficient Frs. Then, perform a multiple correction on the sampling interval Del based on the normalized load prediction value Ldp and the interaction frequency Uih. When the load prediction value Ldp is greater than 0.8 for three consecutive sampling periods, it is determined to be a high-load continuous state, and the sampling interval Del is recalculated as three times the current duration. When the interaction frequency Uih is equal to zero for three consecutive sampling periods and the load prediction value Ldp is less than 0.2, it is determined to be a long-term idle state, and the sampling interval Del is shortened to one-third of the current duration, generating a new sampling interval Del. The new sampling interval Del is then applied to the scheduling control of the next sampling period.
2. The computer performance data acquisition method according to claim 1, characterized in that: S1 includes S11; S11. Using the resource monitoring interface or process management instructions provided by the computer operating system, call the system call function at a single sampling moment to read the proportion of computation time occupied in the current time slice in the processor scheduling module, and record the proportion of computation time as the processing utilization rate Cpuu. At the same time, the ratio of the number of allocated memory pages to the number of available memory pages is read through the memory management interface and recorded as the memory utilization rate (Memu). Processing utilization (Cpuu) and memory utilization (Memu) are stored as percentages and appended with a uniform time-series index.
3. The computer performance data acquisition method according to claim 2, characterized in that: S1 further includes S12; S12. After collecting the processing utilization Cpuu and memory utilization Memu, call the thread scheduling record interface within the same collection period to obtain the number of context switches that occurred in the scheduler within that period, record it as the thread switching rate Ths, and attach a unified time sequence index. Accumulate the number of keyboard key presses and mouse clicks, record the total number of keyboard key presses and mouse clicks as the interaction frequency Uih, and attach a unified time-series index; The processing utilization Cpuu, memory utilization Memu, thread switching rate Ts, and interaction frequency Uih are written into the constructed state set Stc in the order of the collection time sequence index.
4. The computer performance data acquisition method according to claim 3, characterized in that: S2 includes S21; S21. The state set Stc generated in the previous sampling period and the state set Stc recorded in several historical periods are arranged in chronological order to form a continuous sequence, and the processing utilization Cpuu, memory utilization Memu and thread switching rate Ths are extracted as the basic data for trend analysis. The processing utilization Cpuu, memory utilization Memu, and thread switching rate Ts are calculated by sliding accumulation with time decay to generate the processing trend value Cptv, memory trend value Mmtv, and switching trend value Tstv. Min-Max normalization is then used for normalization, followed by weighted averaging to generate the comprehensive trend value trend base value Tbs. The comprehensive trend value, the trend base value Tbs, is obtained through the following calculation formula: Tbs=t1×Cptv+t2×Mmtv+t3×Tstv; In the formula, t1, t2 and t3 represent the weighting coefficients of the processing trend value Cptv, the memory trend value Mmtv and the switching trend value Tstv, respectively, and t1+t2+t3=1. The specific values are set by the user.
5. The computer performance data acquisition method according to claim 4, characterized in that: S2 further includes S22; S22. Use the generated trend base value Tbs and the acquisition overhead value Coi calculated by the acquisition thread execution time recorded in the previous acquisition cycle as prediction input parameters, and substitute them into the load mapping function for calculation. The acquisition cost value Coi is obtained through the following calculation process: In the previous acquisition cycle, the time identifier when the acquisition thread enters the acquisition logic is recorded as the start time Tst, and the time identifier when the acquisition logic finishes execution is recorded as the end time Ted. The acquisition processing time of the previous acquisition cycle is obtained by subtracting the start time Tst from the end time Ted, and the acquisition processing time is directly recorded as the acquisition overhead value Coi. The load mapping function uses a multiply-accumulate model to calculate the theoretical load value by combining the trend base value Tbs and the acquisition overhead value Coi in a fixed ratio, and then compares and calibrates the theoretical load value with the processing trend value Cptv of the current sampling period. When the difference between the theoretical load value and the processed trend value Cptv is within the preset allowable range, the theoretical load value is used as the prediction result. When the difference between the theoretical load value and the processed trend value Cptv exceeds the preset allowable range, the average value of the theoretical load value and the processed trend value Cptv is used as the prediction result. Finally, the calibrated prediction results are compared and recorded as the load prediction value Ldp. The load prediction value Ldp is synchronously normalized using Min-Max normalization, and the value range is limited to [0, 1], where 0 represents a completely idle state and 1 represents the highest load state.
6. The computer performance data acquisition method according to claim 5, characterized in that: S3 includes S31; S31. Compare and judge the load prediction value Ldp with the preset sampling adjustment range, and generate different sampling adjustment marks based on the comparison and judgment results as input data for the mapping rules; The sampling adjustment range includes a high load threshold and a low load threshold. When the predicted load value Ldp is higher than the high load threshold, a low-frequency acquisition marker is generated and recorded as the sampling coefficient Lof; When the load prediction value Ldp is between the high load threshold and the low load threshold, a regular acquisition marker is generated and recorded as the sampling coefficient Nom; When the load prediction value Ldp is lower than the low load threshold, a high-frequency acquisition marker is generated and recorded as the sampling coefficient Hif; Sampling adjustment ratio, low-frequency adjustment reference value, sampling adjustment coefficient Frs, mid-frequency adjustment reference value, sampling adjustment coefficient Frs, high-frequency adjustment reference value, sampling adjustment coefficient Frs, sampling adjustment coefficient Frs.
7. A computer performance data acquisition method according to claim 6, characterized in that: S4 includes S41; S41. Based on the acquired sampling adjustment coefficient Frs, perform inverse mapping processing with the preset basic interval constant, calculate the delay time required for the next sampling period by dividing the basic interval constant by the sampling adjustment coefficient Frs, and record the delay time as the sampling interval Del.
8. A computer performance data acquisition system, applied to the computer performance data acquisition method according to any one of claims 1 to 7, characterized in that: It includes a computer data acquisition module, a status trend analysis module, a calibration frequency module, and an acquisition cycle control module; In each sampling period, the computer data acquisition module collects the processing utilization Cpuu, memory utilization Memu, thread switching rate Ths, and interaction frequency Uih through the computer system resource interface, and writes them into the status set Stc according to a unified time sequence index. The state trend analysis module performs a sliding accumulation operation on the state set Stc generated in two or more consecutive sampling periods in chronological order to obtain the trend base value Tbs; The calibration frequency module records the execution time of the acquisition thread in the previous sampling period as the acquisition overhead value Coi. The trend base value Tbs and the acquisition overhead value Coi are input into the load mapping function and compared and calibrated to obtain the load prediction value Ldp. Based on the load prediction value Ldp, the sampling adjustment coefficient Frs is generated. The acquisition cycle control module calculates the sampling interval Del by performing a reciprocal mapping based on the sampling adjustment coefficient Frs, and then performs a multiple correction on the sampling interval Del based on the load prediction value Ldp. The corrected sampling interval Del is then applied to the scheduling control of the next sampling cycle.