Power consumption statistical method and device, electronic equipment and readable storage medium

By setting up power detection devices in electronic devices and combining the power set of the working time and the target operating scenario, the power consumption of devices and processes is calculated, which solves the reliability problem of existing power consumption statistics methods, realizes more accurate power consumption statistics and anomaly detection, and improves the battery life of the devices.

CN115033458BActive Publication Date: 2026-03-17VIVO MOBILE COMM CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-28
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing power consumption statistics methods have low reliability in terms of device and process power consumption statistics and cannot accurately reflect the actual power consumption of electronic devices.

Method used

By setting a first power detection device in the electronic device to detect the power value of the device, and combining the working time of the process at each frequency point with the power set of the target running scenario, the power consumption of the device and the process can be calculated to achieve accurate power consumption statistics.

Benefits of technology

It improves the reliability of power consumption statistics for devices and processes, provides more accurate power consumption reminders and abnormal power consumption detection for users, and enhances the battery life of electronic devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115033458B_ABST
    Figure CN115033458B_ABST
Patent Text Reader

Abstract

This application provides a power consumption statistics method, apparatus, electronic device, and readable storage medium, belonging to the field of computer technology. The electronic device includes: a first device, and a first power detection device electrically connected to the first device; the method includes: obtaining a first power consumption of the first device within a first time period based on a first power value detected by the first power detection device within the first time period; obtaining a first set of working durations corresponding to M processes of the first device, resulting in M ​​sets of first working durations; obtaining a second power consumption corresponding to the M processes of the first device within the first time period based on the M sets of first working durations and a power set corresponding to a target operating scenario of the first device, resulting in M ​​sets of second power consumptions; and storing the first time period, the first power consumption, and the M sets of second power consumptions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a power consumption statistics method, apparatus, electronic device, and readable storage medium. Background Technology

[0002] In the field of computer technology, battery life has always been one of the most important metrics for users of electronic devices. To improve the battery life of electronic devices, it is particularly important to track the power consumption of the components within them. By tracking component power consumption, it is possible to provide users with power consumption alerts and detect abnormal power usage, thereby improving the overall power efficiency of electronic devices. However, existing power consumption tracking methods have relatively low reliability. Summary of the Invention

[0003] This application provides a power consumption statistics method, apparatus, electronic device, and readable storage medium, which can solve the problem of low reliability of existing power consumption statistics methods.

[0004] In a first aspect, embodiments of this application provide a power consumption statistics method applied to an electronic device, the electronic device comprising: a first device, and a first power detection device electrically connected to the first device, wherein the first power detection device is used to detect the power of the first device;

[0005] The method includes:

[0006] Based on the first power value detected by the first power detection device within the first time period, the first power consumption of the first device within the first time period is obtained;

[0007] Obtain the first working duration set corresponding to each of the M processes of the first device to obtain M first working duration sets, wherein the first working duration set corresponding to the first process includes: the working duration of the first process of the first device at each frequency point within the first duration, the first process is any one of the M processes, and M is a positive integer;

[0008] Based on the M first working duration sets and the power set corresponding to the target operating scenario, the second power consumption corresponding to the M processes of the first device within the first duration is obtained, resulting in M ​​second power consumptions. The power set corresponding to the target operating scenario includes: the power value of the first device operating at each frequency point when the electronic device is in the target operating scenario.

[0009] Save the first duration, the first power consumption, and the M second power consumptions.

[0010] Secondly, this application also provides a power consumption statistics device for use in electronic devices. The electronic devices include: a first device and a first power detection device electrically connected to the first device, wherein the first power detection device is used to detect the power of the first device.

[0011] The device includes:

[0012] The first acquisition module is used to acquire the first power consumption of the first device within the first time period based on the first power value detected by the first power detection device within the first time period;

[0013] The second acquisition module is used to acquire the first working duration set corresponding to the M processes of the first device respectively, to obtain M first working duration sets, wherein the first working duration set corresponding to the first process includes: the working duration of the first process of the first device at each frequency point within the first duration, the first process is any one of the M processes, and M is a positive integer;

[0014] The third acquisition module is used to acquire the second power consumption corresponding to the M processes of the first device within the first duration based on the M first working duration sets and the power set corresponding to the target operating scenario, and obtain M second power consumptions. The power set corresponding to the target operating scenario includes: the power value of the first device at each frequency point when the electronic device is in the target operating scenario.

[0015] The first storage module is used to store the first duration, the first power consumption, and the M second power consumptions.

[0016] Thirdly, embodiments of this application also provide an electronic device, which includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the power consumption statistics method as described in the first aspect.

[0017] Fourthly, embodiments of this application also provide a readable storage medium storing a program or instructions that, when executed by a processor, implement the power consumption statistics method as described in the first aspect.

[0018] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the method as described in the first aspect.

[0019] In a sixth aspect, embodiments of this application provide a computer program product stored in a storage medium, which is executed by at least one processor to implement the method described in the first aspect.

[0020] In this embodiment, on the one hand, the device power consumption of the first device can be detected by a first power detection device; on the other hand, the power consumption of each process of the first device can be calculated by obtaining the working time of each process within the first device at each frequency point, and the power value of the first device at each frequency point when the electronic device is in the target operating scenario, thereby obtaining the total process power consumption of the first device. In this way, by obtaining the device power consumption and process power consumption of the first device separately, the reliability of the power consumption statistics of the first device can be improved. Attached Figure Description

[0021] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 This is a schematic diagram of the first power detection device provided in an embodiment of this application;

[0023] Figure 2 This is one of the flowcharts of the power consumption statistics method provided in the embodiments of this application;

