Power consumption determination method and device, electronic equipment and readable storage medium
By obtaining the temperature of the central processor and the running time of the application thread, and dynamically determining the power consumption of the central processor in combination with the reference relationship, the problem of inaccurate power consumption statistics in the prior art is solved and the accuracy of power consumption statistics is improved.
Patent Information
- Application Number
- CN202411481003.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-02-18
AI Technical Summary
The power consumption statistics applied in the prior art are inaccurate, which affects the battery life of electronic devices.
By obtaining the running time of the application thread at each frequency point of the central processor and the temperature of the central processor, the power consumption of the central processor at each frequency point is determined in combination with the reference relationship, thereby dynamically determining the power consumption of the application.
It realizes more accurate determination of the power consumption of the application at different temperatures, reduces the gap with the actual power consumption, and improves the accuracy of the power consumption statistics results.
Smart Images

Figure CN119473767A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of electronic equipment, and specifically relates to a power consumption determination method, device, electronic equipment and readable storage medium. Background Art
[0002] With the development of technology, electronic devices play an increasingly important role in people's lives. Since people often use electronic devices, the battery life of electronic devices has become one of the important indicators for people to evaluate the quality of electronic devices.
[0003] Generally speaking, if an application in an electronic device runs abnormally for some reason, it will affect the power consumption of the application, and thus affect the battery life of the electronic device. Therefore, in order to improve the user's battery life experience, it is very important to accurately determine the power consumption of the application.
[0004] Currently, the power consumption of applications in electronic devices is mainly determined based on the power consumption of a pre-configured central processing unit at different frequencies and the running time of the application at the central processing unit frequency. However, there is a large gap between the power consumption of the application determined by the above method and the actual power consumption of the application, resulting in inaccurate power consumption statistics of the application. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a power consumption determination method, device, electronic device and readable storage medium, which can solve the technical problem of inaccurate power consumption statistics applied in related technologies.
[0006] In a first aspect, an embodiment of the present application provides a method for determining power consumption, including:
[0007] Obtaining a first running time of a thread of a first application at each frequency point of a central processing unit and a first temperature of the central processing unit;
[0008] Determine the power consumption of the central processing unit at each frequency point according to the first temperature and the reference relationship; the reference relationship is used to characterize the relationship between the temperature and the power consumption of the central processing unit at each frequency point;
[0009] The power consumption of the first application is determined according to each first operating time and the power consumption of the central processing unit at each frequency point.
[0010] In a second aspect, an embodiment of the present application provides a power consumption determination device, including:
[0011] An acquisition module, used for acquiring a first running time of a thread of a first application at each frequency point of a central processing unit and a first temperature of the central processing unit;
[0012] A determination module is used to determine the power consumption of the central processing unit at each frequency point based on the first temperature and a reference relationship; the reference relationship is used to characterize the relationship between the temperature and power consumption of the central processing unit at each frequency point; and the power consumption of the first application is determined based on each first operating time and the power consumption of the central processing unit at each frequency point.
[0013] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.
[0014] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0015] In a fifth aspect, an embodiment of the present application provides a chip, the chip including a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the steps of the method described in the first aspect.
[0016] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the steps of the method described in the first aspect.
[0017] In an embodiment of the present application, the first running time of the thread of the first application at each frequency point of the central processor and the first temperature of the central processor are obtained; the power consumption of the central processor at each frequency point is determined based on the first temperature and a reference relationship, and the reference relationship is used to characterize the relationship between the temperature and the power consumption of the central processor at each frequency point; the power consumption of the first application is determined based on each first running time and the power consumption of the central processor at each frequency point. The implementation of the present application can dynamically determine the power consumption of the central processor at each frequency point based on the temperature of the central processor, that is, taking into account the influence of temperature on the power consumption of the central processor, so that the power consumption of the application at different temperatures can be determined more accurately, and the accuracy of the statistical results of the application power consumption is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 A flowchart of a method for determining power consumption provided in an embodiment of the present application;
[0019] Figure 2 A flowchart of another method for determining power consumption provided in an embodiment of the present application;
[0020] Figure 3 A flowchart of another method for determining power consumption provided in an embodiment of the present application;
[0021] Figure 4A flowchart of another method for determining power consumption provided in an embodiment of the present application;
[0022] Figure 5 A schematic diagram of the structure of a power consumption determination device provided in an embodiment of the present application;
[0023] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0024] Figure 7 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0026] The terms "first", "second", etc. in the specification of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are usually a class, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0027] When analyzing power consumption and temperature rise issues, it is necessary to locate which device is heating abnormally. The central processing unit accounts for the largest proportion of the entire device. Therefore, how to locate which application or process causes the high power consumption of the central processing unit, accurate power consumption measurement is particularly important.
[0028] The existing method for determining application power consumption is to determine the application power consumption by the power consumption of the pre-configured CPU at different frequencies and the running time of the application at the CPU frequency. The specific formula is as follows:
[0029]
[0030] Among them, Power(app1) represents the power consumption of app1 at the current temperature, T i represents the running time of app1 at the i-th frequency point of the CPU, E i Indicates the power consumption of the CPU at the i-th frequency point, and N is the number of CPU frequencies.i It is usually fixed in registers or programs and given by chip manufacturers after testing.
[0031] However, in actual use, the power consumption of the CPU at each frequency point at different temperatures is not fixed, as shown in Table 1, which exemplarily lists the energy efficiency ratios of a CPU at each frequency point at different temperatures.
[0032] Table 1 Energy efficiency ratio of a CPU at different frequencies at different temperatures
[0033]
[0034] As can be seen from Table 1, at the same frequency, the power consumption of the CPU at 65°C and 85°C is quite different, and at some frequencies the difference is even nearly doubled. Therefore, the power consumption determined by the above method is inaccurate and has a large difference with the actual power consumption of the application, which in turn affects the subsequent analysis of the application.
[0035] To this end, the embodiments of the present application provide a power consumption determination method, device, electronic device and readable storage medium, which can solve the technical problem of inaccurate power consumption statistics used in related technologies.
[0036] The power consumption determination method, device, electronic device and readable storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0037] The power consumption determination method provided in the embodiment of the present application can be applied to electronic devices such as mobile phones, tablets, and laptops. The power consumption determination method provided in the embodiment of the present application can be applied to scenarios such as analyzing whether an application is running abnormally based on the power consumption of the application, and testing whether the overall power consumption of the electronic device meets the requirements.
[0038] Figure 1 A flowchart of a method for determining power consumption provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the power consumption determination method may include the following steps:
[0039] S110: Obtain a first running time of a thread of a first application at each frequency point of a central processing unit and a first temperature of the central processing unit.
[0040] S120. Determine the power consumption of the central processing unit at each frequency point according to the first temperature and a reference relationship; the reference relationship is used to characterize the relationship between the temperature and the power consumption of the central processing unit at each frequency point.
[0041] S130: Determine the power consumption of the first application according to each first operating time and the power consumption of the central processing unit at each frequency point.
[0042] The implementation of the present application can dynamically determine the power consumption of the central processing unit at each frequency point according to the temperature of the central processing unit, that is, taking into account the influence of temperature on the power consumption of the central processing unit, so as to more accurately determine the power consumption of the application at different temperatures, reduce the gap with the actual power consumption, and improve the accuracy of the power consumption statistics.
[0043] The above steps are described in detail below:
[0044] In S110, the first application may be any application running in the electronic device, the thread of the first application is a thread included in the first application, the first application may be composed of one or more processes, each process may be composed of one or more threads, that is, the first application may include one or more threads. The embodiment of the present application takes the calculation of the power consumption of the application as an example, and in actual application, the power consumption of each process or each thread of the application may also be calculated separately.
[0045] The electronic device of the embodiment of the present application may include one or more central processing units, and each central processing unit corresponds to the same frequency point. In actual application, the number of frequency points may be multiple, that is, each central processing unit may operate at a different frequency point.
[0046] The same application can run on the same CPU or on different CPUs. For example, if an application consists of multiple threads, when the same application runs on the same CPU, all threads can run at the same frequency or at different frequencies. When the same application runs on different CPUs, some threads can run on one CPU and some threads can run on another CPU.
[0047] The first running time is the running time of each thread at each frequency point. The running time of each thread at each frequency point can be recorded in the member variable time_in_state in the structure task_struct corresponding to each thread. Taking the electronic device using the Android system as an example, each thread has a separate structure task_struct. Assuming that the central processor has a total of N frequency points, the member variable time_in_state is an array of length N, which is used to record the running time of the thread at each frequency point of the central processor. When the central processor performs frequency modulation, the Android system will automatically update the running time of the thread at each frequency point of the central processor recorded in the array. That is, for each thread of the first application, the electronic device can obtain the running time of the thread at each frequency point from the time_in_state corresponding to the thread.
[0048] The first temperature may be the current temperature of the central processing unit, which may be measured by a temperature sensor. The temperature sensor may be disposed on the corresponding central processing unit. For example, the temperature sensor may be a negative temperature coefficient (NTC) sensor, a positive temperature coefficient (PTC) sensor, or the like.
[0049] In S120, the reference relationship is used to characterize the relationship between the temperature and power consumption of the CPU at each frequency point. The reference relationship may be a linear function relationship, a quadratic function relationship, etc. The specific form is associated with the relationship between the temperature and power consumption. The reference relationship may be predetermined, and the specific determination process may refer to the following embodiment.
[0050] The power consumption of the central processing unit at each frequency point may be the power consumption of the central processing unit at each frequency point at the first temperature. The electronic device can determine the power consumption of the central processing unit at each frequency point at the first temperature based on the first temperature of the central processing unit and the reference relationship. That is, in the embodiment of the present application, the power consumption of the central processing unit at each frequency point is related to the temperature of the central processing unit. The power consumption at the same frequency point is different when the temperature of the central processing unit is different. In this way, the power consumption of the application at different temperatures can be measured more accurately.
[0051] In S130, the power consumption of each thread at the first temperature is accumulated to obtain the power consumption of the first application at the first temperature. The power consumption of each thread at the first temperature can be determined by the running time of the thread at each frequency point and the power consumption of the central processor at each frequency point.
[0052] For example, Among them, P j represents the thread power consumption of the jth thread at the first temperature, T ji represents the running time of the jth thread at the i-th frequency point, B i represents the power consumption of the central processor at the i-th frequency point at the first temperature, P represents the power consumption of the first application at the first temperature, and M is the number of threads included in the first application.
[0053] The embodiment of the present application can use a temperature sensor to detect the temperature of the central processing unit in real time, and determine the power consumption of the central processing unit at each frequency point at the temperature based on the temperature and a reference relationship, and then determine the power consumption of the application at the temperature based on the power consumption of the central processing unit at each frequency point at the temperature and the running time of each thread of the application at each frequency point, thereby reducing the gap between the actual power consumption generated by the application at the temperature and improving the accuracy of the measurement results.
[0054] The following is an explanation of the process of determining the reference relationship mentioned in the above embodiment. Figure 2 As shown, Figure 2 and Figure 1 The difference is that Figure 2 Also includes S210-S220.
[0055] S210: For each frequency point, obtain the power consumption of the central processing unit at the frequency point at multiple temperatures.
[0056] For example, the power consumption of the CPU at each frequency point at temperatures such as 10°C, 45°C, 65°C and 85°C can be measured. The power consumption here can be the total power consumption, and the temperature here is the surface temperature of the CPU. The total power consumption of the CPU at each frequency point at different temperatures is measured as follows:
[0057] After the architecture of the CPU is determined, the junction temperature of the CPU can be fixed when the CPU is fully loaded, and then the CPU at different temperatures can be tested. The energy model of the Application Specific Integrated Circuit (ASIC) is used to calculate the power consumption of the CPU at each frequency point at different temperatures. The power consumption includes dynamic power consumption and static power consumption, that is, the power consumption measured when the CPU is running includes dynamic power consumption and static power consumption.
[0058] S220 , fitting the relationship between temperature and power consumption to obtain a reference relationship.
[0059] Exemplarily, for each frequency point, the electronic device can plot points in a two-dimensional coordinate system with temperature as the horizontal axis and power consumption as the vertical axis according to the existing temperature and power consumption, determine the functional relationship between temperature and power consumption at the frequency point according to the relationship between discrete points, and then select a suitable function for fitting. After obtaining the fitting function, the fitting function can be tested using the existing discrete points. For example, it can be determined whether the selected fitting function meets the requirements based on the difference between the power consumption output by the fitting function and the actual power consumption. If it does not meet the requirements, the fitting function can be replaced.
[0060] For example, if the initially determined functional relationship is a quadratic functional relationship, a quadratic function can be fitted based on the existing temperature and power consumption to obtain a fitted quadratic function. During testing, if the power consumption obtained based on the quadratic function is only similar to the power consumption at a few temperatures, and is significantly different from the power consumption at most other temperatures, then it is necessary to adjust the functional relationship between temperature and power consumption, and then refit until the fitted function is similar to the power consumption at most temperatures.
[0061] Exemplarily, multiple temperatures and corresponding power consumption and architecture parameters such as heat dissipation of the electronic device may also be input into the relationship fitting model, and the relationship between the temperature and power consumption may be output by the relationship fitting model. The relationship fitting model may be a deep learning model.
[0062] In an embodiment of the present application, each central processing unit has a run queue runqueue, which is used to manage threads running on the central processing unit, and the run queue runqueue is stored in the structure struct rq of each central processing unit. Each struct rq has its own corresponding struct root_domain, and each struct root_domain contains an em_cap_state. The em_cap_state is similar to a list, which is used to store the power consumption of the central processing unit at various frequencies at different temperatures. Therefore, after obtaining the relationship between temperature and power consumption, the power consumption of the central processing unit at various frequencies at different temperatures can be stored in the em_cap_state, and the power consumption of the central processing unit at various frequencies at different temperatures can be obtained by table lookup later, which simplifies the process of obtaining power consumption.
[0063] The embodiment of the present application measures the power consumption of the central processing unit at each frequency point at a finite number of temperatures, and performs relationship fitting based on the finite number of temperatures and power consumption to obtain the relationship between different temperatures and power consumption of the central processing unit at each frequency point, so that the power consumption of the central processing unit at each frequency point at the actual temperature can be dynamically determined based on the actual temperature of the central processing unit, thereby more accurately determining the power consumption of each application or thread at the actual temperature.
[0064] The application power consumption determined by the above embodiment can be the power consumption of the application at the actual temperature when the central processing unit is in the running state (also called the active state). That is, by default, the central processing unit is always in the running state during the period of time when the actual temperature persists. It is understandable that in actual applications, the central processing unit may be in different states during the period of time when the actual temperature persists, for example, the period of time when the actual temperature persists includes the running state and the idle state. In order to accurately determine the total power consumption of the electronic device, the embodiment of the present application also provides a power consumption determination method, such as Figure 3 As shown, Figure 3 and Figure 1 The difference is that Figure 3 Also includes S310-S320.
[0065] S310, obtaining a first characteristic of a central processing unit during a duration of a first temperature and a static power consumption of the central processing unit at each frequency point at the first temperature.
[0066] Exemplarily, the first feature is used to characterize the operating time of the central processing unit in different states within the duration of the first temperature, for example, it may include the operating state duration of the operating state and the idle state duration of the idle state. Exemplarily, the operating state duration and the idle state duration can be obtained through a performance monitoring tool or timer provided by the operating system. For example, in a Linux system, the active state and idle state time of the central processing unit can be obtained through information in the / proc file system. Among them, the operating time of the central processing unit at each frequency point at different temperatures can be stored in the variable temp_in_state of the structure task_struct.
[0067] The static power consumption of the central processing unit at each frequency point at the first temperature can be measured when the central processing unit is in sleep mode, and the specific measurement process is not limited in the embodiment of the present application.
[0068] S320: Determine the total power consumption of the electronic device according to the first feature, the power consumption of the first application, and the static power consumption of the central processor at each frequency point at the first temperature.
[0069] Exemplarily, by accumulating the static power consumption of the central processor at each frequency point at the first temperature, the static power consumption of the central processor at the first temperature can be obtained, that is, the static power consumption of the central processor in an idle state.
[0070] During the duration of the first temperature, the total power consumption of the electronic device can be determined based on the first feature of the central processor during the duration, the power consumption of each application calculated by the central processor in the running state, and the static power consumption of the central processor in the idle state. Because the central processor is the core component of the electronic device and is also the device with the largest power consumption overhead, the embodiment of the present application only considers the power consumption of the central processor and ignores other power consumption.
[0071] When calculating the power consumption of the electronic device at the first temperature, the embodiment of the present application not only takes into account the total power consumption of the central processing unit in the running state, but also takes into account the static power consumption of the central processing unit in the idle state, so that the total power consumption of the device can be measured more accurately.
[0072] Taking the first feature including the running state duration and the idle state duration as an example, illustratively, the above S320 may include the following steps:
[0073] Determining the static power consumption of the central processor in an idle state according to the static power consumption of the central processor at each frequency point at the first temperature;
[0074] Determine the first time weight according to the relationship between the running state duration and the duration;
[0075] Determining a second time weight according to a relationship between the idle state duration and the duration;
[0076] According to the first time weight and the second time weight, the power consumption of the first application and the static power consumption of the central processor in the idle state are weighted and summed to obtain the total power consumption of the electronic device.
[0077] Exemplarily, assuming that the CPU is in an idle state during the duration of the first temperature, the static power consumption of the CPU at each frequency point at the first temperature is accumulated to obtain the static power consumption of the CPU in the idle state.
[0078] However, in actual application, the central processing unit may exist in different states during the duration of the first temperature, such as an operating state and an idle state. In order to accurately measure the power consumption of the electronic device at the first temperature, the weight of the central processing unit in different states can be determined according to the duration of the operating state and the idle state and the duration of the first temperature.
[0079] Exemplarily, the first time weight Cbusy=Tbusy / Ttotal, and the second time weight Cidle=Tidle / Ttotal, wherein Tbusy is the duration of the running state, Tidle is the duration of the idle state, and Ttotal is the duration of the first temperature.
[0080] Exemplarily, E=Pbusy*Cbusy+Pidle*Cidle, where E is the total power consumption of the electronic device at the first temperature, Pbusy is the total power consumption of the central processing unit in the running state, that is, the cumulative sum of the power consumption of each first application running in the electronic device, and Pidle is the static power consumption of the central processing unit in the idle state.
[0081] The embodiment of the present application can measure the total power consumption of the electronic device according to the idle state duration and the running state duration, combined with the power consumption of the central processing unit in the running state and the power consumption of the central processing unit in the idle state, fully considering the different states of the central processing unit during the duration of the first temperature, and improving the accuracy of the device power consumption measurement results.
[0082] In some embodiments, after S130, the power consumption determination method may further include the following steps:
[0083] When the power consumption of the first application is greater than the first power consumption threshold, abnormal prompt information is output, where the abnormal prompt information is used to prompt that the first application is running abnormally.
[0084] The first power consumption threshold can be determined according to scenarios, requirements, etc. In some embodiments, the first power consumption threshold can be determined according to the maximum power consumption of the application when it is operating normally at the first temperature. For example, the first power consumption threshold can be the maximum power consumption of the application when it is operating normally at the first temperature. The first power consumption threshold of the same application at different temperatures can be different, and the first power consumption threshold of different applications at the same temperature can also be different. The electronic device can store the power consumption thresholds of each application at different temperatures.
[0085] Exemplarily, the electronic device can obtain the power consumption threshold of the first application at the first temperature based on the first temperature of the central processor and the application identifier of the first application, and compare the currently calculated power consumption of the first application with the obtained power consumption threshold; when the calculated power consumption of the first application is greater than the obtained power consumption threshold, the electronic device can output abnormal prompt information to prompt the user that the first application is running abnormally.
[0086] The embodiment of the present application does not limit the output method of the abnormal prompt information, for example, the abnormal prompt information can be output by voice, text, SMS, phone, email, etc. The abnormal prompt information may include but is not limited to the application identifier of the first application, the power consumption of the first application at the first temperature, and the corresponding power consumption threshold.
[0087] Exemplarily, after obtaining the power consumption of a thread or a process, the embodiment of the present application may further determine whether the thread or the process is running abnormally, and the determination process is similar.
[0088] The embodiment of the present application can further determine whether the operation of the application is abnormal based on the measured application power consumption. Since the embodiment of the present application can more accurately measure the application power consumption at different temperatures, it can more accurately analyze whether the operation of the application at different temperatures is abnormal.
[0089] Figure 4 A flowchart of another method for determining power consumption provided in an embodiment of the present application, Figure 4 and Figure 1 The difference is that Figure 4 Also includes S410-S430. Figure 4 Take an electronic device including at least two central processing units as an example.
[0090] S410: When it is detected that the electronic device meets the load balancing condition, the application computing power of the running application in the electronic device is obtained.
[0091] Exemplarily, the electronic device triggers load balancing when detecting the following situations, that is, it is considered that the load balancing condition is met:
[0092] (1) The CPU goes from the running state to the idle state;
[0093] (2) Tick interrupt is detected. Tick interrupt is used to periodically detect whether load balancing is required;
[0094] (3) A misfit task is detected in the CPU runqueue;
[0095] (4) Create a new process or rerun a process in a sleeping / blocked state
[0096] The running application is an application in the running state in the electronic device, and the running application here may include the first application in the above embodiment. Exemplarily, when it is detected that the electronic device meets the load balancing condition, the application computing power of each running application can be obtained. The application computing power is the computing power of the application. Different applications can correspond to different computing powers. The greater the computing power, the higher the performance requirements for the central processing unit. The computing power of each application can be determined based on factors such as the hardware configuration and software support of the electronic device. Under normal circumstances, when the architecture of the electronic device is determined, the computing power of each application in the electronic device is also fixed.
[0097] S420. Determine a target frequency of a target central processor corresponding to the running application according to the application computing power and a second characteristic of each frequency of each central processor at the first temperature, wherein the second characteristic includes at least one of processor computing power and processor power consumption.
[0098] The processor power consumption of the central processing unit at each frequency point at the first temperature, that is, the power consumption of the central processing unit at each frequency point at the first temperature in the above embodiment.
[0099] Exemplarily, when the second feature includes processor computing power, the electronic device can determine the target frequency of the target central processor according to the application computing power of the running application and the processor computing power of each central processor at each frequency at the first temperature. For example, the maximum computing power can be determined from the computing power of each central processor, and the central processor to which the maximum computing power belongs is determined as the target central processor, and the frequency point to which the maximum computing power belongs is determined as the target frequency point.
[0100] For example, if the computing power of CPU 4 at frequency 2.0 and the computing power of CPU 7 at frequency 1.5 are both greater than the computing power of a running application, and the computing power of CPU 4 at frequency 2.0 is greater than the computing power of CPU 7 at frequency 1.5, then CPU 4 can be determined as the target CPU and frequency 2.0 can be determined as the target frequency.
[0101] Exemplarily, when the second feature includes processor power consumption, the minimum power consumption can be determined from the power consumptions of various processors, and the central processor to which the minimum power consumption belongs is determined as the target central processor, and the frequency point to which the minimum power consumption belongs is determined as the target frequency point.
[0102] For example, at the first temperature, the CPU 5 has the lowest processor power consumption at a frequency of 2.5, so the CPU 5 can be determined as the target CPU and the frequency of 2.5 can be determined as the target frequency.
[0103] Exemplarily, when the second feature includes processor computing power and processor power consumption, the central processor and frequency point that match the application computing power of the running application can be determined comprehensively based on the processor computing power and processor power consumption of the central processor at each frequency point.
[0104] Exemplarily, the above S420 may include the following steps:
[0105] According to the application computing power, determine the candidate computing power greater than or equal to the application computing power and the candidate frequency points corresponding to the candidate computing power from the computing power of each processor;
[0106] A frequency point whose processor power consumption is less than a second power consumption threshold value among the candidate frequency points is determined as a target frequency point, and a central processor whose power consumption is less than the second power consumption threshold value is determined as a target central processor.
[0107] The candidate computing power is the processor computing power of each CPU at each frequency point at the first temperature that is greater than or equal to the application computing power of a running application. Candidate frequency points can be obtained based on the candidate computing power, and the electronic device can further determine the target CPU and target frequency point based on power consumption from the candidate frequency points.
[0108] The second power consumption threshold is used to select a frequency point with the lowest power consumption from the candidate frequency points. The second power consumption threshold can be dynamically determined according to the power consumption of the candidate frequency points, as long as the power consumption of the processor at the selected frequency point is the lowest.
[0109] For example, the processor computing power of CPU 4 at 2.0 frequency is the same as that of CPU 7 at 1.5 frequency, and both are greater than the application computing power of a running application. However, at different temperatures, the processor power consumption of CPU 4 at 2.0 frequency is different from that of CPU 7 at 1.5 frequency. Therefore, the CPU and frequency matching the running application can be further determined based on the processor power consumption of CPU 4 at 2.0 frequency and the processor power consumption of CPU 7 at 1.5 frequency. For example, when the temperature is 30°C, the processor power consumption of CPU 4 at 2.0 frequency is less than that of CPU 7 at 1.5 frequency. Therefore, CPU 4 can be determined as the target CPU and 2.0 frequency can be determined as the target frequency.
[0110] The embodiments of the present application can dynamically determine the central processor and frequency that match the application computing power of the running application based on the processor computing power and processor power consumption of the central processor at each frequency point, and allocate a central processor and frequency with lower power consumption to the running application as much as possible without affecting the performance of the running application, thereby saving power consumption, increasing the battery life of the electronic device, and improving the user's battery life experience.
[0111] S430: Run the application at a target frequency of the target central processor.
[0112] After the target CPU and the target frequency are determined, the electronic device can schedule the running application to the target frequency of the target CPU, so that the running application runs at the target frequency of the target CPU.
[0113] In the embodiment of the present application, when the electronic device meets the load balancing conditions, the central processing unit and frequency that match the running application can be dynamically determined based on the application computing power of the running application and the second characteristics of each central processing unit at each frequency at different temperatures, and the running application can be scheduled based on the matching central processing unit and frequency. Without affecting the performance of the running application, the power consumption can be reduced as much as possible, the power consumption can be saved, and the battery life can be extended.
[0114] The embodiment of the present application can dynamically determine the power consumption of the central processor at each frequency point at different temperatures, and combine the running time of the thread at each frequency point of the central processor to more accurately measure the power consumption of the thread, process or application, and then more accurately analyze the abnormality of the thread, process or application. At the same time, when the electronic device meets the load balancing conditions, it can also dynamically schedule the running application according to the dynamically determined processor power consumption and processor computing power of the central processor at each frequency point at different temperatures, and reduce the power consumption as much as possible without affecting the performance of the application, thereby increasing the battery life of the electronic device and improving the user's battery life experience.
[0115] It should be noted that the power consumption determination method provided in the embodiment of the present application can be executed by a power consumption determination device, or a processing module in the power consumption determination device for executing the power consumption determination method. In the embodiment of the present application, the power consumption determination device provided in the embodiment of the present application is described by taking the power consumption determination method executed by the power consumption determination device as an example.
[0116] Figure 5 A schematic diagram of the structure of a power consumption determination device provided in an embodiment of the present application.
[0117] like Figure 5 As shown, the power consumption determination device 500 may include:
[0118] An acquisition module 501 is used to acquire a first running time of a thread of a first application at each frequency point of a central processing unit and a first temperature of the central processing unit;
[0119] Determination module 502 is used to determine the power consumption of the central processing unit at each frequency point based on the first temperature and the reference relationship; the reference relationship is used to characterize the relationship between the temperature and power consumption of the central processing unit at each frequency point; the power consumption of the first application is determined based on each first operating time and the power consumption of the central processing unit at each frequency point.
[0120] In an embodiment of the present application, the first running time of the thread of the first application at each frequency point of the central processor and the first temperature of the central processor are obtained; the power consumption of the central processor at each frequency point is determined according to the first temperature and the reference relationship; the reference relationship is used to characterize the relationship between the temperature and power consumption of the central processor at each frequency point; the power consumption of the first application is determined according to each first running time and the power consumption of the central processor at each frequency point. The implementation of the present application can dynamically determine the power consumption of the central processor at each frequency point according to the temperature of the central processor, that is, taking into account the influence of temperature on the power consumption of the central processor, so that the power consumption of the application at different temperatures can be determined more accurately, reducing the gap with the actual power consumption, and improving the accuracy of the application power consumption statistics.
[0121] In some possible implementations of the embodiments of the present application, the acquisition module 501 is further used to acquire, for each frequency point, the power consumption of the central processor at the frequency point at multiple temperatures;
[0122] The power consumption determination device 500 may further include:
[0123] The fitting module is used to fit the relationship between temperature and power consumption to obtain a reference relationship.
[0124] In some possible implementations of the embodiments of the present application, the acquisition module 501 is further used to acquire a first characteristic of the central processor within a duration of the first temperature and a static power consumption of the central processor at each frequency point at the first temperature;
[0125] The determination module 502 is further configured to determine the total power consumption of the electronic device according to the first feature, the power consumption of the first application, and the static power consumption of the central processor at each frequency point at the first temperature.
[0126] In some possible implementations of the embodiments of the present application, the first feature includes a running state duration and an idle state duration;
[0127] The determination module 502 is specifically configured to:
[0128] Determining the static power consumption of the central processor in an idle state according to the static power consumption of the central processor at each frequency point at the first temperature;
[0129] Determine the first time weight according to the relationship between the running state duration and the duration;
[0130] Determining a second time weight according to a relationship between the idle state duration and the duration;
[0131] The power consumption of the first application and the static power consumption of the central processor in an idle state are weighted and summed according to the first time weight and the second time weight to obtain the total power consumption of the electronic device.
[0132] In some possible implementations of the embodiments of the present application, the power consumption determination device 500 may further include:
[0133] The output module is used to output abnormal prompt information when the power consumption of the first application is greater than the first power consumption threshold, and the abnormal prompt information is used to prompt that the first application runs abnormally.
[0134] In some possible implementations of the embodiments of the present application, the device is applied to an electronic device, and the electronic device includes at least two central processors;
[0135] The acquisition module 501 is further configured to acquire the application computing power of the running application in the running state in the electronic device when it is detected that the electronic device meets the load balancing condition;
[0136] The determination module 502 is specifically configured to:
[0137] Determining a target frequency of a target central processor corresponding to the running application according to the application computing power and a second characteristic of each frequency of each central processor at the first temperature, the second characteristic comprising at least one of processor computing power and processor power consumption;
[0138] The power consumption determination device 500 may further include:
[0139] The running module is used to run the running application at the target frequency point of the target central processor.
[0140] In some possible implementations of the embodiments of the present application, the second feature includes processor computing power and processor power consumption;
[0141] The determination module 502 is specifically configured to:
[0142] According to the application computing power, determine the candidate computing power greater than or equal to the application computing power and the candidate frequency points corresponding to the candidate computing power from the computing power of each processor;
[0143] A frequency point whose processor power consumption is less than a second power consumption threshold value among the candidate frequency points is determined as a target frequency point, and a central processor whose frequency point power consumption is less than the second power consumption threshold value is determined as a target central processor.
[0144] The embodiment of the present application can dynamically determine the frequency power consumption of the central processor at each frequency point at different temperatures, and combine the running time of the thread at each frequency point of the central processor to more accurately measure the power consumption of the thread, process or application, and then more accurately analyze the abnormality of the thread, process or application. At the same time, when the electronic device meets the load balancing conditions, it can also dynamically schedule the running application according to the processor power consumption and processor computing power of the dynamically determined central processor at each frequency point at different temperatures, and reduce the power consumption as much as possible without affecting the performance of the application, thereby increasing the battery life of the electronic device and improving the user's battery life experience.
[0145] The power consumption determination device in the embodiment of the present application can be a device, or a component in an electronic device, such as an integrated circuit or a chip. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a user computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0146] The electronic device in the embodiment of the present application may be a terminal with an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0147] The power consumption determination device provided in the embodiment of the present application can achieve Figures 1 to 4 The various processes in the power consumption determination method embodiment can achieve the same technical effect. To avoid repetition, they will not be described here.
[0148] like Figure 6 As shown, an embodiment of the present application also provides an electronic device 600, including a processor 601 and a memory 602, wherein the memory 602 stores programs or instructions that can be executed on the processor 601, and when the program or instructions are executed by the processor 601, the various steps of the above-mentioned power consumption determination method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not described here.
[0149] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile terminals and non-mobile terminals.
[0150] Figure 7 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.
[0151] The electronic device 700 includes but is not limited to: a radio frequency unit 701, a network module 702, an audio output unit 703, an input unit 704, a sensor 705, a display unit 706, a user input unit 707, an interface unit 708, a memory 709, and a processor 710.
[0152] Those skilled in the art will appreciate that the electronic device 700 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 710 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 7 The structure of the electronic device 700 shown in the figure does not constitute a limitation on the electronic device 700. The electronic device 700 may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0153] Among them, processor 710 is used to obtain the first running time of the thread of the first application at each frequency point of the central processing unit and the first temperature of the central processing unit; determine the power consumption of the central processing unit at each frequency point based on the first temperature and the reference relationship; the reference relationship is used to characterize the relationship between the temperature and power consumption of the central processing unit at each frequency point; determine the power consumption of the first application based on each first running time and the power consumption of the central processing unit at each frequency point.
[0154] In an embodiment of the present application, the first running time of the thread of the first application at each frequency point of the central processor and the first temperature of the central processor are obtained; the power consumption of the central processor at each frequency point is determined according to the first temperature of the central processor and the reference relationship; the reference relationship is used to characterize the relationship between the temperature and power consumption of the central processor at each frequency point; the power consumption of the first application is determined according to each first running time and the power consumption of the central processor at each frequency point. The implementation of the present application can dynamically determine the power consumption of the central processor at each frequency point according to the temperature of the central processor, that is, taking into account the influence of temperature on the power consumption of the central processor, so that the power consumption of the application at different temperatures can be determined more accurately, reducing the gap with the actual power consumption, and improving the accuracy of the statistical results of the application power consumption.
[0155] In some possible implementations of the embodiments of the present application, the processor 710 is further configured to obtain, for each frequency point, the power consumption of the central processor at the frequency point at multiple temperatures;
[0156] The relationship between temperature and power consumption is fitted to obtain a reference relationship.
[0157] In some possible implementations of the embodiments of the present application, the processor 710 is further configured to obtain a first characteristic of the central processor within a duration of the first temperature and a static power consumption of the central processor at each frequency point at the first temperature;
[0158] The total power consumption of the electronic device is determined according to the first feature, the power consumption of the first application, and the static power consumption of the central processor at each frequency point at the first temperature.
[0159] In some possible implementations of the embodiments of the present application, the first feature includes a running state duration and an idle state duration;
[0160] The processor 710 is specifically configured to:
[0161] Determining the static power consumption of the central processor in an idle state according to the static power consumption of the central processor at each frequency point at the first temperature;
[0162] Determine the first time weight according to the relationship between the running state duration and the duration;
[0163] Determining a second time weight according to a relationship between the idle state duration and the duration;
[0164] The power consumption of the first application and the static power consumption of the central processor in an idle state are weighted and summed according to the first time weight and the second time weight to obtain the total power consumption of the electronic device.
[0165] In some possible implementations of the embodiments of the present application, the processor 710 is further used to output abnormal prompt information when the power consumption of the first application is greater than the first power consumption threshold, and the abnormal prompt information is used to prompt that the first application is running abnormally.
[0166] In some possible implementations of the embodiments of the present application, the electronic device includes at least two central processors;
[0167] The processor 710 is further configured to obtain the application computing power of the running application in the running state in the electronic device when it is detected that the electronic device meets the load balancing condition;
[0168] Determining a target frequency of a target central processor corresponding to the running application according to the application computing power and a second characteristic of each frequency of each central processor at the first temperature, the second characteristic comprising at least one of processor computing power and processor power consumption;
[0169] The running application is run at a target frequency of the target central processor.
[0170] In some possible implementations of the embodiments of the present application, the second feature includes processor computing power and processor power consumption;
[0171] The processor 710 is specifically configured to:
[0172] According to the application computing power, determine the candidate computing power greater than or equal to the application computing power and the candidate frequency points corresponding to the candidate computing power from the computing power of each processor;
[0173] A frequency point whose processor power consumption is less than a second power consumption threshold value among the candidate frequency points is determined as a target frequency point, and a central processor whose frequency point power consumption is less than the second power consumption threshold value is determined as a target central processor.
[0174] The embodiment of the present application can dynamically determine the frequency power consumption of each frequency point of the central processor at different temperatures, and combine the running time of the thread at each frequency point of the central processor to more accurately measure the power consumption of the thread, process or application, and then more accurately analyze the abnormality of the thread, process or application. At the same time, when the electronic device meets the load balancing conditions, it can also dynamically schedule the running application according to the processor power consumption and processor computing power of the dynamically determined central processor at each frequency point at different temperatures, and reduce the power consumption as much as possible without affecting the performance of the application, thereby increasing the battery life of the electronic device and improving the user's battery life experience.
[0175] It should be understood that in the embodiment of the present application, the input unit 704 may include a graphics processor (Graphics Processing Unit, GPU) 7041 and a microphone 7042, and the graphics processor 7041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 706 may include a display panel 7061, and the display panel 7061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 707 includes a touch panel 7071 and at least one of other input devices 7072. The touch panel 7071 is also called a touch screen. The touch panel 7071 may include two parts: a touch detection device and a touch controller. Other input devices 7072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0176] The memory 709 can be used to store software programs and various data. The memory 709 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 709 may include a volatile memory or a non-volatile memory, or the memory 709 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 709 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0177] The processor 710 may include one or more processing units; optionally, the processor 710 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 710.
[0178] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned power consumption determination method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0179] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0180] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned power consumption determination method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0181] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0182] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned power consumption determination method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0183] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0184] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the relevant technology, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0185] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A method for determining power consumption, characterized in that: include: Obtaining a first running time of a thread of a first application at each frequency point of a central processing unit and a first temperature of the central processing unit; Determining the power consumption of the central processing unit at each frequency point according to the first temperature and a reference relationship; the reference relationship is used to characterize the relationship between the temperature and the power consumption of the central processing unit at each frequency point; The power consumption of the first application is determined according to each of the first operating time periods and the power consumption of the central processing unit at each frequency point.
2. The method according to claim 1, characterized in that: The method further comprises: For each frequency point, obtaining the power consumption of the central processor at the frequency point at multiple temperatures; The relationship between temperature and power consumption is fitted to obtain the reference relationship.
3. The method according to claim 1, characterized in that: The method further comprises: Acquire a first characteristic of the central processing unit during a duration of the first temperature and a static power consumption of the central processing unit at each frequency point at the first temperature; The total power consumption of the electronic device is determined according to the first feature, the power consumption of the first application, and the static power consumption of the central processor at each frequency point at the first temperature.
4. The method according to claim 3, characterized in that: The first feature includes the running state duration and the idle state duration; The determining the total power consumption of the electronic device according to the first feature, the power consumption of the first application, and the static power consumption of the central processor at each frequency point at the first temperature includes: Determining the static power consumption of the central processing unit in an idle state according to the static power consumption of the central processing unit at each frequency point at the first temperature; Determining a first time weight according to the relationship between the running state duration and the duration; Determining a second time weight according to the relationship between the idle state duration and the duration; According to the first time weight and the second time weight, the power consumption of the first application and the static power consumption of the central processor in an idle state are weighted and summed to obtain the total power consumption of the electronic device.
5. The method according to claim 1, characterized in that The method further comprises: When the power consumption of the first application is greater than a first power consumption threshold, abnormal prompt information is output, where the abnormal prompt information is used to prompt that the first application is running abnormally.
6. The method according to claim 1, characterized in that The method is applied to an electronic device, wherein the electronic device includes at least two central processing units; The method further comprises: When it is detected that the electronic device meets the load balancing condition, obtaining the application computing power of the running application in the running state in the electronic device; determining a target frequency of a target central processor corresponding to the running application according to the application computing power and a second characteristic of each frequency of each central processor at the first temperature, wherein the second characteristic includes at least one of processor computing power and processor power consumption; The running application is run at a target frequency of the target central processor.
7. The method according to claim 6, characterized in that The second characteristic includes processor computing power and processor power consumption; The determining, according to the application computing power and the second characteristic of each frequency point of each central processing unit at the first temperature, a target frequency point of a target central processing unit corresponding to the running application includes: According to the application computing power, determine, from each of the processor computing powers, a candidate computing power greater than or equal to the application computing power and a candidate frequency point corresponding to the candidate computing power; A frequency point whose processor power consumption is less than a second power consumption threshold value among the candidate frequency points is determined as a target frequency point, and a central processing unit whose power consumption is less than the second power consumption threshold value is determined as a target central processing unit.
8. A power consumption determination device, characterized in that: include: An acquisition module, configured to acquire a first running time of a thread of a first application at each frequency point of a central processing unit and a first temperature of the central processing unit; A determination module is used to determine the power consumption of the central processing unit at each frequency point based on the first temperature and a reference relationship; the reference relationship is used to characterize the relationship between the temperature and power consumption of the central processing unit at each frequency point; and the power consumption of the first application is determined based on each of the first operating time and the power consumption of the central processing unit at each frequency point.
9. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Temperature regulation and control method and device, storage medium and electronic equipment
CN120929278A