Power consumption processing method and device and storage medium
By obtaining and comparing the power consumption lists of local and servers, determining and skipping the high power consumption function call stack in the client, the high power consumption problem of client is solved and the user experience and client retention rate is improved.
Patent Information
- Application Number
- CN202510355119.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-06-27
AI Technical Summary
The high power consumption of the client leads to a rapid decline in power and continuous heating of terminal equipment, affecting the user experience and reducing the retention rate of the client.
By obtaining the locally stored first power consumption list and the second power consumption list sent by the server, the target function call stack exists in both at the same time, and the execution of these high power consumption function call stacks is skipped during the operation of the target client.
It effectively solves the problem of high power consumption of clients, avoids heating of terminal devices, improves user experience, and improves client retention rate.
Smart Images

Figure CN120215675A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular, to a power consumption processing method, device, and storage medium. Background Art
[0002] Currently, the power consumption of the client is relatively high, resulting in a rapid decline in the battery power of the terminal device running the client and continuous heating, which affects the user experience and easily causes the user to directly close or even uninstall the client, reducing the retention rate of the client.
[0003] Therefore, how to handle the high power consumption of the client has become a technical problem to be solved. Summary of the Invention
[0004] Embodiments of the present invention provide a power consumption processing method, device, and storage medium to solve the problem of high power consumption of the client in the prior art.
[0005] In a first aspect, an embodiment of the present invention provides a power consumption processing method, including:
[0006] In response to a start instruction, obtain a first power consumption list stored locally; the first power consumption list includes function information of function call stacks that meet the first power consumption condition during the historical startup and operation of the target client;
[0007] Send a power consumption list acquisition request to the server to obtain a second power consumption list matching the device environment information of the target client sent by the server; the second power consumption list includes function information of at least one function call stack reported by the client in the past that meets the second power consumption condition and matches the device environment information of the target client;
[0008] Determine whether there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list according to the function information of the function call stacks in the first power consumption list and the function information of the function call stacks in the second power consumption list;
[0009] In the case where there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list, skip executing the target function call stack during the operation of the target client.
[0010] In a second aspect, an embodiment of the present invention provides a power consumption processing method, including:
[0011] In response to a power consumption list acquisition request of the target client, determine function information of at least one function call stack reported by the client in the past that meets the second power consumption condition and matches the device environment information of the target client;
[0012] Construct a second power consumption list according to the function information of the function call stack;
[0013] Send the second power consumption list to the target client; the second power consumption list is used for the target client to determine a target function call stack that is simultaneously in the first power consumption list and the second power consumption list according to the function information of the function call stack in the first power consumption list and the function information of the function call stack in the second power consumption list, so as to skip executing the target function call stack during the running of the target client; the first power consumption list includes the function information of the function call stack that meets the first power consumption condition during the historical startup and running process of the target client.
[0014] In a third aspect, an embodiment of the present invention provides a power consumption processing device, and the device includes:
[0015] In response to a startup instruction, obtain a first power consumption list stored locally; the first power consumption list includes the function information of the function call stack that meets the first power consumption condition during the historical startup and running process of the target client;
[0016] Send a power consumption list acquisition request to the server to obtain a second power consumption list sent by the server that matches the device environment information of the target client; the second power consumption list includes the function information of at least one function call stack reported by a client in the past that meets the second power consumption condition and matches the device environment information of the target client;
[0017] Determine whether there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list according to the function information of the function call stack in the first power consumption list and the function information of the function call stack in the second power consumption list;
[0018] In the case where there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list, skip executing the target function call stack during the running of the target client.
[0019] In a fourth aspect, an embodiment of the present invention provides a power consumption processing device, and the device includes:
[0020] In response to a power consumption list acquisition request of a target client, determine the function information of at least one function call stack reported by a client in the past that meets the second power consumption condition and matches the device environment information of the target client;
[0021] Construct a second power consumption list according to the function information of the function call stack;
[0022] Send the second power consumption list to the target client; the second power consumption list is used for the target client to determine a target function call stack that is simultaneously in the first power consumption list and the second power consumption list according to the function information of the function call stack in the first power consumption list and the function information of the function call stack in the second power consumption list, so as to skip executing the target function call stack during the operation of the target client; the first power consumption list includes the function information of the function call stacks that meet the first power consumption condition during the historical startup and operation of the target client.
[0023] In a fifth aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, where the memory is used to store one or more computer instructions. Among them, when the one or more computer instructions are executed by the processor, the power consumption processing method in the first aspect or the power consumption processing method in the second aspect described above is implemented. The electronic device may further include a communication interface for communicating with other devices or communication systems.
[0024] In a sixth aspect, an embodiment of the present invention provides a non-transitory machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor can at least implement the power consumption processing method in the first aspect or the power consumption processing method in the second aspect described above.
[0025] In a seventh aspect, an embodiment of the present invention provides a computer program product, which includes a computer program or instruction. When the computer program or instruction is executed by a processor, the processor can implement the power consumption processing method in the first aspect or the power consumption processing method in the second aspect described above.
[0026] In an embodiment of the present invention, in response to a startup instruction, a first power consumption list stored locally is obtained; a power consumption list acquisition request is sent to a server to obtain a second power consumption list sent by the server and matching the device environment information of a target client; wherein, the first power consumption list includes function information of function call stacks that meet the first power consumption condition during the historical startup and operation of the target client; the second power consumption list includes function information of function call stacks that meet the second power consumption condition and are reported by at least one client matching the device environment information of the target client in history; according to the function information of the function call stacks in the first power consumption list and the function information of the function call stacks in the second power consumption list, it is determined whether there is a target function call stack that is simultaneously located in the first power consumption list and the second power consumption list; in the case where there is a target function call stack that is simultaneously located in the first power consumption list and the second power consumption list, the execution of the target function call stack is automatically skipped during the operation of the target client. By avoiding the execution of high-power-consuming target function call stacks, the high power consumption problem of the client is solved, and the heat generated by the operation of the client affecting the user experience is avoided. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0028] Figure 1 It is a flowchart of an embodiment of a power consumption processing method provided by an embodiment of the present invention;
[0029] Figure 2 It is a flowchart of an embodiment of a power consumption processing method provided by an embodiment of the present invention;
[0030] Figure 3a It shows a schematic diagram of the reporting process of the historical startup and operation of a target client in an actual application;
[0031] Figure 3b It shows a schematic diagram of the power consumption processing process of the current startup and operation of a target client in an actual application;
[0032] Figure 4 It is a schematic structural diagram of a power consumption processing device provided by an embodiment of the present invention;
[0033] Figure 5 It is a schematic structural diagram of a power consumption processing device provided by an embodiment of the present invention;
[0034] Figure 6 For Figure 4 orFigure 5 Schematic structural diagram of an electronic device corresponding to the power consumption processing device provided by the illustrated embodiment. Detailed implementation manners
[0035] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0036] As described in the background art, currently, the power consumption of the client is relatively high, resulting in a rapid decrease in the battery power of the terminal device running the client and continuous heating, which affects the user experience and easily causes the user to directly close or even uninstall the client, resulting in a decrease in the retention rate of the client.
[0037] Therefore, how to handle the high power consumption of the client becomes a technical problem to be solved.
[0038] To solve the technical problem of high power consumption of the client, the inventor has conducted a series of studies and proposed the technical solution of the present invention. In the embodiments of the present invention, in response to a startup instruction, a first power consumption list stored locally is obtained; a power consumption list acquisition request is sent to the server to obtain a second power consumption list sent by the server that matches the device environment information of the target client; wherein, the first power consumption list includes function information of function call stacks that meet the first power consumption condition during the historical startup and operation of the target client; the second power consumption list includes function information of function call stacks that meet the second power consumption condition reported by at least one client history that matches the device environment information of the target client; according to the function information of the function call stacks in the first power consumption list and the function information of the function call stacks in the second power consumption list, it is determined whether there is a target function call stack that is simultaneously located in the first power consumption list and the second power consumption list; in the case where there is a target function call stack that is simultaneously located in the first power consumption list and the second power consumption list, the execution of the target function call stack is automatically skipped during the operation of the target client.
[0039] The target function call stack can be determined by comprehensively considering the function call stacks that meet the first power consumption condition stored locally in the target client and the function call stacks that meet the second power consumption condition reported by at least one client history statistically by the server. The target function call stack with high power consumption can be determined by combining the operation conditions of multiple clients, which can improve the accuracy of determining the target function call stack with high power consumption and reduce the risk of misjudgment. By avoiding the execution of the target function call stack with high power consumption, the problem of high power consumption of the client is solved, and the device heating caused by the operation of the client is avoided, thus affecting the user experience.
[0040] Compared with the traditional method that restricts the resources required for the client to run, such as the number of threads for the client to run, and cannot locate the specific power consumption reasons, etc., the embodiments of the present invention can locate the function call stack with high power consumption and flexibly solve the problem of high power consumption.
[0041] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties. And the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or refuse.
[0042] The following will describe in detail some embodiments of the present invention with reference to the accompanying drawings. Without conflict between the embodiments, the following embodiments and the features and steps in the embodiments can be combined with each other. In addition, the step timings in the following method embodiments are only examples and are not strictly limited.
[0043] Figure 1 It is a flowchart of an embodiment of a power consumption processing method provided by an embodiment of the present invention. The technical solution of the embodiment of the present invention can be executed by a target client. The method may include the following steps:
[0044] 101: In response to a start instruction, obtain a first power consumption list stored locally.
[0045] Among them, the first power consumption list may include function information of function call stacks that meet the first power consumption condition during the historical startup and operation process of the target client.
[0046] The function call stacks in the first power consumption list are high-power-consumption function call stacks determined by the target client.
[0047] A function call stack (Call Stack) is a data structure used to track the function call order and status during the program running process. It shows how each function is called in sequence and their hierarchical (nested) relationships. Whenever a function is called, information about the function call (such as function parameters, return address, etc.) is pushed onto the top of the stack as a stack frame; when the function execution is completed, its corresponding stack frame is popped. Many programming language runtime environments provide tools or methods that allow capturing (dumping) the function information of the function call stack of the current thread or process at any time.
[0048] The function information of the function call stack may include, for example, parameters, address information, and / or call levels, etc.
[0049] 102: Send a power consumption list acquisition request to the server to obtain a second power consumption list sent by the server that matches the device environment information of the target client.
[0050] The second power consumption list may include function information of function call stacks that meet the second power consumption condition reported by at least one client that matches the device environment information of the target client.
[0051] Among them, the server can obtain function information of function call stacks that meet the second power consumption condition reported by at least one client, and the at least one client may include the target client and the target client.
[0052] Among them, the device environment information may include client version information and terminal device information, etc. The client version information may include a client version identifier, etc. The terminal device information may refer to information about the terminal device on which the client is deployed, such as may include one or more of a terminal device model and an operating system version, etc.
[0053] 103: Determine whether there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list according to the function information of the function call stacks in the first power consumption list and the function information of the function call stacks in the second power consumption list.
[0054] 104: In the case where there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list, skip the execution of the target function call stack during the operation of the target client.
[0055] Among them, if there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list, interception can be performed at the start of each function execution during the operation of the target client, and it is judged whether the function call stack corresponding to the start of each function execution is the target function call stack, so as to skip the execution of the target function call stack.
[0056] If there is no target function call stack that is simultaneously in the first power consumption list and the second power consumption list, no function interception operation will be performed during the operation of the target client.
[0057] In this embodiment, the target function call stack can be determined by comprehensively considering the function call stacks that meet the first power consumption condition stored locally in the target client and the function call stacks that meet the second power consumption condition reported by at least one client statistically by the server. The high-power-consuming target function call stack can be determined by combining the operation conditions of multiple clients, which can improve the accuracy of determining the high-power-consuming target function call stack, reduce the risk of misjudgment, and solve the high-power consumption problem of the client by avoiding the execution of the high-power-consuming target function call stack, and avoid the device heating caused by the operation of the client from affecting the user experience.
[0058] Compared with the traditional method that restricts the resources required for the client to run, such as the number of threads for the client to run, etc., and cannot locate the specific power consumption reasons, etc., this embodiment can locate the function call stack with high power consumption and flexibly solve the problem of high power consumption.
[0059] In some embodiments, obtaining the first power consumption list stored locally in response to the start instruction may include: obtaining the first power consumption list stored locally in response to the start instruction when the energy-saving condition is met.
[0060] Among them, meeting the energy-saving condition may include: the terminal device running the target client is in the energy-saving mode and the power of the terminal device running the target client reaches the low power threshold; or, the terminal device running the target client is in the energy-saving mode; or, the power of the terminal device running the target client reaches the low power threshold.
[0061] In this embodiment, it is possible to determine whether there is a target function call stack with high power consumption for restriction when the energy-saving condition is met, and no restriction is required when the energy-saving condition is not met.
[0062] In some embodiments, the method may further include: during the historical startup and operation process, detecting the power consumption data corresponding to at least one power consumption index; determining the power consumption evaluation result according to the power consumption data corresponding to at least one power consumption index; if the power consumption evaluation result reaches the predetermined evaluation threshold, determining that the currently executed function call stack meets the first power consumption condition, saving the function information of the currently executed function call stack to the first power consumption list, and reporting the function information of the currently executed function call stack and the device environment information of the target client to the server.
[0063] Among them, during the historical startup and operation process of the target client, detecting the power consumption data corresponding to at least one power consumption index may be real-time detection or detecting the power consumption data corresponding to at least one power consumption index at regular intervals.
[0064] Among them, the larger the power consumption data corresponding to the power consumption index, the higher the power consumption of the currently executed function call stack. Compared with the traditional method, manually analyzing the power-consuming code segments can only find some obvious and static power consumption problems and cannot analyze the power consumption problems in different operating environments. This embodiment can automatically detect the power consumption data corresponding to the power consumption index in any operating environment and judge the power consumption situation of the currently executed function call stack.
[0065] Among them, the target client can obtain the power consumption data corresponding to at least one power consumption index by using the API (Application Programming Interface) of the operating system of the terminal device.
[0066] In some embodiments, determining a power consumption evaluation result based on power consumption data corresponding to at least one power consumption metric may include: obtaining a weighted sum of the power consumption data according to the predetermined weights corresponding to the at least one power consumption metric respectively to obtain the power consumption evaluation result.
[0067] Obtaining a weighted sum of the power consumption data according to the predetermined weights corresponding to the at least one power consumption metric respectively to obtain the power consumption evaluation result may include: in response to the power consumption data corresponding to a predetermined number of power consumption metrics among the at least one power consumption metric reaching the corresponding predetermined power consumption threshold, obtaining a weighted sum of the power consumption data according to the predetermined weights corresponding to the at least one power consumption metric respectively to obtain the power consumption evaluation result. That is, power consumption evaluation is only performed when the power consumption data corresponding to a predetermined number of power consumption metrics reaches the corresponding predetermined power consumption threshold.
[0068] Among them, the at least one power consumption metric may include one or more of CPU (Central Processing Unit) usage rate, memory usage rate, and I / O read and write frequency, etc. Among them, the CPU usage rate may refer to the proportion of the time when the CPU is occupied to run the target client within a predetermined time interval to the total CPU time, the memory usage rate may refer to the proportion of the physical memory used to run the target client to the total physical memory, and the I / O (Input / Output) read and write frequency may refer to the number of read and write operations of the target client per unit time.
[0069] Among them, assuming that the at least one power consumption metric includes three power consumption metrics: CPU usage rate, memory usage rate, and I / O read and write count, and assuming that the power consumption data corresponding to any two of the power consumption metrics reaches the corresponding predetermined power consumption threshold, then power consumption evaluation is performed.
[0070] For example, the CPU usage rate threshold is 70%, the I / O read and write count threshold is 100 times per millisecond, and the memory usage rate threshold is 50%. If it is detected that the CPU usage rate is 60%, the I / O read and write count is 110 times per millisecond, and the memory usage rate is 60%, then the I / O read and write count and the memory usage rate reach the corresponding predetermined power consumption threshold, and power consumption evaluation is performed.
[0071] Optionally, clients with different device environment information may set different predetermined power consumption thresholds. For example, the hardware performances of different terminal devices are different, and a higher predetermined power consumption threshold may be set for a terminal device model with higher hardware performance, etc. By flexibly configuring the predetermined power consumption threshold, it is possible to avoid excessive restrictions on the execution of the function call stack for terminal devices with higher hardware performance for running the client, and the hardware resources of the terminal device can be fully utilized.
[0072] In some embodiments, the function information of the function call stack may include the offset address of each function in the function call stack.
[0073] Determining that the currently executed function call stack meets the first power consumption condition, saving the function information of the currently executed function call stack to the first power consumption list, and reporting the function information of the currently executed function call stack and the device environment information of the target client to the server may include: determining that the currently executed function call stack meets the first power consumption condition, obtaining the running address and loading base address of each function in the currently executed function call stack; determining the offset address of each function according to the running address and loading base address of each function in the currently executed function call stack; saving the offset address of each function in the currently executed function call stack to the first power consumption list, and reporting the offset address of each function in the currently executed function call stack and the device environment information of the target client to the server.
[0074] Among them, the offset address of a function can be obtained by subtracting the loading base address of the function from the running address of the function.
[0075] During the process of client compilation and packaging, the compiler and linker generate an executable file based on the source code and library files. During this process, the position (i.e., the offset address) of each function in the executable file is determined. Once the client compilation and packaging are completed, the offset address of each function is determined accordingly and will not change during subsequent operations. Each time the client starts, the running address and loading base address of the same function may be different, and the offset address calculated according to the running address and loading base address of the function can locate the corresponding function.
[0076] In some embodiments, skipping the execution of the target function call stack during the operation of the target client may include: intercepting the currently executed function using a hook function during the operation of the target client; and skipping the execution of the target function call stack when it is determined that the function call stack corresponding to the currently executed function is the target function call stack.
[0077] Among them, the hook function can be set to intercept at the beginning of each function execution. If the function call stack corresponding to the currently executed function is the target function call stack, the execution of the target function call stack is skipped. If the function call stack corresponding to the currently executed function is not the target function call stack, the currently executed function continues to be executed, and the hook function continues to be used to intercept the next called function to determine whether the function call stack corresponding to the next called function is the target function call stack.
[0078] Suppose function A nests function B, function B nests function C, and function A - function B - function C is the target function call stack. When starting to execute function A, it is intercepted and found that the currently executing function call stack is function A, which does not belong to the target function call stack, so function A continues to be executed, and then function B is executed. It is intercepted and found that the currently executing function call stack is function A - function B, which does not belong to the target function call stack, so function B continues to be executed, and then function C is executed. It is intercepted and found that the currently executing function call stack is function A - function B - function C, which belongs to the target function call stack, so it is possible to roll back to the position before executing function A to skip the function call stack function A - function B - function C and continue to execute other functions according to the operation of the client.
[0079] Among them, it is possible to determine whether the function call stack corresponding to the currently executing function is the target function call stack according to the function information of the function call stack corresponding to the currently executing function and the function information of the target function call stack. For example, it is possible to compare the offset address of each function in the function call stack corresponding to the currently executing function with the offset address of each function in the target function call stack to determine whether the function call stack corresponding to the currently executing function is the target function call stack.
[0080] In some embodiments, in the case where there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list, skipping the execution of the target function call stack during the operation of the target client may include:
[0081] In the case where there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list and the target function call stack meets the ignore condition, skip the execution of the target function call stack during the operation of the target client.
[0082] The function call stack that meets the ignore condition may refer to a function call stack that implements non-core functions and does not affect the running stability of the target client. For example, it may include a function call stack that implements interface updates, etc.
[0083] This embodiment can avoid skipping the execution of function call stacks that implement core functions and / or affect the running stability of the client to ensure the stable operation of the client.
[0084] Figure 2 It is a flowchart of an embodiment of a power consumption processing method provided by an embodiment of the present invention. The technical solution of the embodiment of the present invention can be executed by a server, and the method may include the following steps:
[0085] 201: In response to a power consumption list acquisition request of a target client, determine function information of at least one function call stack that satisfies a second power consumption condition and is reported by the client history and matches the device environment information of the target client.
[0086] 202: Construct a second power consumption list based on the function information in the function call stack.
[0087] 203: Send the second power consumption list to the target client.
[0088] Among them, the second power consumption list can be used by the target client to determine the target function call stack that is simultaneously in the first power consumption list and the second power consumption list according to the function information in the function call stack of the first power consumption list and the function information in the function call stack of the second power consumption list, so as to skip the execution of the target function call stack during the operation of the target client.
[0089] The first power consumption list may include the function information of the function call stack that meets the first power consumption condition during the historical startup and operation of the target client.
[0090] In this embodiment, the target function call stack can be determined by comprehensively considering the function call stacks that meet the second power consumption condition reported by at least one client statistically by the server and the function call stacks that meet the first power consumption condition stored locally by the target client. The high-power consumption target function call stack can be determined by combining the operation conditions of multiple clients, which can improve the accuracy of determining the high-power consumption target function call stack, reduce the risk of misjudgment, and solve the high-power consumption problem of the client by avoiding the execution of the high-power consumption target function call stack, thus avoiding the device heating caused by the operation of the client and affecting the user experience.
[0091] In some embodiments, the method may further include: obtaining the function information and device environment information respectively corresponding to the function call stacks that meet the first power consumption condition reported by at least one client historically; counting the reporting times of the function call stacks that meet the first power consumption condition; determining that the function call stack whose reporting times reach the predetermined number meets the second power consumption condition; and saving the function information and device environment information of the function call stack that meets the second power consumption condition.
[0092] Among them, counting the reporting times of the function call stacks that meet the first power consumption condition may refer to counting the reporting times of the function call stacks with the same function information and device environment information that meet the first power consumption condition.
[0093] Among them, the server can receive and save the function information and device environment information corresponding to at least one function call stack reported by clients historically that meet the first power consumption condition. After the server receives the function information and device environment information corresponding to the function call stack reported by any client each time, it can query the function information and device environment information corresponding to the saved function call stacks. If a corresponding function call stack is found based on the function information of the currently reported function call stack and the corresponding device environment information, the reporting count of that function call stack is incremented by one. If no corresponding function call stack is found, the function information of the currently reported function call stack and the corresponding device environment information are saved to update the saved data.
[0094] In this embodiment, the function call stack with a higher reporting count among the function call stacks that meet the first power consumption condition can be determined to meet the second power consumption condition.
[0095] In some embodiments, the device environment information may include client version information and terminal device information. Obtaining the function information and device environment information corresponding to at least one function call stack reported by clients historically that meet the first power consumption condition may include: obtaining the function information corresponding to at least one function call stack reported by clients historically that meet the first power consumption condition, as well as client version information and terminal device information.
[0096] For ease of understanding, Figure 3a a schematic diagram of the reporting process of the target client's historical startup and operation in an actual application is shown.
[0097] Among them, when the target client starts historically, it can detect the power consumption data corresponding to at least one power consumption indicator. Assume that the at least one power consumption indicator includes three power consumption indicators: CPU usage rate, memory usage rate, and I / O read / write count. Assume that if the power consumption data corresponding to any two of these power consumption indicators reaches the corresponding predetermined power consumption threshold, a power consumption assessment is performed.
[0098] Furthermore, based on the predetermined weights and power consumption data corresponding to the CPU usage rate, memory usage rate, and I / O read / write count respectively, a weighted sum is calculated to obtain a power consumption assessment result. If the power consumption assessment result reaches the predetermined assessment threshold, it is determined that the currently executed function call stack meets the first power consumption condition, and the function information of the currently executed function call stack is obtained. For example, the running address and loading base address of each function in the currently executed function call stack can be obtained, and then the offset address of each function in the function call stack is calculated. The offset address of each function in the currently executed function call stack is saved to the first power consumption list, and the offset address of each function in the currently executed function call stack, the client version identification information, and the terminal device model are reported to the server.
[0099] Furthermore, the server can query the corresponding function call stack from the offset addresses of the saved function call stacks, the client version identification information, and the terminal device model according to the offset address of the currently reported function call stack, the client version identification information, and the terminal device model. Then, increment the reporting count of the function call stack by one. If the corresponding function call stack is not found, save the function information and device environment information corresponding to the currently reported function call stack to update the saved data. Furthermore, determine that the function call stacks whose reporting counts reach the predetermined count meet the second power consumption condition.
[0100] Figure 3b Fig. shows a schematic diagram of the power consumption processing flow currently started and running by the target client in an actual application.
[0101] When the target client starts, it obtains the first power consumption list stored locally and sends a power consumption list acquisition request to the server. The server can determine the function information of at least one function call stack that meets the second power consumption condition and is reported by the client history that matches the device environment information of the target client, construct a second power consumption list according to the function information of the function call stack, and send the second power consumption list to the target client.
[0102] Furthermore, the target client can determine whether there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list.
[0103] If there is no target function call stack that is simultaneously in the first power consumption list and the second power consumption list, the function interception operation will not be performed during the operation of the target client.
[0104] If there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list, during the operation of the target client, the currently executed function can be intercepted using a hook function, the offset address of each function in the function call stack corresponding to the currently executed function can be determined, and the offset address of each function in the function call stack corresponding to the currently executed function can be compared with the offset address of each function in the target function call stack to determine whether the function call stack corresponding to the currently executed function is the target function call stack. If the function call stack corresponding to the currently executed function is the target function call stack, skip the execution of the target function call stack. If the function call stack corresponding to the currently executed function is not the target function call stack, continue to execute the currently executed function, and continue to use the hook function to intercept the next called function to determine whether the function call stack corresponding to the next called function is the target function call stack.
[0105] Figure 4 Fig. is a schematic structural diagram of a power consumption processing device provided by an embodiment of the present invention. The device may include:
[0106] An acquisition module 401, configured to acquire a first power consumption list stored locally in response to a startup instruction.
[0107] A first sending module 402, configured to send a power consumption list acquisition request to a server to acquire a second power consumption list sent by the server and matching the device environment information of a target client.
[0108] A first determination module 403, configured to determine whether there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list according to the function information of the function call stack in the first power consumption list and the function information of the function call stack in the second power consumption list.
[0109] An execution module 404, configured to skip executing the target function call stack during the running of the target client if there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list.
[0110] Wherein, the first power consumption list may include function information of function call stacks that meet the first power consumption condition during the historical startup and running process of the target client. The second power consumption list may include function information of function call stacks reported by at least one client that match the device environment information of the target client and meet the second power consumption condition.
[0111] In some embodiments, the acquisition module acquiring the first power consumption list stored locally in response to a startup instruction may include: acquiring the first power consumption list stored locally in response to a startup instruction when the energy-saving condition is met.
[0112] Wherein, meeting the energy-saving condition may include: the terminal device for running the target client is in an energy-saving mode and the power of the terminal device for running the target client reaches a low power threshold; or, the terminal device for running the target client is in an energy-saving mode; or, the power of the terminal device for running the target client reaches a low power threshold.
[0113] In some embodiments, the apparatus may further include:
[0114] A detection module, configured to detect power consumption data corresponding to at least one power consumption index during the historical startup and running process; determine a power consumption evaluation result according to the power consumption data corresponding to at least one power consumption index; if the power consumption evaluation result reaches a predetermined evaluation threshold, determine that the currently executed function call stack meets the first power consumption condition, save the function information of the currently executed function call stack to the first power consumption list, and report the function information of the currently executed function call stack and the device environment information of the target client to the server.
[0115] In some embodiments, determining a power consumption evaluation result according to power consumption data corresponding to at least one power consumption indicator may include: obtaining the power consumption evaluation result by weighted summation according to the predetermined weights corresponding to at least one power consumption indicator and the power consumption data.
[0116] Obtaining the power consumption evaluation result by weighted summation according to the predetermined weights corresponding to at least one power consumption indicator and the power consumption data may include: in response to the power consumption data corresponding to a predetermined number of power consumption indicators among at least one power consumption indicator reaching the corresponding predetermined power consumption threshold, obtaining the power consumption evaluation result by weighted summation according to the predetermined weights corresponding to at least one power consumption indicator and the power consumption data.
[0117] In some embodiments, the function information of the function call stack may include the offset address of each function in the function call stack.
[0118] The above-mentioned determining that the currently executed function call stack meets the first power consumption condition, saving the function information of the currently executed function call stack to the first power consumption list, and reporting the function information of the currently executed function call stack and the device environment information of the target client to the server may include: determining that the currently executed function call stack meets the first power consumption condition, obtaining the running address and loading base address of each function in the currently executed function call stack; determining the offset address of each function according to the running address and loading base address of each function in the currently executed function call stack; saving the offset address of each function in the currently executed function call stack to the first power consumption list, and reporting the offset address of each function in the currently executed function call stack and the device environment information of the target client to the server.
[0119] In some embodiments, the execution module skipping the execution of the target function call stack during the operation of the target client may include: intercepting the currently executed function using a hook function during the operation of the target client; skipping the execution of the target function call stack when it is determined that the function call stack corresponding to the currently executed function is the target function call stack.
[0120] In some embodiments, when there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list, the execution module skipping the execution of the target function call stack during the operation of the target client may include: when there is a target function call stack that is simultaneously in the first power consumption list and the second power consumption list and the target function call stack meets the ignoring condition, skipping the execution of the target function call stack during the operation of the target client.
[0121] Figure 4 The shown device may execute Figure 1 the power consumption processing method of the shown embodiment. For parts not described in detail in this embodiment, reference may be made to Figure 1Description of the related embodiments shown. For the execution process and technical effects of this technical solution, please refer to Figure 1 the description in the embodiments shown, which will not be elaborated here.
[0122] Figure 5 The following is a schematic structural diagram of a power consumption processing device provided by an embodiment of the present invention. The device may include:
[0123] A second determination module 501, configured to determine function information of function call stacks that meet the second power consumption condition and are reported by at least one client that matches the device environment information of the target client in response to a power consumption list acquisition request of the target client;
[0124] A construction module 502, configured to construct a second power consumption list according to the function information of the function call stacks;
[0125] A second sending module 503, configured to send the second power consumption list to the target client.
[0126] Among them, the second power consumption list can be used by the target client to determine a target function call stack that is simultaneously located in the first power consumption list and the second power consumption list according to the function information of the function call stacks in the first power consumption list and the function information of the function call stacks in the second power consumption list, so as to skip the execution of the target function call stack during the operation of the target client.
[0127] The first power consumption list may include function information of function call stacks that meet the first power consumption condition during the historical startup and operation process of the target client.
[0128] In some embodiments, the device may further include:
[0129] A saving module, configured to obtain function information and device environment information corresponding to function call stacks that meet the first power consumption condition and are reported by at least one client respectively; count the reporting times of function call stacks that meet the first power consumption condition; determine that function call stacks whose reporting times reach a predetermined number meet the second power consumption condition; and save the function information and device environment information of function call stacks that meet the second power consumption condition.
[0130] This embodiment may determine function call stacks with more reporting times among function call stacks that meet the first power consumption condition as those that meet the second power consumption condition.
[0131] In some embodiments, the device environment information may include client version information and terminal device information. Obtaining function information and device environment information corresponding to function call stacks that meet the first power consumption condition and are reported by at least one client respectively may include: obtaining function information corresponding to function call stacks that meet the first power consumption condition and are reported by at least one client respectively, as well as client version information and terminal device information.
[0132] Figure 5 The device shown can execute Figure 2 the power consumption processing method of the embodiment shown. For parts not described in detail in this embodiment, reference can be made to the relevant descriptions of Figure 2 the embodiment shown. For the execution process and technical effects of this technical solution, refer to the description in Figure 2 the embodiment shown, which will not be elaborated here.
[0133] In a possible design, Figure 1 or Figure 2 the power consumption processing method provided in the embodiment shown can be applied to an electronic device, such as Figure 6 shown. The electronic device may include: a processor 61 and a memory 62. Among them, the memory 62 is used to store a program that supports the electronic device to execute the Figure 1 or Figure 2 power consumption processing method provided in the embodiment shown. The processor 61 is configured to execute the program stored in the memory 32.
[0134] The program includes one or more computer instructions. Among them, when one or more computer instructions are executed by the processor 61, the following steps can be implemented:
[0135] In response to a start instruction, obtain a first power consumption list stored locally; the first power consumption list includes function information of function call stacks that meet the first power consumption condition during the historical startup and operation of the target client;
[0136] Send a power consumption list acquisition request to the server to obtain a second power consumption list sent by the server that matches the device environment information of the target client; the second power consumption list includes function information of function call stacks that meet the second power consumption condition reported by at least one client that matches the device environment information of the target client;
[0137] According to the function information of the function call stacks in the first power consumption list and the function information of the function call stacks in the second power consumption list, determine whether there is a target function call stack that is simultaneously located in the first power consumption list and the second power consumption list;
[0138] In the case where there is a target function call stack that is simultaneously located in the first power consumption list and the second power consumption list, skip the execution of the target function call stack during the operation of the target client.
[0139] Optionally, the processor 61 is further configured to execute all or part of the steps in the foregoing Figure 1 embodiment shown.
[0140] Among them, when one or more computer instructions are executed by the processor 61, the following steps can also be implemented:
[0141] In response to a power consumption list acquisition request from a target client, determine function information of at least one function call stack that meets the second power consumption condition and is reported by a client matching the device environment information of the target client in the past;
[0142] Construct a second power consumption list according to the function information of the function call stack;
[0143] Send the second power consumption list to the target client; the second power consumption list is used for the target client to determine a target function call stack that is simultaneously in the first power consumption list and the second power consumption list according to the function information of the function call stack in the first power consumption list and the function information of the function call stack in the second power consumption list, so as to skip executing the target function call stack during the operation of the target client; the first power consumption list includes function information of function call stacks that meet the first power consumption condition during the historical startup and operation of the target client.
[0144] Optionally, the processor 61 is further configured to execute all or part of the steps in the foregoing Figure 2 illustrated embodiments.
[0145] Wherein, the structure of the electronic device may further include a communication interface 63 for the electronic device to communicate with other devices or communication systems.
[0146] In addition, an embodiment of the present invention provides a computer storage medium for storing computer software instructions used by the foregoing electronic device, which includes programs for executing the foregoing Figure 1 or Figure 2 illustrated power consumption processing methods.
[0147] In addition, an embodiment of the present invention provides a computer program product. The computer program product includes a computer program or instructions. When the computer program or instructions are executed by a processor, the processor can implement the steps or functions of the foregoing Figure 1 or Figure 2 illustrated power consumption processing methods.
[0148] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for processing power consumption, characterized in that: Applied to target clients, including: In response to the startup instruction, a first power consumption list stored locally is obtained; the first power consumption list includes function information of a function call stack that meets a first power consumption condition during the historical startup and operation process of the target client; Sending a power consumption list acquisition request to the server to acquire a second power consumption list sent by the server and matching the device environment information of the target client; the second power consumption list includes function information of a function call stack that meets the second power consumption condition and is historically reported by at least one client and matches the device environment information of the target client; Determine whether there is a target function call stack that is located in both the first power consumption list and the second power consumption list according to the function information of the function call stack in the first power consumption list and the function information of the function call stack in the second power consumption list; In the case that there is a target function call stack that is located in both the first power consumption list and the second power consumption list, the target function call stack is skipped during the running of the target client.
2. The method according to claim 1, characterized in that Also includes: During the historical startup operation, detecting power consumption data corresponding to at least one power consumption indicator; Determining a power consumption evaluation result according to the power consumption data corresponding to the at least one power consumption indicator; If the power consumption assessment result reaches a predetermined assessment threshold, it is determined that the currently executed function call stack meets the first power consumption condition, the function information of the currently executed function call stack is saved to the first power consumption list, and the function information of the currently executed function call stack and the device environment information of the target client are reported to the server.
3. The method according to claim 2, characterized in that The determining of the power consumption evaluation result according to the power consumption data corresponding to the at least one power consumption indicator comprises: The power consumption evaluation result is obtained by weighted summing according to the predetermined weight and the power consumption data respectively corresponding to the at least one power consumption indicator.
4. The method according to claim 2, characterized in that: The function information of the function call stack includes the offset address of each function in the function call stack; The determining that the currently executed function call stack meets the first power consumption condition, saving the function information of the currently executed function call stack to the first power consumption list, and reporting the function information of the currently executed function call stack and the device environment information of the target client to the server includes: Determine whether a currently executed function call stack satisfies a first power consumption condition, and obtain a running address and a loading base address of each function in the currently executed function call stack; Determine the offset address of each function according to the running address and the loading base address of each function in the currently executed function call stack; The offset address of each function in the currently executed function call stack is saved in the first power consumption list, and the offset address of each function in the currently executed function call stack and the device environment information of the target client are reported to the server.
5. The method according to claim 1, characterized in that The step of skipping the execution of the target function call stack during the operation of the target client comprises: During the operation of the target client, a hook function is used to intercept the currently executed function; When it is determined that the function call stack corresponding to the currently executed function is the target function call stack, execution of the target function call stack is skipped.
6. A method for processing power consumption, characterized in that: Applied to the server, including: In response to a power consumption list acquisition request from a target client, determining function information of a function call stack that meets a second power consumption condition and is historically reported by at least one client that matches device environment information of the target client; Constructing a second power consumption list according to the function information of the function call stack; The second power consumption list is sent to the target client; the second power consumption list is used by the target client to determine the target function call stack that is located in both the first power consumption list and the second power consumption list based on the function information of the function call stack in the first power consumption list and the function information of the function call stack in the second power consumption list, so as to skip the execution of the target function call stack during the operation of the target client; the first power consumption list includes the function information of the function call stack that meets the first power consumption condition during the historical startup and operation of the target client.
7. The method according to claim 6, characterized in that Also includes: Obtaining function information and device environment information corresponding to function call stacks that meet the first power consumption condition and are historically reported by at least one client; Counting the number of reports of the function call stack that meets the first power consumption condition; Determining that a function call stack whose reporting times reaches a predetermined number meets a second power consumption condition; The function information of the function call stack that meets the second power consumption condition and the corresponding device environment information are saved.
8. The method according to claim 7, characterized in that The step of obtaining function information and device environment information respectively corresponding to a function call stack that meets the first power consumption condition and is reported historically by at least one client comprises: Acquire function information corresponding to function call stacks that meet the first power consumption condition and are historically reported by at least one client, as well as client version information and terminal device information.
9. An electronic device, characterized in that: include: A memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the power consumption processing method described in any one of claims 1 to 5 or the power consumption processing method described in any one of claims 6 to 8.
10. A non-transitory machine-readable storage medium, characterized in that: The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor executes the power consumption processing method according to any one of claims 1 to 5 or the power consumption processing method according to any one of claims 6 to 8.