[0024] Figure 3 This is one of the schematic diagrams of the power consumption statistics module provided in the embodiments of this application;

[0025] Figure 4 This is the second flowchart of the power consumption statistics method provided in the embodiments of this application;

[0026] Figure 5 This is one of the flowcharts for process power consumption statistics provided in the embodiments of this application;

[0027] Figure 6 This is a power consumption diagram of the operating scenario provided in the embodiments of this application;

[0028] Figure 7 This is the second schematic diagram of the power consumption statistics module provided in the embodiments of this application;

[0029] Figure 8 This is the second flowchart of process power consumption statistics provided in the embodiments of this application;

[0030] Figure 9 This is a structural diagram of the power consumption statistics device provided in the embodiments of this application;

[0031] Figure 10 This is one of the structural diagrams of the electronic device provided in the embodiments of this application;

[0032] Figure 11 This is the second structural diagram of the electronic device provided in the embodiments of this application. Detailed Implementation

[0033] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0034] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0035] For ease of understanding, the following describes some aspects of the embodiments of this application:

[0036] To improve the battery life of electronic devices, efforts can be made from two dimensions. First, by using technology to inform users of the actual power consumption characteristics, users can clearly understand where their power is being used, thus alleviating their doubts about the phone's battery life. In this regard, various electronic device manufacturers have launched power consumption ranking functions, which not only display the power consumption details of each component but also break it down to the application level. In this context, providing users with more accurate power consumption measurements for components and applications is particularly important. Second, by using technology to detect abnormal power consumption behavior of users, this technology can either run in the background or notify users through anomaly alerts. Background abnormal power consumption detection can include two processing methods: one is to report "suspicious anomalies" from the user's side to the cloud, where they are uniformly classified and sorted, and then handled by technical developers; the other is to handle "deterministic anomalies" from the user's side on the device side, such as handling anomalies of unimportant processes in the background.

[0037] The above analysis reveals that edge power consumption statistics are a crucial technology. The accuracy of this technology is vital for both user power consumption alerts and abnormal power consumption detection. More accurate power consumption alerts can avoid misleading users, while more precise abnormal power consumption detection can effectively improve battery life.

[0038] In related technologies, device power consumption can be measured by adding a power meter composed of an analog-to-digital converter (ADC) to the device's power supply front end. This method can accurately measure device power consumption, with a precision consistent with the ADC itself. However, this method cannot accurately measure process power consumption details. Therefore, it cannot be used for process power consumption ranking or process anomaly detection.

[0039] Another type of statistical strategy uses load to track process power consumption and then accumulates the power consumption over a period of time to obtain the device's power consumption. This method assumes that power consumption is the same under the same load. This assumption is approximate and incomplete. In different test scenarios, the power consumption of a device under full load varies significantly. For example, under the same full load conditions, the power consumption of running integer operations is different from that of running floating-point operations. Furthermore, under the same full load conditions and the power consumption of running integer operations, the power consumption of running instructions already in the cache is different from that of running instructions that need to be fetched from memory. Therefore, using load to track device process power consumption introduces errors, and the device power consumption obtained by accumulating process power consumption also contains errors.

[0040] Therefore, this application provides a new power consumption statistics method that can simultaneously realize the statistics of device power consumption and process power consumption, thereby improving the reliability of power consumption statistics.

[0041] The power consumption statistics method of this application embodiment can be applied to electronic devices, or executed by electronic devices. The electronic device includes: a first device, and a first power detection device electrically connected to the first device, wherein the first power detection device is used to detect the power of the first device. The power consumption statistics method of this application embodiment can be used to count the power consumption of the first device.

[0042] In this embodiment, the first device can be a device related to the operation of a process in an electronic device, that is, a device that the process calls upon during operation. It is worth noting that when calculating the power consumption of a device, one implementation can calculate the power consumption of the device as a whole; another implementation, considering that different units within the device operate under different conditions, can calculate the power consumption of different units separately, and then calculate the overall power consumption of the device. Therefore, in practical applications, the first device can be the entirety or a unit of the following devices: a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a Digital Signal Processor (DSP), or a microcontroller, etc.

[0043] For ease of understanding, taking a CPU as an example, considering the multi-core nature of CPUs, the first device can be: a single CPU, a single CPU cluster, a single CPU core, or a custom CPU unit. A CPU cluster refers to a group of identical CPU cores; for example, the typical classification method is small cores, medium cores, and large cores. A custom CPU unit can be determined based on the CPU's power supply structure. For example, assuming the CPU's power supply scheme adopts a small core plus medium core strategy, then the small core plus the medium core can be defined as a CPU unit.

[0044] In the embodiments of this application, each first device is provided with an independent power detection device, which is dedicated to detecting the power consumption of the device.

[0045] In a specific implementation, in one approach, the first power detection device can be directly used to detect the power value of the first device. In this approach, the first power detection device is connected in parallel with the first device.

[0046] In another implementation, the first power detection device may include a galvanometer and a calculation unit. The galvanometer detects the current of the first device, and the calculation unit calculates the power value of the first device based on the current detected by the galvanometer and the voltage read. The galvanometer includes a first element and a second element connected in parallel. The first element can be a resistor or a transistor, and the second element is used to detect the current of the first device. The second element can be an ADC or other custom-defined element. The ADC can be a newly added ADC or an ADC built into the power supply system of the first device. In this implementation, the first power detection device can be located at the front end or the rear end of the first device. For ease of understanding, see [link to relevant documentation]. Figure 1 .exist Figure 1 In this configuration, the first power detection device includes a resistor and an ADC connected in parallel. The first device is a CPU cluster, and the first power detection device is positioned before the CPU cluster.

[0047] It should be noted that the first power detection device can be packaged outside or inside the first device, depending on the actual situation. This application does not limit this.

[0048] In practical applications, electronic devices can be mobile phones, tablet computers, laptop computers (also known as notebook computers), personal digital assistants (PDAs), handheld computers, netbooks, ultra-mobile personal computers (UMPCs), mobile internet devices (MIDs), augmented reality (AR) / virtual reality (VR) devices, robots, wearable devices, vehicle-mounted devices (VUEs), pedestrian terminals (PUEs), and smart home devices (home appliances with wireless communication capabilities, such as refrigerators, televisions, washing machines, or furniture).

[0049] The power consumption statistics method provided in this application will be described in detail below with reference to the accompanying drawings, through some embodiments and application scenarios.

[0050] See Figure 2 , Figure 2 This is one of the flowcharts for the power consumption statistics method provided in the embodiments of this application. For example... Figure 2 As shown, the power consumption statistics method may include the following steps:

[0051] Step 201: Based on the first power value detected by the first power detection device within the first time period, obtain the first power consumption of the first device within the first time period.

[0052] In this embodiment, the electronic device can periodically count the power consumption of a first device, where the first duration is equal to the period length of the periodic count of the first device. In some embodiments, to achieve periodic counts, the electronic device can set a timer. The electronic device can perform a count once when the timer expires. Thus, the periodic count of the power consumption of the first device can be achieved by periodically controlling the start of the timer. The period of the timer can be set according to actual needs, and this embodiment does not limit it.

[0053] It is understandable that the product of the first power value and the first duration is the first power consumption. Since the first power consumption is detected by a power detection device, it can be referred to as the device power consumption of the first device.

[0054] Step 202: Obtain the first working duration set corresponding to each of the M processes of the first device, and obtain M first working duration sets. The first working duration set corresponding to the first process includes: the working duration of the first process of the first device at each frequency point within the first duration. The first process is any one of the M processes, and M is a positive integer.

[0055] The M processes are the processes running on the first device within the first time period. Each process corresponds to a first set of working time periods, including the working time of the process at each frequency point. Furthermore, the working time is the non-idle state working time.

[0056] Step 203: Based on the M first working duration sets and the power set corresponding to the target operating scenario, obtain the second power consumption corresponding to the M processes of the first device within the first duration, and obtain the M second power consumptions.

[0057] The target operating scenario can be any operating scenario of the first device, or the operating scenario in which the first device operates at the highest frequency. This application embodiment does not limit the method of determining the target operating scenario.

[0058] The power set corresponding to the target operating scenario can be obtained in advance, such as through laboratory testing. The power set corresponding to the target operating scenario includes: the power values ​​of the first device operating at each frequency point when the electronic device is in the target operating scenario. Further, this power value is the power value of the first device at each frequency point after operating at full load. It is worth noting that if the first device cannot operate at full load in the target operating scenario, the power value after operating at full load can be calculated based on the current load power value and the current load relative to full load.

[0059] For each process, we can first calculate the power consumption of the process at each frequency point, and then sum the power consumption at each frequency point to obtain the power consumption of the process. The power consumption at each frequency point can be obtained by multiplying the power value at each frequency point by the operating time.

[0060] Assume that the operating time of each process within the first device at frequency point f is u. pro (f), the power value of the first device at frequency point f is p m-opt (f), then, the power consumption E corresponding to each process within the first device pro It can be calculated using the following formula:

[0061]

[0062] Since the second power consumption is the power consumption of each process of the first device, the M second power consumptions can be referred to as the process power consumption of the first device.

[0063] Step 204: Save the first duration, the first power consumption, and the M second power consumptions.

[0064] In one implementation, the electronic device can directly save the first duration, the first power consumption, and the M second power consumption data for use, such as for power consumption ranking or power consumption anomaly detection.

[0065] In another implementation, before saving the power consumption, the electronic device can first detect whether the first power consumption is equal to the sum of the M second power consumptions, so that the power consumption of the first device saved is consistent with the power consumption of the process, thereby ensuring the reliability of the power consumption statistics.

[0066] The power consumption statistics method of this embodiment can, on the one hand, detect the power consumption of the first device through a first power detection device; on the other hand, it can calculate the power consumption of each process of the first device by obtaining the working time of each process within the first device at each frequency point, and the power value of the first device operating at each frequency point when the electronic device is in the target operating scenario, and thus obtain the total process power consumption of the first device. In this way, by obtaining the device power consumption and process power consumption of the first device separately, the reliability of the power consumption statistics of the first device can be improved.

[0067] In some embodiments, before obtaining the second power consumption corresponding to the M processes of the first device within the first duration based on the M first operating duration sets and the power set corresponding to the target operating scenario, the method further includes:

[0068] Obtain the second set of operating durations corresponding to the first device, the second set of operating durations including: the operating duration of the first device at each frequency point within the first duration;

[0069] Obtain the power sets corresponding to the N operating scenarios of the first device, where N is an integer greater than 1;

[0070] Based on the first set of working durations and the power sets corresponding to the N operating scenarios, the third power consumption corresponding to the N operating scenarios of the first device within the first duration is obtained, and N third power consumptions are obtained.

[0071] Based on the N third power consumptions, the target operating scenario is determined from the N operating scenarios.

[0072] In this embodiment, the electronic device can count the operating time of the first device at each frequency point. Thus, based on the operating time of the first device at each frequency point and the power value of the first device operating at each frequency point when the electronic device is in each operating scenario, the process power consumption of the first device in each operating scenario can be calculated.

[0073] Subsequently, based on the process power consumption of the first device in each operating scenario within the first duration, one operating scenario can be selected from the N operating scenarios as the target operating scenario for calculating the process power consumption of the first device within the first duration.

[0074] This can improve the statistical reliability of the power consumption of the first process.

[0075] In one optional implementation, the electronic device can determine the operating scenario corresponding to the third power consumption that is the largest, smallest, or closest to the average of the N third power consumptions as the target operating scenario.

[0076] In another optional implementation, determining the target operating scenario from the N operating scenarios based on the N third power consumption scenarios may include:

[0077] Calculate the differences between the N third power consumption values ​​and the first power consumption values ​​respectively to obtain N differences;

[0078] The running scenario corresponding to the smallest absolute value among the N differences is determined as the target running scenario.

[0079] In this optional embodiment, the target operating scenario is determined by comparing the magnitudes of each of the third power consumptions with the first power consumption. Specifically, the operating scenario corresponding to the third power consumption that is closest to the first power consumption is determined as the target operating scenario.

[0080] The third power consumption corresponding to the target operating scenario is closest to the first power consumption, indicating that the target operating scenario is closest to the actual power consumption scenario of the first device. Therefore, the process power consumption of the first device within the first time period calculated based on the power set corresponding to the target operating scenario of the first device can be closer to the process power consumption of the first device within the first time period, thereby further improving the statistical reliability of process power consumption.

[0081] It should be noted that for different durations, the target operating scenario determined by the electronic device may also differ due to the different operating conditions of the electronic device, and the specific decision should be made based on the actual situation.

[0082] In some embodiments, saving the first duration, the first power consumption, and the M second power consumptions may include:

[0083] Determine whether the target power consumption is equal to the first power consumption, wherein the target power consumption is the sum of the second power consumption corresponding to the M processes respectively;

[0084] If the target power consumption is equal to the first power consumption, save the first duration, the first power consumption, and the M second power consumptions.

[0085] In this embodiment, before saving the statistically obtained power consumption, it can be checked whether the statistically obtained process power consumption is equal to the device power consumption. If they are equal, the statistically obtained power consumption can be saved directly; if they are not equal, the process power consumption can be corrected to make the process power consumption consistent with the device power consumption, thereby improving the reliability of power consumption statistics.

[0086] In an optional implementation, after determining whether the target power consumption is equal to the first power consumption, the method further includes:

[0087] If the target power consumption is not equal to the first power consumption, a correction coefficient corresponding to the second power consumption is obtained, wherein the correction coefficient is the ratio of the first power consumption to the target power consumption;

[0088] The M second power consumptions are corrected using the correction coefficient.

[0089] Save the first duration, the first power consumption, and the corrected M second power consumptions.

[0090] In practice, the product of the second power consumption and the correction coefficient can be determined as the corrected second power consumption. This ensures that the sum of the M corrected second power consumptions is equal to the first power consumption, thereby improving the reliability of power consumption statistics.

[0091] It should be noted that the various optional implementation methods described in the embodiments of this application can be combined with each other or implemented individually without conflict, and the embodiments of this application do not limit this.

[0092] For ease of understanding, the following example is provided:

[0093] The following example illustrates the power consumption of the CPU.

[0094] The embodiments of this application can be used to statistically analyze the power consumption of CPU devices and CPU processes. Ultimately, it can achieve ultra-high precision in CPU device power consumption statistics and also enable the selection of optimal CPU process power consumption strategies.

[0095] This application embodiment can provide a hardware device for statistically analyzing CPU device power consumption, specifically the power consumption of the CPU across different clusters or cores. This application embodiment can also provide a method for calculating CPU process power consumption. This method first collects detailed CPU usage data, then derives CPU power consumption under multiple models, and further selects the optimal model to statistically analyze CPU power consumption. This application embodiment can also provide a strategy that can reallocate CPU process power consumption based on CPU device power consumption.

[0096] Note that the multi-core feature of CPUs has become mainstream in electronic devices. This application's embodiments can statistically analyze CPU power consumption information at the level of CPU clusters (small cores, medium cores, large cores), CPU cores, or even a free combination of CPU clusters / cores. The corresponding implementation methods are described based on different statistical strategies.

[0097] Implementation Method 1

[0098] This implementation focuses on power consumption statistics for devices and processes within a single CPU cluster. A CPU cluster (CL) refers to a group of identical CPU cores; for example, the typical classification is small cores, medium cores, and large cores. This implementation chooses cluster-based statistics primarily because the current power supply architecture allocates power according to clusters, facilitating the addition of a power detection module. A schematic diagram of the module in this implementation can be found in [reference needed]. Figure 3 .exist Figure 3 In this system, the CPU's internal computing resources include a single cluster, and a power detection module is connected to the periphery of the CPU cluster. The power detection module can detect its power consumption. The power detection module can be packaged outside or inside the CPU. The calculation results of the power detection module and the CPU energy calculation module, which is used by the algorithm unit to monitor the overall power consumption of the CPU, jointly output a power consumption data analysis unit.

[0099] Phase 1: A power detection module (i.e., the aforementioned power detection device) can be added before the CPU cluster to measure power consumption. For example... Figure 1 As shown, one feasible approach is to insert a resistor in series in the CPU power supply circuit and add an ADC (Anti-Digital Converter) across the resistor to collect power consumption information. This ammeter can be a separately selected ammeter, a built-in ammeter in the power management chip (PMIC) power supply system, or other user-defined hardware devices. Note that the accuracy of the power detection module represents the accuracy of CPU device power consumption statistics and will also affect the accuracy of power consumption statistics for each CPU process. Furthermore, the use of an ADC chip in the accompanying drawings of this application does not imply limitation on this selection. Other hardware devices capable of measuring CPU device power consumption can also be used.

[0100] Phase Two: Prepare energy efficiency data for the CPU cluster under any typical scenario in the laboratory. The scenario chosen in this phase can be a typical benchmark test model or a key scenario of interest to manufacturers. Examples of benchmarks include classic models such as Dhrystone, Geekbench, and Spec Int; examples of key scenarios include typical scenarios such as gaming, video, and social media. Benchmark: Specifically refers to a CPU laboratory benchmark testing platform; Dhrystone: One of the most common benchmark programs for measuring processor computing power, often used to measure the integer operation performance of processors; Geekbench: A comprehensive testing tool compatible with multiple platforms, primarily used to examine the computing power of the CPU and memory system; Spec Int: A computer standard test specification for CPU integer processing capabilities, maintained by a standard performance evaluation company.

[0101] The energy efficiency data to be output in this stage refers to the power consumption of the CPU cluster at different frequencies under full load. After completing the above steps, the power consumption data table to be output in this stage is as follows:

[0102] P = {p m (f)}

[0103] Where p represents full-load power consumption, m represents different test models (i.e. test scenarios), and f represents different frequency points.

[0104] Phase 3: Perform CPU device and process power consumption statistics on the client side. This phase can be implemented through software code, allowing the corresponding algorithm module to run on the client side. This algorithm unit mainly includes the following logic modules: a timer module; a CPU usage information module; a CPU energy calculation module; and a module for writing calculation results to disk. Figure 4 As shown, the main execution steps of this algorithm are described below:

[0105] Step 1: Initialization Phase. This phase begins by initializing the hardware power detection module and setting the correct configuration parameters. Next, the directory and files storing CPU power consumption information are initialized. Note that this file system can be text, database, or other formats. Here, a database format is used as an example. Afterward, the periodic timer module is started. The period of this timer is set by the developers as needed; for example, a feasible approach is to set a timer with a 10-minute period.

[0106] Step two: The terminal device processes data after the timer expires. This mainly includes CPU device power consumption statistics, CPU process usage statistics, and CPU process power consumption calculations. (Combined with...) Figure 5 The following program illustrates the power consumption statistics process for devices and processes within a CPU cluster.

[0107] Program 1 uses software code to read the device power consumption E as calculated by the power detection module. com .

[0108] Program 2 uses software code to obtain the usage details u(f) of the CPU cluster in the kernel at various frequencies. It also obtains the usage details u of each process within the CPU cluster at different frequencies. pro (f) refers to the usage time of process pro at frequency point f (i.e., the aforementioned working time). Note that the usage details here refer to working time excluding idle time.

[0109] Program 3 derives the power consumption of the CPU under different power consumption models.

[0110]

[0111] Step 4: Obtain the optimal data model. Among all m models, select the minimum (E) model. com -E m The optimal model m-opt corresponds to this. The optimal model and its parameters are selected in this way during each iteration cycle.

[0112] Program 5 calculates the power consumption of each CPU process based on the optimal model obtained in the previous step.

[0113]

[0114] Using the methods described above, the device power consumption E of the CPU cluster can ultimately be obtained. com Power consumption E of the process pro .

[0115] Program 2 can be made by Figure 3 The CPU in the program uses the information module to execute the program; programs 3-5 can be executed by... Figure 3 The CPU energy calculation module in the system is executed.

[0116] Step three: The disk storage module is responsible for storing the current CPU device power consumption and CPU process power consumption in the corresponding database file in the directory. This method facilitates data retrieval by external interfaces, such as power consumption ranking modules and power consumption anomaly detection modules.

[0117] The beneficial effects of Implementation Method 1:

[0118] This embodiment provides a hardware device that can statistically analyze the power consumption of CPU devices. The advantage of this approach is that the obtained CPU device power consumption data is consistent with the accuracy of the acquisition device. Taking ADC devices as an example, the accuracy of existing ADC devices can be improved to over 98% while meeting cost requirements.

[0119] This embodiment provides a software method for calculating CPU process power consumption. This method selects the optimal model from multiple models based on the power consumption calculated by the software model most closely approximating hardware device statistics. By using this method to select the optimal model, the final process power consumption allocation ratio is the most reasonable. Figure 6 As shown, this implementation method can select the solution that is closest to the software power consumption statistics and hardware statistics in each cycle (marked in black in the figure). This method greatly improves the accuracy of software power consumption statistics and obtains a local optimum solution in each small cycle.

[0120] Implementation Method 2

[0121] This implementation primarily focuses on power consumption statistics for CPUs with multiple clusters, including device and process power consumption statistics. Considering that the CPU cluster is the basic unit for device power supply, this implementation requires adding a power detection module to the front end of each cluster. This embodiment is not limited to a single unit of the CPU cluster; it can also be implemented in a combined unit of CPU clusters. It should be noted that the CPU cluster is pre-set by the manufacturer or its size can be adjusted in real time according to actual needs, and multiple sub-clusters together form the parent cluster that determines the CPU's computing power. A schematic diagram of the module in this implementation can be found here. Figure 7 .exist Figure 7 In this system, the CPU's internal computing resources comprise several clusters. These CPU clusters are pre-set by the manufacturer or can be adjusted in real-time according to actual needs. Multiple sub-clusters together form a parent cluster that determines the CPU's computing power. Several power detection modules are connected in parallel around the parent CPU cluster. These power detection modules can match and detect the power consumption of one or more sub-clusters.

[0122] In Phase 1, this embodiment requires adding a power detection module to the front end of the CPU cluster to count power consumption values. The specific method of adding the module is the same as in "Implementation Method 1".

[0123] Phase Two involves preparing energy efficiency data for the CPU cluster under different typical scenarios in the laboratory. The specific scenarios selected are the same as in "Implementation Method One". The output set of power consumption values ​​for the CPU cluster in this phase is as follows:

[0124] P = {p m (c,f)}

[0125] Here, 'c' represents different clusters.

[0126] Phase three involves performing CPU device and process power consumption statistics on the client side. This phase is implemented through software code and requires the corresponding algorithm module to run on the client side. The main logic module of this algorithm unit is the same as that in "Implementation Method One", such as... Figure 4 As shown, the main execution steps of this algorithm are described below:

[0127] Step 1: Initialization phase.

[0128] Step two: The terminal device processes data after the timer expires. (Combined with...) Figure 5 The diagram below illustrates the power consumption statistics process for devices and processes within a CPU cluster.

[0129] Program 1 uses software code to read the device power consumption E of the CPU cluster from the hardware statistics of the power detection module. com (c)

[0130] Program 2 uses software code to obtain usage details of different CPU clusters in the kernel at various frequencies. This usage detail can be represented as u(c,f). It also obtains the usage details u of CPU processes at various clusters and frequencies. pro (c,f).

[0131] Program 3 derives the power consumption of CPU clusters under different power consumption models.

[0132]

[0133] Step 4: Obtain the optimal data model. From all m models, select... The corresponding optimal model is m-opt. The optimal model parameters are selected in this way during each iteration cycle.

[0134] Program 5 calculates the power consumption of each process within the CPU cluster:

[0135]

[0136] Using the above method, the power consumption of this process under cluster c can be calculated. The total power consumption of this process can then be expressed as:

[0137]

[0138] Using the methods described above, the CPU's device power consumption E can ultimately be obtained. com (c) CPU process power consumption E pro .

[0139] Step 3: The disk write module is responsible for writing the calculation results to disk at the current moment, including the power consumption of the CPU device and the CPU process consumption.

[0140] The beneficial effects of implementation method two:

[0141] This implementation can statistically analyze the specific power consumption information of CPUs with multiple clusters. It can analyze power consumption at both the CPU device and process levels. Similar to "Implementation Method 1," this implementation provides very high accuracy in analyzing device power consumption. This implementation can also analyze the power consumption of each process within a CPU cluster. During each execution round, a locally optimal model is selected on the endpoint to ensure that the sum of the statistically analyzed process power consumption is closest to the device power consumption.

[0142] Implementation Method 3:

[0143] This implementation primarily addresses the discrepancy between the statistically analyzed CPU device power consumption and the process power consumption. This is achieved by adding a "correction algorithm" to the statistical program. The theoretical basis for this is that hardware statistical analysis is far more accurate than software statistical analysis. Therefore, this implementation corrects the process power consumption using device values ​​in the final step of the statistical program. A schematic diagram of this implementation can be found in [link to schematic diagram]. Figure 7 .

[0144] For Phase 1 and Phase 2, please refer to Implementation Method 2.

[0145] The difference between Phase Three and Implementation Method Two is that it also includes Procedure 6, such as... Figure 8 As shown.

[0146] Program 6 corrects CPU process power consumption using the following formula, which uses the ratio of the sum of hardware values ​​of all CPU clusters to the sum of process values ​​as weights to correct the process values.

[0147]

[0148] Using the above method, the power consumption of this process under cluster c can be calculated. The total power consumption of this process can then be expressed as:

[0149]

[0150] Using the methods described above, the CPU's device power consumption E can ultimately be obtained. com CPU process power consumption E′ pro .

[0151] The module that writes calculation results to disk is responsible for writing the current CPU device power consumption and CPU process power consumption to disk.

[0152] The beneficial effects of implementation method three:

[0153] This implementation retains the ability of Implementation 2 to perform statistical analysis on multiple clusters and to select the optimal model from multiple models. This implementation ensures that the selection of a single-round model is a locally optimal solution.

[0154] This implementation corrects software process power consumption by measuring device power consumption. This correction method is adopted because the statistical accuracy of CPU device power consumption is very high. Furthermore, there are differences between CPU software statistical values ​​and hardware statistical values. This implementation ensures that, within a single cluster, the sum of the statistically analyzed process power consumption remains consistent with the hardware power consumption. This also means that the statistically analyzed process power consumption maintains the same accuracy as the hardware statistics at the single-cluster level.

[0155] The above examples use CPU clusters as the statistical unit. This application's embodiments are not limited to using CPU clusters as the statistical unit; they can also be adjusted according to the specific power supply system. For example, assuming the CPU power supply scheme adopts a small core plus medium core strategy, then the statistical hardware in this application's embodiments needs to be added to the front end of the small core plus medium core CPU, and the corresponding software statistical strategy is also adjusted to statistically analyze the process data of the small core plus medium core. Through the above statements and examples, this application's embodiments can be implemented in various combinations of CPU cores, CPU clusters, and multiple CPUs; such schemes are also within the protection scope of this application's embodiments.

[0156] It should be noted that the power consumption statistics method provided in this application embodiment can be executed by a power consumption statistics device, or by a control module within that power consumption statistics device for executing the power consumption statistics method. This application embodiment uses the execution of the power consumption statistics method by a power consumption statistics device as an example to illustrate the power consumption statistics device provided in this application embodiment.

[0157] See Figure 9 , Figure 9 This is a structural diagram of the power consumption statistics device provided in the embodiments of this application.

[0158] like Figure 9 As shown, the power consumption statistics device 900 includes:

[0159] The first acquisition module 901 is used to acquire the first power consumption of the first device within the first time period based on the first power value detected by the first power detection device within the first time period.

[0160] The second acquisition module 902 is used to acquire the first working duration set corresponding to the M processes of the first device respectively, to obtain M first working duration sets, wherein the first working duration set corresponding to the first process includes: the working duration of the first process of the first device at each frequency point within the first duration, the first process is any one of the M processes, and M is a positive integer;

[0161] The third acquisition module 903 is used to acquire the second power consumption corresponding to the M processes of the first device within the first duration according to the M first working duration sets and the power set corresponding to the target operating scenario, and obtain M second power consumptions. The power set corresponding to the target operating scenario includes: the power value of the first device at each frequency point when the electronic device is in the target operating scenario.

[0162] The first storage module 904 is used to store the first duration, the first power consumption, and the M second power consumptions.

[0163] In some embodiments, the apparatus further includes:

[0164] The fourth acquisition module is used to acquire the second working duration set corresponding to the first device, the second working duration set including: the working duration of the first device at each frequency point within the first duration;

[0165] The fifth acquisition module is used to acquire the power sets corresponding to the N operating scenarios of the first device, where N is an integer greater than 1;

[0166] The sixth acquisition module is used to acquire the third power consumption corresponding to the N operating scenarios of the first device within the first duration based on the first working duration set and the power sets corresponding to the N operating scenarios respectively, and obtain N third power consumptions.

[0167] The determination module is used to determine the target operating scenario from the N operating scenarios based on the N third power consumptions.

[0168] In some embodiments, the determining module includes:

[0169] The calculation unit is used to calculate the differences between the N third power consumptions and the first power consumption, respectively, to obtain N differences;

[0170] The first determining unit is used to determine the running scenario corresponding to the smallest absolute value among the N differences as the target running scenario.

[0171] In some embodiments, the first storage module includes:

[0172] The second determining unit is used to determine whether the target power consumption is equal to the first power consumption, wherein the target power consumption is the sum of the second power consumption corresponding to the M processes respectively;

[0173] A storage unit is used to store the first duration, the first power consumption, and the M second power consumptions when the target power consumption is equal to the first power consumption.

[0174] In some embodiments, the apparatus further includes:

[0175] The sixth acquisition module is used to acquire a correction coefficient corresponding to the second power consumption when the target power consumption is not equal to the first power consumption, wherein the correction coefficient is the ratio of the first power consumption to the target power consumption;

[0176] The correction module is used to correct the M second power consumptions using the correction coefficient;

[0177] The second storage module is used to store the first duration, the first power consumption, and the corrected M second power consumptions.

[0178] The power consumption statistics device in this application embodiment can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This application embodiment does not impose specific limitations.

[0179] The power consumption statistics device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit it.

[0180] The power consumption statistics device 900 provided in this embodiment can achieve… Figure 2 To avoid repetition, the various processes in the method embodiments will not be described again here.

[0181] Optional, such as Figure 10 As shown, this application embodiment also provides an electronic device 1000, including a processor 1001, a memory 1002, and a program or instructions stored in the memory 1002 and executable on the processor 1001. When the program or instructions are executed by the processor 1001, they implement the various processes of the above-described power consumption statistics method embodiment and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0182] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.

[0183] Figure 11 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of this application.

[0184] The electronic device 1100 includes, but is not limited to, components such as: radio frequency unit 1101, network module 1102, audio output unit 1103, input unit 1104, sensor 1105, display unit 1106, user input unit 1107, interface unit 1108, memory 1109, and processor 1110.

[0185] Those skilled in the art will understand that the electronic device 1100 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 1110 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 11 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.

[0186] The processor 1110 is used for:

[0187] Based on the first power value detected by the first power detection device within the first time period, the first power consumption of the first device within the first time period is obtained;

[0188] Obtain the first working duration set corresponding to each of the M processes of the first device to obtain M first working duration sets, wherein the first working duration set corresponding to the first process includes: the working duration of the first process of the first device at each frequency point within the first duration, the first process is any one of the M processes, and M is a positive integer;

[0189] Based on the M first working duration sets and the power set corresponding to the target operating scenario of the first device, the second power consumption corresponding to the M processes of the first device within the first duration is obtained, resulting in M ​​second power consumptions. The power set corresponding to the target operating scenario includes: the power value of the first device at each frequency point when the electronic device is in the target operating scenario.

[0190] Save the first duration, the first power consumption, and the M second power consumptions.

[0191] The electronic device 1100 provided in this application embodiment can achieve... Figure 2To avoid repetition, the various processes in the method embodiments will not be described again here.

[0192] It should be understood that, in this embodiment, the input unit 1104 may include a graphics processing unit (GPU) 11041 and a microphone 11042. The GPU 11041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 1106 may include a display panel 11061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, etc. The user input unit 1107 includes a touch panel 11071 and other input devices 11072. The touch panel 11071 is also called a touch screen. The touch panel 11071 may include a touch detection device and a touch controller. Other input devices 11072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, joysticks, etc., which will not be described in detail here. The memory 1109 can be used to store software programs and various data, including but not limited to applications and operating systems. Processor 1110 may integrate an application processor and a modem processor. The application processor mainly handles the operating system, user interface, and applications, while the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into processor 1110.

[0193] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described power consumption statistics method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0194] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0195] This application also provides a chip, including a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described power consumption statistics method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again.

[0196] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.

[0197] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0198] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0199] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A power consumption statistics method applied to an electronic device, characterized in that, The electronic device comprises a first device and a first power detection device electrically connected to the first device, wherein the first power detection device is configured to detect power of the first device; The method comprises: obtaining a first power value detected by the first power detection device within a first time length, and obtaining a first power consumption of the first device within the first time length according to the first power value; obtaining a first working time length set corresponding to each of M processes of the first device, wherein the first working time length set corresponding to a first process comprises working time lengths of the first process at each frequency point within the first time length, the first process being any one of the M processes, and M being a positive integer; obtaining a second power consumption corresponding to each of the M processes of the first device within the first time length according to the M first working time length sets and a power set corresponding to a target running scenario of the first device, wherein the power set corresponding to the target running scenario comprises power values of the first device working at each frequency point when the electronic device is in the target running scenario; storing the first time length, the first power consumption and the M second power consumptions; before the step of obtaining the second power consumption corresponding to each of the M processes of the first device within the first time length according to the M first working time length sets and the power set corresponding to the target running scenario of the first device, the method further comprises: obtaining a second working time length set corresponding to the first device, wherein the second working time length set comprises working time lengths of the first device at each frequency point within the first time length; obtaining a power set corresponding to each of N running scenarios of the first device, N being an integer greater than 1, wherein the running scenarios at least include the following two: a game running scenario, a video running scenario and a social running scenario; obtaining a third power consumption corresponding to each of the N running scenarios of the first device within the first time length according to the first working time length set and the power set corresponding to each of the N running scenarios, and obtaining N third power consumptions; determining the target running scenario from the N running scenarios according to the N third power consumptions.

2. The method of claim 1, wherein, The step of determining the target running scenario from the N running scenarios according to the N third power consumptions comprises: calculating a difference between each of the N third power consumptions and the first power consumption to obtain N differences; determining a running scenario corresponding to a difference with the smallest absolute value in the N differences as the target running scenario.

3. The method of claim 1, wherein, The step of storing the first time length, the first power consumption and the M second power consumptions comprises: determining whether a target power consumption is equal to the first power consumption, the target power consumption being a sum of the second power consumptions corresponding to the M processes respectively; storing the first time length, the first power consumption and the M second power consumptions in a case where the target power consumption is equal to the first power consumption.

4. The method of claim 3, wherein, After the step of determining whether the target power consumption is equal to the first power consumption, the method further comprises: In a case where the target power consumption is not equal to the first power consumption, a correction coefficient corresponding to the second power consumption is obtained, the correction coefficient being a ratio of the first power consumption to the target power consumption; The M second power consumptions are corrected by using the correction coefficient; The first time length, the first power consumption, and the M corrected second power consumptions are saved.

5. A power consumption statistics device applied to an electronic device, characterized in that, The electronic device comprises a first device and a first power detection device electrically connected to the first device, wherein the first power detection device is configured to detect power of the first device; The apparatus comprises: A first obtaining module configured to obtain a first power consumption of the first device in a first time length according to a first power value detected by the first power detection device in the first time length; A second obtaining module configured to obtain M first working time length sets respectively corresponding to M processes of the first device, to obtain M first working time length sets, wherein each first working time length set corresponding to a first process comprises working time lengths of the first process at each frequency point in the first time length, the first process being any one of the M processes, and M being a positive integer; A third obtaining module configured to obtain second power consumptions respectively corresponding to the M processes of the first device in the first time length according to the M first working time length sets and a power set corresponding to a target running scenario, to obtain M second power consumptions, wherein the power set corresponding to the target running scenario comprises power values of the first device working at each frequency point when the electronic device is in the target running scenario; A first saving module configured to save the first time length, the first power consumption, and the M second power consumptions; The apparatus further comprises: A fourth obtaining module configured to obtain a second working time length set corresponding to the first device, the second working time length set comprising working time lengths of the first device at each frequency point in the first time length; A fifth obtaining module configured to obtain N power sets respectively corresponding to N running scenarios of the first device, N being an integer greater than 1, the running scenarios at least including the following two: a game running scenario, a video running scenario, and a social running scenario; A sixth obtaining module configured to obtain third power consumptions respectively corresponding to the N running scenarios of the first device in the first time length according to the first working time length set and the N power sets respectively corresponding to the N running scenarios, to obtain N third power consumptions; A determining module configured to determine the target running scenario from the N running scenarios according to the N third power consumptions.

6. The apparatus of claim 5, wherein, The determining module comprises: A calculating unit configured to calculate differences between the N third power consumptions and the first power consumption respectively, to obtain N differences; A first determining unit configured to determine, as the target running scenario, a running scenario corresponding to a difference having a smallest absolute value among the N differences.

7. The apparatus of claim 5, wherein, The first saving module comprises: A second determining unit configured to determine whether a target power consumption is equal to the first power consumption, the target power consumption being a sum of the second power consumptions respectively corresponding to the M processes. The saving unit is configured to save the first time length, the first power consumption and the M second power consumptions when the target power consumption is equal to the first power consumption.

8. The apparatus of claim 7, wherein, The device further comprises: The sixth obtaining module is configured to obtain a correction coefficient corresponding to the second power consumption when the target power consumption is not equal to the first power consumption, the correction coefficient being a ratio of the first power consumption to the target power consumption. The correction module is configured to correct the M second power consumptions by using the correction coefficient. The second saving module is configured to save the first time length, the first power consumption and the M corrected second power consumptions.

9. An electronic device, comprising: The device comprises a processor, a memory and a program or instruction stored on the memory and executable on the processor, and the program or instruction is executed by the processor to implement the steps of the power consumption statistical method according to any one of claims 1 to 4.

10. A readable storage medium, characterized by, The readable storage medium stores the program or instruction, and the program or instruction is executed by the processor to implement the steps of the power consumption statistical method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Linux-based processor process parameter monitoring method and system

    CN108228414A