Performance optimization method and system based on interpreter and related electronic equipment
Through the interpreter insertion of pile Hook processing and dynamic adjustment of pile point strategies, the accuracy of performance optimization strategies in complex scenarios of third-party applications is solved, and the content loading speed and user experience are improved.
Patent Information
- Application Number
- CN202311871916.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2043-12-29
AI Technical Summary
The existing technology is difficult to accurately control performance optimization strategies in complex scenarios of third-party applications, resulting in slow content loading speed and poor user experience.
Through interpreter-based instrumentation Hook processing, the target pile point of the objective function is determined, and the execution timing of the performance optimization strategy is dynamically adjusted according to the pile point type (such as start pile point, delay pile point), including the preset time of the termination and start delay pile point, to ensure that the loading speed can be effectively improved in complex scenarios.
Accurately control performance optimization strategies in complex scenarios, reduce loading time and improve user experience.
Smart Images

Figure CN120276792A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the technical field of terminals, and in particular, to a performance optimization method, system, and related electronic devices based on an interpreter. Background Art
[0002] With the development of the Internet, for the convenience and entertainment of life, users download and use more and more third-party applications in the application market of electronic devices. However, for users, the content loading process of various related functions or associated applications in third-party applications is particularly important. Being able to quickly respond to user operations (such as opening a third-party application or clicking on a page), quickly load the page content and display it can bring a good user experience to users.
[0003] Since currently, when the temperature of an electronic device rises, the processor (Central Processing Unit, CPU) will automatically downclock to reduce power consumption and temperature, and the higher the temperature of the electronic device, the lower the operating frequency of the processor. Therefore, in the content loading process of third-party applications, it is easy to have situations where the page content (such as: pictures, texts, voices, or controls, etc.) takes too long to load and the relevant functions are loaded too slowly. In the prior art, usually, key functions related to the loading logic are found at the start point and end point of the content loading process as the start and end stub points to determine the time range of content loading, and then the corresponding performance optimization strategy is sent down to improve the content loading speed. However, for some scenarios with a more complex loading process (such as a content loading scenario where it is difficult to find a key function with strong logical relevance as the end stub point), the corresponding performance optimization strategy cannot be effectively sent down, resulting in the content loading speed not being improved and the user experience being poor.
[0004] Therefore, how to accurately and efficiently control the execution of corresponding performance optimization strategies for the content loading process of third-party applications in various complex scenarios to reduce the loading duration and improve the user experience is an urgent problem to be solved. Summary of the Invention
[0005] The present application provides a performance optimization method, system, and related electronic devices based on an interpreter. Among them, in the performance optimization method based on an interpreter, corresponding performance optimization strategies can be controlled and executed for various complex content loading scenarios to improve the user experience.
[0006] In a first aspect, an embodiment of the present application provides a performance optimization method based on an interpreter. The method may include: performing stub Hook processing on a target function to determine a target stub point corresponding to the target function; the target function is a function currently being interpreted and executed by the interpreter, and one target function corresponds to one target stub point; when the target function is executed, determining whether the triggering condition of the target stub point is currently satisfied; the types of the target stub points include a start stub point and a delay stub point, the start stub point is used to trigger the execution of a performance optimization strategy, the delay stub point is used to trigger an end stub point after a preset time, and the end stub point is used to trigger the end of the performance optimization strategy; if the target stub point is a delay stub point and the triggering condition corresponding to the delay stub point is satisfied, then terminate the preset time corresponding to the previously triggered delay stub point, start the preset time corresponding to the current delay stub point, and trigger the end stub point after the preset time.
[0007] In the prior art, typically at the start point and end point of the content loading process of a third-party application, key functions related to the loading logic are found as the start and end stubs, used to determine the time range of content loading, so as to issue corresponding performance optimization strategies to improve the content loading speed. However, for some scenarios with complex loading processes (such as content loading scenarios where it is difficult to find key functions with strong logical relevance as the end stubs), corresponding performance optimization strategies cannot be effectively issued, resulting in the content loading speed not being improved and poor user experience. In the embodiments of the present application, by performing stub Hook processing on the function currently being interpreted and executed by the interpreter (i.e., the target function), the corresponding target stub is determined; when the target function is executed, it is further determined whether the current situation meets the trigger condition of the target stub. Among them, the types of target stubs can include start stubs and delay stubs. Since the start stub is used to trigger the execution of the performance optimization strategy, and the delay stub is used to trigger the end stub after a preset time, and the end stub is used to trigger the end of the performance optimization strategy, for all target functions in the entire content loading process of the third-party application, there is at least one start stub and one delay stub, so as to specifically control the execution process of the performance optimization strategy during the content loading process of the application, avoid continuously executing the performance optimization strategy during the application operation, resulting in too high a temperature of the electronic device and poor performance optimization effect. Further, if the target stub is a delay stub and the trigger condition corresponding to the delay stub is met, the preset time corresponding to the previously triggered delay stub is terminated, the preset time corresponding to the current delay stub is started, and the end stub is triggered after the preset time. Therefore, in the embodiments of the present application, by terminating the preset time corresponding to the previously triggered delay stub and starting the preset time corresponding to the current delay stub when repeatedly triggering delay stubs (such as repeatedly triggering the delay stub corresponding to a target function and / or different delay stubs corresponding to different target functions), the trigger time of the end stub can be dynamically adjusted, so that in scenarios with complex loading processes (such as content loading scenarios where it is difficult to find key functions with strong logical relevance as the end stubs of the performance optimization strategy), it is not necessary to find key functions related to the loading logic as the end stubs of the performance optimization strategy, and the electronic device can still accurately execute corresponding performance optimization strategies for the content loading process, thereby reducing the loading duration to improve user experience.
[0008] In a possible implementation manner, the method further includes: obtaining function information of the function to be interpreted and executed, where the function information includes the function name of the function; based on the function information and a pre-obtained configuration file, determining whether the function is a key function, where the configuration file includes function names respectively corresponding to one or more key functions; in the case where the function is the key function, determining the function as the target function.
[0009] In an embodiment of the present application, relevant function information such as the function name of the function to be interpreted and executed can be obtained. At the same time, based on a pre-obtained configuration file, it is determined whether the function to be interpreted and executed currently is a key function. If the function is a key function, it means that the function is the trigger point of a key event during the application content loading process, and the function can be determined as the target function, so as to perform stub Hook processing on the function to determine its corresponding target stub point, so as to accurately and efficiently perform performance optimization strategies for the content loading process to improve the user experience.
[0010] In a possible implementation manner, the determining whether the function is a key function based on the function information and the pre-obtained configuration file may include: judging whether there is a function name in the configuration file that is the same as the function name of the function based on the function information and the configuration file; if so, determining that the function is the corresponding key function; if not, determining that the function is a non-key function.
[0011] In an embodiment of the present application, since the configuration file includes function names corresponding to one or more key functions, based on this configuration file and the obtained function information including the function to be interpreted and executed, it is compared and judged whether there is a function name in the configuration file that is the same as the function name of the function to be interpreted and executed. If so, it is determined that the function to be interpreted and executed is the corresponding key function; if not, it is determined that the function to be interpreted and executed is a non-key function. Through the embodiment of the present application, it can be determined whether the function to be interpreted and executed by the current interpreter (that is, the function to be interpreted and executed) is a key function by the function name, greatly improving the efficiency of confirming the key function, so as to target the content loading process during the operation of the third-party application based on this key function for positioning, so as to accurately and efficiently determine the trigger execution and end timing of the performance optimization strategy, thereby reducing the loading duration to improve the user experience.
[0012] In a possible implementation manner, the method further includes: determining the stub point information corresponding to the target stub point based on the target stub point; the stub point information includes position information, trigger conditions, and trigger rules; the position information is used to indicate the stubbing position of the target stub point in the target function, the trigger condition is used to indicate the condition for the target stub point to be triggered, and the trigger rule is used to indicate the operation to be executed when the target stub point is triggered.
[0013] In an embodiment of the present application, by determining stub point information including relevant information such as location information, trigger conditions, and trigger rules, and then based on the location information in the stub point information, the stubbing position of the target stub point in the key function (i.e., the target function) currently being interpreted and executed by the interpreter can be determined, so as to ensure that the triggering of the target stub point can accurately reflect the key time points of the content loading process; at the same time, based on the trigger conditions of the stub point information, it can be determined whether the target stub point is triggered when the corresponding target function is executed, so as to avoid the situation of the target stub point being triggered in advance or repeatedly; in addition, based on the trigger rules in the stub point information, the operations executed by the electronic device when the target stub point is triggered can be determined, thereby realizing targeted control of the electronic device to execute corresponding performance optimization strategies during the content loading process, so as to reduce the loading duration and improve the user experience.
[0014] In a possible implementation manner, when the target function is executed, determining whether the current situation meets the trigger condition of the target stub point may include: when the target function is executed, determining whether the current situation meets the trigger condition of the target stub point based on the stub point information corresponding to the target function.
[0015] In an embodiment of the present application, when the key function (i.e., the target function) currently being interpreted and executed by the interpreter is executed, through the stub point information corresponding to the target function, it can be determined whether the current situation meets the trigger condition of the corresponding target stub point, so as to determine whether the corresponding target stub point is triggered currently, so as to avoid the situation of the target stub point being triggered in advance or repeatedly, improve the accuracy of controlling the electronic device to execute corresponding performance optimization strategies for the content loading process, ensure that the target stub point is triggered at the correct time, and thus reduce the loading duration and improve the user experience.
[0016] In a possible implementation manner, the types of the target stub points further include start pre-stub points and / or delay pre-stub points; the start pre-stub points are used to change the pre-state to the start pre-state, and the delay pre-stub points are used to change the pre-state to the delay pre-state, and the pre-state is the program state before executing the target function corresponding to the target stub point.
[0017] In the embodiments of the present application, since the types of the key functions (i.e., target functions) currently being interpreted and executed by the interpreter may further include start pre-stub points and / or delay pre-stub points, the start pre-stub point can change the program state (i.e., the pre-state) before the target function corresponding to the target stub point to the start pre-state, and the pre-stub point can change the program state (i.e., the pre-state) before the target function corresponding to the target stub point to the delay pre-state. Therefore, during the entire content loading process of the third-party application, different types of target stub points can be set for the key functions according to the complexity of the actual situation, and through the free combination of different types of target stub points, it is ensured that the key events corresponding to various different content loading scenarios can be targeted, so as to more flexibly and accurately control the triggering execution and ending timing of the performance optimization strategy to adapt to various different content loading scenarios.
[0018] In a possible implementation manner, the start stub point is further configured to record the time when the performance optimization strategy is triggered to execute, and change the pre-state to the start state; the end stub point is further configured to record the time when the execution of the performance optimization strategy ends, and change the pre-state to the end state.
[0019] In the embodiments of the present application, while the start stub point can trigger the execution of the performance optimization strategy, it can also be used to record the time when the performance optimization strategy is triggered to execute, and change the program state (i.e., the pre-state) before the target function corresponding to the target stub point to the start state; the end stub point can be used to trigger the end of the performance optimization strategy, and can also be used to record the time when the execution of the performance optimization strategy ends, and change the program state (i.e., the pre-state) before the target function corresponding to the target stub point to the end state. This is beneficial to calculating the relevant dimension measurement information such as the execution duration of the performance optimization strategy through the timestamps recorded when the start stub point and the end stub point are triggered. At the same time, through the change of this pre-state, especially for the case where the loading logic is complex, it is possible to quickly determine the execution of each key event during the content loading process, which helps to more comprehensively and meticulously analyze and understand the behavior of the program in scenarios such as debugging, dimension measurement, or performance analysis, so as to further perform corresponding fault analysis or optimization to improve the user experience.
[0020] In a possible implementation manner, the performance optimization strategy includes increasing the working frequency of the processor.
[0021] The performance optimization strategy in the embodiments of the present application may include increasing the working frequency of the processor (for example, sending a frequency increase instruction to the processor) to enable quick response to user operations (such as opening a third-party application or clicking on a page) during the content loading process of the third-party application, quickly loading the page content and displaying it, thereby enhancing the user experience.
[0022] In a possible implementation, the type of the target stake point further includes the start pre-stake point; the determining whether the trigger condition of the target stake point is currently satisfied may include: if the target stake point is the start stake point, determining whether the pre-state is the start pre-state based on the stake point information corresponding to the start stake point; if so, determining that the trigger condition corresponding to the start stake point is satisfied; if not, determining that the trigger condition corresponding to the start stake point is not satisfied.
[0023] In an embodiment of the present application, when, for the entire content loading process of a third-party application, the type of all target stake points corresponding to all target functions further includes a start pre-stake point, if the target stake point corresponding to the key function (i.e., the target function) currently interpreted and executed by the interpreter is the start stake point, then it is possible to determine whether the program state (i.e., the pre-state) before the electronic device executes the target function corresponding to this start stake point (i.e., the target stake point) is the start pre-state based on the stake point information corresponding to this start stake point, so as to determine whether the trigger condition of this start stake point (i.e., the target stake point) is currently satisfied. Further, if this pre-state is the start pre-state, it can be determined that the trigger condition corresponding to this start stake point is satisfied; if this pre-state is not the start pre-state, it can be determined that the trigger condition corresponding to this start stake point is not satisfied, such that after the start pre-stake point is triggered, the start stake point can be triggered, thereby ensuring that the start stake point will not be triggered in advance during the content loading process, so as to ensure that the triggering of the start stake point can accurately reflect the start node of the content loading process and improve the positioning accuracy.
[0024] In a possible implementation, the type of the target stake point further includes the delay pre-stake point; the determining whether the trigger condition of the target stake point is currently satisfied may include: when the target stake point is the delay stake point, determining whether the pre-state is the delay pre-state based on the stake point information corresponding to the delay stake point; if so, determining that the trigger condition corresponding to the delay stake point is satisfied; if not, determining that the trigger condition corresponding to the delay stake point is not satisfied.
[0025] In an embodiment of the present application, when, for the entire content loading process of a third-party application, the types of target stubs corresponding to all target functions also include delay pre-stubs, if the target stub corresponding to the key function (i.e., the target function) currently being interpreted and executed by the interpreter is a delay stub, the instrumentation module can determine, based on the stub information corresponding to the delay stub, whether the program state (i.e., the pre-state) before the electronic device executes the target function corresponding to the delay stub (i.e., the target stub) is a delay pre-state, so as to determine whether the trigger condition of the current delay stub (i.e., the target stub) is satisfied. Further, if the pre-state is a delay pre-state, it can be determined that the trigger condition corresponding to the delay stub is satisfied; if the pre-state is not a delay pre-state, it can be determined that the trigger condition corresponding to the delay stub is not satisfied, so that the delay stub can be triggered only after the delay pre-stub is triggered, thereby ensuring that the delay stub will not be triggered in advance during the content loading process, so as to ensure that the triggering of the delay stub can accurately reflect the delay node of the content loading process and improve the accuracy of positioning.
[0026] In a possible implementation manner, the determining whether the trigger condition of the target stub is currently satisfied may include: if the target stub is the delay pre-stub, determining whether the pre-state is the start state based on the stub information corresponding to the delay pre-stub; if so, determining that the trigger condition corresponding to the delay pre-stub is satisfied; if not, determining that the trigger condition corresponding to the delay pre-stub is not satisfied.
[0027] In an embodiment of the present application, if the target stub corresponding to the key function (i.e., the target function) currently being interpreted and executed by the interpreter is a delay pre-stub, it can be determined, based on the stub information corresponding to the delay pre-stub, whether the program state (i.e., the pre-state) before the electronic device executes the target function corresponding to the delay pre-stub (i.e., the target stub) is the start state, so as to determine whether the trigger condition of the current delay pre-stub (i.e., the target stub) is satisfied. Further, if the pre-state is the start state, it can be determined that the trigger condition corresponding to the delay pre-stub is satisfied; if the pre-state is not the start state, it can be determined that the trigger condition corresponding to the delay pre-stub is not satisfied, so that the delay pre-stub can be triggered only after the start stub is triggered, thereby ensuring that the delay pre-stub will not be triggered in advance during the content loading process, so as to ensure that the triggering of the delay pre-stub can accurately reflect the delay pre-node of the content loading process and improve the accuracy of positioning.
[0028] In a possible implementation, the method further includes: if the target stake point is the start pre-stake point and the triggering condition corresponding to the start pre-stake point is satisfied, changing the pre-state to the start pre-state; if the target stake point is the start stake point and the triggering condition corresponding to the start stake point is satisfied, triggering the execution of the performance optimization strategy, recording the time when the performance optimization strategy is triggered, and changing the pre-state to the start state; if the target stake point is the delay pre-stake point and the triggering condition corresponding to the delay pre-stake point is satisfied, changing the pre-state to the delay pre-state.
[0029] In an embodiment of the present application, when the target staking point corresponding to the key function (i.e., the target function) currently being interpreted and executed by the interpreter is the start pre-staking point, and the trigger condition corresponding to the start pre-staking point is satisfied, the electronic device changes the program state (i.e., the pre-state) before the target function corresponding to the start pre-staking point (i.e., the target staking point) to the start pre-state, so as to ensure that the start pre-staking point (including the start pre-staking point corresponding to one target function and / or different start pre-staking points corresponding to different target functions) will not be repeatedly triggered during the content loading process. That is, the start pre-staking point can only be triggered once during the entire content loading process, thereby ensuring that the triggering of the start pre-staking point can accurately reflect the start pre-node of the content loading process and improving the positioning accuracy. When the target staking point corresponding to the key function (i.e., the target function) currently being interpreted and executed by the interpreter is the start staking point, and the trigger condition corresponding to the start staking point is satisfied, the electronic device triggers the execution of the performance optimization strategy and records the time when the performance optimization strategy is triggered, so as to quickly determine the start time and other maintenance measurement information of the performance optimization strategy in the maintenance measurement scenario, and further perform corresponding fault analysis or optimization to improve the user experience. In addition, the electronic device also changes the program state (i.e., the pre-state) before the target function corresponding to the start staking point (i.e., the target staking point) to the start state, so as to ensure that the start staking point (including the start staking point corresponding to one target function and / or different start staking points corresponding to different target functions) will not be repeatedly triggered during the content loading process. That is, the start staking point can only be triggered once during the entire content loading process, thereby ensuring that the triggering of the start staking point can accurately reflect the start node of the content loading process. When the target staking point corresponding to the key function (i.e., the target function) currently being interpreted and executed by the interpreter is the delay pre-staking point, and the trigger condition corresponding to the delay pre-staking point is satisfied, the electronic device changes the program state (i.e., the pre-state) before the target function corresponding to the delay pre-staking point (i.e., the target staking point) to the delay pre-state, so as to ensure that the delay pre-staking point (including the delay pre-staking point corresponding to one target function and / or different delay pre-staking points corresponding to different target functions) will not be repeatedly triggered during the content loading process. That is, the delay pre-staking point can only be triggered once during the entire content loading process, thereby ensuring that the triggering of the delay pre-staking point can accurately reflect the delay pre-node of the content loading process and improving the positioning accuracy.
[0030] In a possible implementation, if the target stake point is a delay stake point and the triggering condition corresponding to the delay stake point is satisfied, terminating the preset time corresponding to the last triggered delay stake point, starting the preset time corresponding to the current delay stake point, and triggering the end stake point after the preset time may include: if the target stake point is the delay stake point and the triggering condition corresponding to the delay stake point is satisfied, sending delay information, where the delay information is used to trigger the end stake point after the preset time; during the preset time when the delay message is waiting in the message queue and during the process of executing the next target function, continuously determining whether the triggering condition of the delay stake point is currently satisfied; if satisfied, removing the previously sent delay message from the message queue, simultaneously sending the latest delay message, and updating the latest delay message to the message queue; if not satisfied, triggering the end stake point after the preset time of the delay message has passed.
[0031] In the embodiment of the present application, when the target stake point corresponding to the key function (i.e., the target function) currently being interpreted and executed by the interpreter is a delay stake point and the triggering condition corresponding to the delay stake point is satisfied, delay information that can be used to trigger the end stake point after a preset time (e.g., 500 ms) can be sent. Further, during the preset time (e.g., 500 ms) when the delay message is waiting in the message queue and during the process of executing the next target function, continuously determine whether the triggering condition of the delay stake point is currently satisfied. If satisfied, remove the previously sent delay message from the message queue, simultaneously send the latest delay message, and update the latest delay message to the message queue, so as to achieve that when the delay stake point is repeatedly triggered (e.g., repeatedly triggering the delay stake point corresponding to a target function and / or different delay stake points corresponding to different target functions), terminate the preset time corresponding to the last triggered delay stake point, start the preset time corresponding to the current delay stake point, and trigger the end stake point to end the execution of the performance optimization strategy when the delay stake point is not triggered again before the preset time (e.g., 500 ms) ends. Through the embodiment of the present application, the triggering time of the end stake point can be continuously and dynamically adjusted, so that in a scenario where the loading process is relatively complex (e.g., a content loading scenario where it is difficult to find a key function with strong logical relevance as the content of the end stake point of the performance optimization strategy), it is not necessary to find a key function related to the loading logic as the end stake point of the performance optimization strategy, and the electronic device can accurately execute the corresponding performance optimization strategy for the content loading process, thereby reducing the loading duration to improve the user experience.
[0032] In a possible implementation, the end staking point is further configured to record the time when the performance optimization strategy ends and change the pre-state to an end state; the method further includes: when the end staking point is triggered, trigger the end of the performance optimization strategy, record the time when the performance optimization strategy ends, and change the pre-state to the end state.
[0033] In the embodiments of the present application, the end staking point can also be used to record the time when the performance optimization strategy ends and change the program state (i.e., the pre-state) before executing the target function corresponding to the target staking point from the start state to the end state. Correspondingly, when the end staking point is triggered, the electronic device triggers the end of the execution of the performance optimization strategy, records the time when the execution of the performance optimization strategy ends, and changes the program state (i.e., the pre-state) before executing the target function corresponding to the target staking point to the end state, so as to ensure that the triggering of the end staking point can accurately reflect the end node of the content loading process. Further, when the electronic device ends the execution of the performance optimization strategy, recording the time when the execution of the performance optimization strategy is triggered is beneficial to monitoring the process of the electronic device executing the performance optimization strategy, so as to quickly determine the end time and other monitoring information of the performance optimization strategy, which is convenient for corresponding fault analysis or optimization in the monitoring scenario of the third-party application, so as to improve the user experience.
[0034] In a second aspect, the embodiments of the present application provide a performance optimization system based on an interpreter, and the system includes an instrumentation module and a performance management module; the instrumentation module is configured to: perform instrumentation Hook processing on a target function to determine a target staking point corresponding to the target function; the target function is the function currently being interpreted and executed by the interpreter, and one target function corresponds to one target staking point; when the target function is executed, determine whether the triggering condition of the target staking point is currently satisfied; the types of the target staking points include a start staking point and a delay staking point, the start staking point is used to trigger the execution of the performance optimization strategy, the delay staking point is used to trigger the end staking point after a preset time, and the end staking point is used to trigger the end of the performance optimization strategy; the performance management module is configured to: if the target staking point is a delay staking point and the triggering condition corresponding to the delay staking point is satisfied, terminate the preset time corresponding to the previous triggered delay staking point, start the preset time corresponding to the current delay staking point, and trigger the end staking point after the preset time.
[0035] Through the embodiments of the present application, when the delay stub points can be repeatedly triggered (for example, repeatedly trigger the delay stub points corresponding to a target function and / or different delay stub points corresponding to different target functions), the preset time corresponding to the previous triggered delay stub point is terminated, and the preset time corresponding to the current delay stub point is started, so as to dynamically adjust the triggering time of the end stub point, such that in a scenario where the loading process is relatively complex (for example, a content loading scenario where it is difficult to find a key function with strong logical relevance as the content of the end stub point of the performance optimization strategy), there is no need to find a key function related to the loading logic as the end stub point of the performance optimization strategy, and the electronic device can also accurately control the execution of the corresponding performance optimization strategy for the content loading process, thereby reducing the loading duration to improve the user experience.
[0036] In a possible implementation manner, the stub insertion module is further configured to: obtain function information of a function to be interpreted and executed, where the function information includes the function name of the function; based on the function information and a pre-obtained configuration file, determine whether the function is a key function, where the configuration file includes function names respectively corresponding to one or more key functions; and in the case where the function is the key function, determine that the function is the target function.
[0037] In a possible implementation manner, the stub insertion module is specifically configured to: based on the function information and the configuration file, determine whether there is a function name in the configuration file that is the same as the function name of the function; if so, determine that the function is the corresponding key function; if not, determine that the function is a non-key function.
[0038] In a possible implementation manner, the stub insertion module is further configured to: based on the target stub point, determine stub point information corresponding to the target stub point; the stub point information includes position information, a trigger condition, and a trigger rule; the position information is used to indicate the stub insertion position of the target stub point in the target function, the trigger condition is used to indicate the condition for the target stub point to be triggered, and the trigger rule is used to indicate the operation to be executed when the target stub point is triggered.
[0039] In a possible implementation manner, the stub insertion module is specifically configured to: when the target function is executed, determine whether the current situation meets the trigger condition of the target stub point based on the stub point information corresponding to the target function.
[0040] In a possible implementation manner, the type of the target stub point further includes a start pre-stub point and / or a delay pre-stub point; the start pre-stub point is used to change the pre-state to a start pre-state, and the delay pre-stub point is used to change the pre-state to a delay pre-state, where the pre-state is the program state before executing the target function corresponding to the target stub point.
[0041] In a possible implementation manner, the start stake point is further used to record the time when the performance optimization policy is triggered to be executed, and change the pre-state to the start state; the end stake point is further used to record the time when the execution of the performance optimization policy ends, and change the pre-state to the end state.
[0042] In a possible implementation manner, the performance optimization policy includes increasing the working frequency of the processor.
[0043] In a possible implementation manner, the type of the target stake point further includes the start pre-stake point; the stake insertion module is specifically configured to: if the target stake point is the start stake point, judge whether the pre-state is the start pre-state based on the stake point information corresponding to the start stake point; if so, judge that the trigger condition corresponding to the start stake point is satisfied; if not, judge that the trigger condition corresponding to the start stake point is not satisfied.
[0044] In a possible implementation manner, the type of the target stake point further includes the delay pre-stake point; the stake insertion module is specifically configured to: if the target stake point is the delay stake point, judge whether the pre-state is the delay pre-state based on the stake point information corresponding to the delay stake point; if so, judge that the trigger condition corresponding to the delay stake point is satisfied; if not, judge that the trigger condition corresponding to the delay stake point is not satisfied.
[0045] In a possible implementation manner, the stake insertion module is specifically configured to: if the target stake point is the delay pre-stake point, judge whether the pre-state is the start state based on the stake point information corresponding to the delay pre-stake point; if so, judge that the trigger condition corresponding to the delay pre-stake point is satisfied; if not, judge that the trigger condition corresponding to the delay pre-stake point is not satisfied.
[0046] In a possible implementation manner, the performance management module is further configured to: if the target stake point is the start pre-stake point and the trigger condition corresponding to the start pre-stake point is satisfied, change the pre-state to the start pre-state; if the target stake point is the start stake point and the trigger condition corresponding to the start stake point is satisfied, trigger the execution of the performance optimization policy, record the time when the performance optimization policy is triggered to be executed, and change the pre-state to the start state; if the target stake point is the delay pre-stake point and the trigger condition corresponding to the delay pre-stake point is satisfied, change the pre-state to the delay pre-state.
[0047] In a possible implementation manner, the performance management module is specifically configured to: if the target stake point is the delay stake point and the trigger condition corresponding to the delay stake point is satisfied, send delay information, where the delay information is used to trigger the end stake point after the preset time; during the preset time when the delay message is waiting in the message queue and during the process of executing the next target function, continue to determine whether the trigger condition of the current delay stake point is satisfied; if satisfied, remove the previously sent delay message in the message queue, send the latest delay message at the same time, and update the latest delay message to the message queue; if not satisfied, trigger the end stake point after the preset time of the delay message has elapsed.
[0048] In a possible implementation manner, the end stake point is further used to record the time when the performance optimization strategy ends and change the pre - state to the end state; the performance management module is further configured to: when the end stake point is triggered, trigger the end of the performance optimization strategy, record the time when the performance optimization strategy ends at the same time, and change the pre - state to the end state.
[0049] In a third aspect, an embodiment of the present application provides an electronic device, which may include a memory and a processor. Among them, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the routing device executes the method described in any one of the possible implementation manners in the first aspect above.
[0050] In a fourth aspect, an embodiment of the present application provides a computer - readable storage medium, which stores a computer program, and the computer program is executed by the processor to implement the method described in any one of the possible implementation manners in the first aspect above.
[0051] In a fifth aspect, the present application provides a computer program product. When the computer program product runs on a computer, the computer is enabled to execute the method described in any one of the possible implementation manners in the first aspect above.
[0052] It can be understood that the system provided in the second aspect, the electronic device provided in the third aspect, the computer - readable storage medium provided in the fourth aspect, and the computer program product provided in the fifth aspect are all used to execute the method provided in the embodiments of the present application. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method, and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background technology, the drawings required to be used in the embodiments of the present application or the background technology will be described below.
[0054] Figures 1 to 4 It is a schematic diagram of the user interface of a group of electronic devices provided by an embodiment of the present application.
[0055] Figure 5 It is a schematic diagram of the operation of a third-party application provided by an embodiment of the present application.
[0056] Figure 6 It is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application.
[0057] Figure 7 It is a block diagram of the software structure of an electronic device provided by an embodiment of the present application.
[0058] Figure 8 It is a block diagram of the software structure of another electronic device provided by an embodiment of the present application.
[0059] Figure 9 It is a schematic diagram of the process of the stub Hook method provided by an embodiment of the present application.
[0060] Figure 10 It is a schematic diagram of the process of the performance optimization method based on an interpreter provided by an embodiment of the present application.
[0061] Figure 11 It is a specific schematic diagram of the process of the performance optimization method based on an interpreter provided by an embodiment of the present application.
[0062] Figure 12 It is a schematic diagram of the stub point trigger process in a performance optimization method provided by an embodiment of the present application.
[0063] Figure 13 It is a schematic diagram of the delayed stub point trigger process provided by an embodiment of the present application.
[0064] Figure 14 It is a schematic diagram of a dynamic search end point provided by an embodiment of the present application.
[0065] Figure 15 It is a schematic diagram of the process of identifying and processing delayed messages through a switch structure provided by an embodiment of the present application.
[0066] Figure 16 It is a schematic diagram of the structure of a performance optimization device provided by an embodiment of the present application.
[0067] Figure 17 It is a schematic diagram of the hardware structure of another electronic device provided by an embodiment of the present application. Detailed implementation manner
[0068] The technical solutions in the embodiments of the present application will be clearly and elaborately described below with reference to the accompanying drawings. Among them, in the description of the embodiments of the present application, unless otherwise specified, " / " means "or". For example, A / B may represent A or B. The "and / or" in the text is merely a description of the association relationship between associated objects, indicating that there can be three relationships. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present application, "a plurality of" means two or more than two.
[0069] In the following embodiments of the present application, the term "user interface (UI)" is a media interface for interaction and information exchange between an application or an operating system and a user, and it realizes the conversion between the internal form of information and the form acceptable to the user. The user interface of an application is source code written in a specific computer language such as Java or Extensible Markup Language (XML). The interface source code is parsed and rendered on an electronic device and finally presented as content recognizable by the user, such as controls like pictures, texts, and buttons. A control is also called a widget and is a basic element of the user interface. Typical controls include a toolbar, a menubar, a text box, a button, a scrollbar, pictures, and texts. The attributes and content of the controls in the interface are defined through tags or nodes. For example, XML passes through <textview> 、 <imgview> 、 <videoview>Nodes such as these are used to specify the controls included in the interface. One node corresponds to one control or property in the interface, and after being parsed and rendered, the node presents as visible content to the user. In addition, in the interfaces of many applications, such as hybrid applications, there are usually web pages included. A web page, also known as a page, can be understood as a special control embedded in the application interface. A web page is source code written in a specific computer language, such as hyper text markup language (HTML), cascading style sheets (CSS), JavaScript (JS), etc. The web page source code can be loaded and displayed as recognizable content to the user by a browser or a web page display component similar to the browser in function. The specific content included in the web page is also defined by tags or nodes in the web page source code. For example, HTML uses 、 、 <video> 、 <canvas>Define the elements and attributes of a web page.
[0070] A commonly used form of the user interface is the graphical user interface (GUI), which refers to the user interface related to computer operations displayed in a graphical manner. It can be an interface element such as an icon, window, or control displayed on the display screen of an electronic device, where the control can include visible interface elements such as icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, and Widgets.
[0071] In addition, the following also introduces an electronic device, a user interface for such an electronic device, and embodiments for using such an electronic device. In some embodiments, the electronic device can be a portable electronic device that also includes other functions such as message management, message reception, and push functions, such as a mobile phone, a tablet computer, a wearable electronic device with wireless communication functions (such as a smart watch), etc. Exemplary embodiments of the portable electronic device include, but are not limited to, those equipped with or other operating systems. The above portable electronic device can also be other portable electronic devices, such as a laptop computer (Laptop) with a touch-sensitive surface or a touch panel. It should also be understood that in some other embodiments, the above electronic device may not be a portable electronic device, but a desktop computer or an in-vehicle computer with a touch-sensitive surface or a touch panel. It can be understood that the embodiments of the present application are described by taking a smart phone as an example, but are not limited to smart phones, and can also be other intelligent devices with communication functions, such as smart watches, smart bracelets, and so on.
[0072] To facilitate the understanding of the embodiments of the present application, the following specifically analyzes the technical problems to be solved by the embodiments of the present application.
[0073] With the development of the Internet, for the convenience and entertainment of life, users are downloading and using more and more third-party software in the application market of electronic devices. However, for users, the content loading process of various related functions or associated applications in third-party applications is particularly important. Being able to quickly respond to user operations (such as opening a third-party application or clicking on a page), quickly load the page content and display it can bring a better user experience to users.
[0074] Please refer to Appendix Figure 1 to Appendix Figure 4 , Figures 1 to 4 which are schematic diagrams of the user interfaces of a group of electronic devices provided by the embodiments of the present application.
[0075] First, the electronic device can display a user interface as shown in Figure 1 , and such as Figure 1 The user interface shown is a user interface for entering the mini program through WeChat. The user interface may include one or more third-party applications (for example, shopping mini program 101). The user can click (or other user operations) the shopping mini program 101. In the case where the content loading time is very short, the electronic device can quickly respond to the user's click operation and display the following: Figure 2 The user interface shown in Figure 2 The user interface shown is the application display interface of the shopping applet 101 (that is, a third-party application). Figure 2 As shown, when the user clicks on application 1022 among multiple applications (such as various applications shown in display area 102) in the third-party application in the application display interface, the third application will load the corresponding page content to be displayed in the electronic device, presenting as shown in FIG. Figure 3 The user interface shown.
[0076] Currently, third-party applications often display Figure 3 Before the user interface shown in the figure, the electronic device will first display the following Figure 4 The user interface shown in the figure Figure 4 The user interface shown is a user interface for loading content of the shopping applet 101 (ie, a third-party application), such as Figure 4 As shown, the length of time the user interface is displayed can directly affect the user's usage experience. The shorter the display time of the user interface, the better the user experience.
[0077] For example, please refer to the following Table 1, which is a table of content loading time of third-party applications running on different electronic devices at different temperatures in the prior art provided by an embodiment of the present application.
[0078] Table 1
[0079]
[0080] As shown in Table 1 above, the content loading time of third-party applications (such as shopping applets) running on different electronic devices will increase with the increase of temperature. This is because when the temperature of the electronic device increases, the processor (Central Processing Unit, CPU) will automatically reduce the frequency to reduce power consumption and temperature. The higher the temperature of the electronic device, the lower the operating frequency of the processor. Therefore, the content loading time of the third-party application is longer, and the corresponding above Figure 4 The longer the user interface is displayed, the worse the user experience will be. Therefore, it is necessary to shorten the above Figure 4 The display time of the shown user interface is to enhance the user experience. It can be understood that the above - shown user interface is only an exemplary loading application interface of a third - party application, and different loading application interfaces can be presented for different third - party applications, which does not constitute a limitation of the embodiments of the present application.
[0081] Generally, the operation of a third - party application does not involve relevant operation events of the operating system in the electronic device. Please refer to the appendix Figure 5 , Figure 5 FIG. is a schematic diagram of the operation of a third - party application provided by an embodiment of the present application. As Figure 5 shown, when a third - party application is running, it is often a set of multiple functions running. By using the key functions related to the loading logic as the starting point and the ending point of the content loading process, based on this, frequency modulation optimization is started. In the prior art, when a third - party application performs content loading, the working frequency of the corresponding processor is higher than the working frequency of the processor during the initial operation, so as to shorten the content loading time and improve the user experience. However, for some scenarios where the loading process is relatively complex (such as a content loading scenario where it is difficult to find key functions with strong logical relevance as the ending point), this solution cannot effectively issue corresponding performance optimization strategies, resulting in the content loading speed not being improved and the user experience being poor. Therefore, the embodiments of the present application provide a performance optimization method based on an interpreter and related electronic devices, which can dynamically adjust the trigger time of the ending stubs, so that in a scenario where the loading process is relatively complex (such as a content loading scenario where it is difficult to find key functions with strong logical relevance as the ending stubs), without finding key functions related to the loading logic as the ending stubs of the performance optimization strategy, it can accurately control the electronic device to execute corresponding performance optimization strategies for the content loading process to improve the performance of the processor, thereby shortening the loading time of a certain page content in the third - party application and enhancing the user experience.
[0082] Among them, for the specific implementation manner of this method, please refer to the detailed description of the following related embodiments, and the embodiments of the present application will not elaborate here for the time being.
[0083] First, by way of example, taking the electronic device 100 as an example, the above - mentioned Figures 1 - 4 shown electronic device will be introduced.
[0084] Please refer to the appendix Figure 6 , Figure 6 FIG. is a schematic hardware structure diagram of an electronic device provided by an embodiment of the present application.
[0085] The following takes the electronic device 100 as an example to specifically illustrate the embodiments. It should be understood that the electronic device 100 is a smart terminal device and can be of various types, and the specific type thereof is not limited in the embodiments of the present application. For example, the electronic device can be a mobile phone, and can also include a tablet computer, a desktop computer, a desktop computer with a touch-sensitive surface or a touch panel, a laptop, a handheld computer, a notebook computer, a smart screen, a wearable device (such as a smart watch, a smart bracelet, etc.), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a car machine, a smart headset, a game console, and can also be an Internet of Things (IOT) device or a smart home device such as a smart water heater, a smart lamp, a smart air conditioner, etc.
[0086] The electronic device 100 may include: a processor 101, a memory 102, a wireless communication module 103, a mobile communication module 104, an antenna 103A, an antenna 104A, a power switch 105, a sensor module 106, a focusing motor 107, a camera 108, a display screen 109, a display screen controller 110, a power management module 111, a battery 112, etc. Among them, the sensor module 106 may include a gyroscope sensor 106A, an acceleration sensor 106B, an ambient light sensor 106C, an image sensor 106D, a distance sensor 106E, etc. Among them, the wireless communication module 103 may include a WLAN communication module, a Bluetooth communication module, etc. The above-mentioned multiple parts can transmit data through a bus.
[0087] The processor 101 is the control center of the electronic device 100, connecting various parts of the entire electronic device 100 through various interfaces and circuits. By running or executing software programs and / or modules stored in the memory 102, and by calling the data stored in the memory 102, it performs various functions of the electronic device 100 and processes data, thereby exercising overall control over the electronic device 100. Optionally, the processor 101 may include one or more processing units. For example, the processor 101 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.
[0088] The memory 102 can be used to store software programs and modules. The processor 101 executes various functional applications and data processing of the electronic device 100 by running the software programs and modules stored in the memory 102. The memory 102 may include, but is not limited to, a Read Only Memory (ROM), a Static Random Access Memory (SRAM), a Synchronous Dynamic Random Access Memory (SDRAM), or a Random Access Memory (RAM), etc. Further, the memory 102 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.); the data storage area may store data created according to the use of the electronic device 100 (such as audio data, a phone book, etc.).
[0089] The wireless communication function of the electronic device 100 can be implemented through the antenna 103A, the antenna 104A, the mobile communication module 104, the wireless communication module 103, the modem processor, and the baseband processor, etc.
[0090] Antennas 103A and 104A can be used for transmitting and receiving electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas.
[0091] The mobile communication module 104 can provide solutions for wireless communications such as 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 104 can include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 104 can receive electromagnetic waves by the antenna 104A, filter, amplify and process the received electromagnetic waves, and then transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 104 can also amplify the signal modulated by the modulation and demodulation processor and convert it into electromagnetic waves through the antenna 104A for radiation.
[0092] The modulation and demodulation processor can include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Subsequently, the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs a sound signal through the audio device, or displays an image or video through the display screen 109.
[0093] The wireless communication module 103 can provide solutions for wireless communications such as wireless local area networks (WLAN), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc. applied to the electronic device 100. The wireless communication module 103 can be one or more devices integrating at least one communication processing module. The wireless communication module 103 receives electromagnetic waves via the antenna 103A, frequency-modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 101. The wireless communication module 103 can also receive the signal to be transmitted from the processor 101, frequency-modulate and amplify it, and convert it into electromagnetic waves through the antenna 103A for radiation.
[0094] The power switch 105 can be used to control the power supply to the electronic device 100.
[0095] The gyroscope sensor 106A can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyroscope sensor 106A. The gyroscope sensor 106A can be used for anti-shake shooting. Exemplarily, when the shutter is pressed, the gyroscope sensor 106A detects the angle of jitter of the electronic device 100, calculates the distance that the lens module needs to compensate according to the angle, and makes the lens offset the jitter of the electronic device 100 through reverse movement to achieve anti-shake. The gyroscope sensor 106A can also be used for navigation and somatosensory game scenarios.
[0096] The acceleration sensor 106B can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device. For example, the acceleration sensor 106B can be applied to applications such as horizontal and vertical screen switching and pedometers.
[0097] The ambient light sensor 106C is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 109 according to the sensed ambient light brightness. The ambient light sensor 106C can also be used to automatically adjust the white balance when taking pictures.
[0098] The image sensor 106D, also known as the photosensitive element, can convert the optical image on the photosensitive surface into an electrical signal in a corresponding proportional relationship with the optical image by using the photoelectric conversion function of optoelectronic devices. The image sensor can be a charge coupled device (CCD) sensor or a complementary metal-oxide-semiconductor (CMOS) sensor.
[0099] The distance sensor 106E can be used to measure distance. The electronic device 100 can measure distance through infrared or laser. In some shooting scenarios, the electronic device 100 can use the distance sensor 106E to measure distance to achieve rapid focusing.
[0100] The focusing motor 107 can be used for rapid focusing. The electronic device 100 can control the movement of the lens through the focusing motor 107 to achieve automatic focusing.
[0101] The electronic device 100 can achieve the shooting function through the ISP, camera 108, video codec, GPU, display screen 109, application processor, etc.
[0102] The ISP is used to process the data fed back by the camera 108. For example, when taking a photo, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also optimize the noise and brightness of the image through algorithms. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be provided in the camera 108.
[0103] The camera 108 can be used to capture still images or videos. An object generates an optical image through the lens and projects it onto the image sensor. The image sensor can convert the light signal into an electrical signal and then transmit the electrical signal to the ISP to be converted into a digital image signal. The ISP can output the digital image signal to the DSP for processing. The DSP converts the digital image signal into a standard image signal in formats such as RGB and YUV. In some embodiments, the electronic device 100 may include one or N cameras 108, where N is a positive integer greater than 1.
[0104] The video codec is used to compress or decompress digital images. The electronic device 100 can support one or more image codecs. In this way, the electronic device 100 can open or save pictures or videos in multiple encoding formats.
[0105] The electronic device 100 can achieve the display function through the GPU, the display screen 109, the application processor, etc. The GPU is a microprocessor for image processing, connected to the display screen 109 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 101 may include one or more GPUs, which execute program instructions to generate or change the display information.
[0106] The display screen 109 is used to display images, videos, etc. The display screen 109 includes a display panel. The display panel can adopt a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 109, where N is a positive integer greater than 1.
[0107] The display screen controller 110, which may also be referred to as the display screen IC controller (Integrated Circuit Controller), may be used to control the image display, brightness, color and other parameters on the display screen 109. The display screen controller 110 may be an electronic chip or an integrated circuit, which controls and manages the parameters of the display screen 109 to control the hardware functions of the display screen, such as adjusting the display screen brightness, rendering images and generating final image output. In some embodiments, the GPU may be integrated on the same chip as the display screen controller 110, but the functions are separate. Among them, the GPU can perform image calculations, and the display screen controller 110 manages the hardware characteristics of the display screen 109.
[0108] The power management module 111 can manage the power supply and power consumption of the electronic device 100 by connecting to the battery 112, detecting the state of the battery 112 and controlling the charging and discharging process, and ensure the safe and efficient use of the battery 112. In addition, the power management module 111 can also control the electronic device 100 to enter the sleep mode, turn off the display screen 109 by sending corresponding instructions to the display screen controller 110, and wake up the device when the electronic device 100 needs to resume normal operation to reduce power consumption.
[0109] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0110] See also Figure 7 , Figure 7 It is a software structure block diagram of an electronic device provided in an embodiment of the present application.
[0111] like Figure 7 As shown, the software structure diagram can be applied to the above Figure 6 In the hardware architecture of the electronic device 100 shown, the layered architecture can divide the software in the electronic device 100 into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In other embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer (also referred to as the application management layer in the embodiment of the present application), the Android runtime (Android runtime) and the system library, and the kernel layer.
[0112] The application layer can include a series of application packages.
[0113] like Figure 7 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, running health, etc.
[0114] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions.
[0115] In some embodiments, the application framework layer may obtain a configuration file, which includes function names corresponding to one or more key functions. Based on this configuration file, it can be used to determine whether a function is a key function when an application calls the function and perform stub Hook processing.
[0116] Such as Figure 7 As shown, the application framework layer may include a display manager, a sensor manager, a cross-device connection manager, an event manager, an activity manager, a window manager, a content provider, a view system, a resource manager, a notification manager, etc.
[0117] The display manager is used for the display management of the system, responsible for managing all display-related matters, including creation, destruction, orientation switching, size and status changes, etc. Generally, there will be only one default display module on a single device, that is, the main display module.
[0118] The sensor manager is responsible for the status management of sensors and manages applications to monitor sensor events and report the events to the applications in real time.
[0119] The cross-device connection manager is used to establish communication connections with other devices.
[0120] The event manager is used for the event management service of the system, responsible for receiving events uploaded from the bottom layer and distributing them to each window, and completing tasks such as event reception and distribution.
[0121] The task manager is used for the management of task (Activity) components, including start management, life cycle management, task direction management, etc.
[0122] The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc. The window manager is also responsible for window display management, including management related to window display mode, display size, display coordinate position, display hierarchy, etc.
[0123] For the specific execution processes of the above various embodiments, reference may be made to the relevant content of the human-computer dialogue method in the following text.
[0124] The content provider is used to store and retrieve data and make this data accessible to applications. The data may include videos, images, audio, incoming and outgoing calls, browsing history and bookmarks, phone books, etc.
[0125] The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures.
[0126] The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, and so on.
[0127] The notification manager enables applications to display notification information in the status bar. It can be used to convey informative messages, which can disappear automatically after a short stay without user interaction. For example, the notification manager is used to inform that the download is complete, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as the notification of a background-running application, or a notification that appears in the form of a dialogue window on the screen. For example, it can prompt text information in the status bar, emit a prompt sound, vibrate the electronic device, blink the indicator light, etc.
[0128] The Android Runtime includes core libraries and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0129] The core libraries consist of two parts: one part is the functional functions that need to be called by the Java language, and the other part is the core libraries of Android.
[0130] Both the application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files, provides an isolated running environment, is responsible for loading, interpreting or compiling program code, and performing corresponding operations. The virtual machine is used to execute functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0131] The system libraries (also known as the data management layer) can include multiple functional modules. For example: Hardware Abstraction Layer (HAL), surface manager, Media Libraries, 3D graphics processing libraries (such as: OpenGL ES), 2D graphics engine (such as: SGL), and event data, etc.
[0132] The Hardware Abstraction Layer (HAL) can be used to provide an abstract interface for specific hardware devices, such as providing an abstract interface for hardware for virtual machines, etc., so that the programs running on it can be independent of the underlying hardware.
[0133] The Surface Manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
[0134] The Media Library supports the playback and recording of a variety of common audio and video formats, as well as static image files, etc. The Media Library can support a variety of audio and video coding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0135] The 3D Graphics Processing Library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing, etc.
[0136] The 2D Graphics Engine is a drawing engine for 2D drawing.
[0137] The Kernel Layer is the layer between hardware and software. The Kernel Layer at least includes a display driver, a camera driver, an audio driver, and a sensor driver.
[0138] In a possible implementation manner, please refer to the attached Figure 8 , Figure 8 is a software structure block diagram of another electronic device provided by an embodiment of the present application.
[0139] It should be noted that, as Figure 8 shown, the software structure is a showing manner applicable to the embodiment of the present application based on the software structure as described above Figure 7 shown.
[0140] As Figure 8 shown, in the embodiment of the present application, the Application Layer may further include third-party applications, etc. The third-party application may be a third-party application that the user can download and install through an application store, or may also be a small program that the user directly runs on a specific platform without installation. The embodiment of the present application does not limit this. The Application Framework Layer may further include a performance management module (such as IAware) and a stubbing module for intelligent perception and energy consumption management. Among them, the stubbing module can perform system optimization or test information processing on the third-party application specifically based on the configuration file and the delay information in the message queue.
[0141] Specifically, the instrumentation module can instrument critical functions that are about to be interpreted and executed in a third-party application based on a configuration file, and send a message to the message queue when a stub point is triggered, so that the performance management module can make corresponding targeted processing based on the message queue. In addition, the message queue supports an asynchronous communication mode. After the instrumentation module puts the message into the message queue, it can continue to execute other operations without waiting for the response of the message, improving the performance of the system.
[0142] The performance management module may include a third-party application for process creation and sub-modules for performance monitoring and energy consumption management. Among them, the performance monitoring sub-module can monitor and analyze the real-time performance of the system by intelligently perceiving the running state of the system and user behavior, so as to adjust and optimize the system in a timely manner according to the corresponding dimension measurement information; the energy consumption management sub-module can intelligently manage system resources such as the CPU and memory according to the system load and performance requirements, so as to execute corresponding performance optimization strategies.
[0143] The Hardware Abstraction Layer (HAL) may include a compiler and an interpreter; in addition to the display driver, camera driver, audio driver, and sensor driver in the kernel layer, it may also include a functional module scheduled by the kernel part, which is used to manage and schedule each process or thread running in the system. The embodiments of the present application will not elaborate on each functional module for the time being. For the specific description of each functional module, please refer to the following relevant descriptions.
[0144] Specifically, the compiler is responsible for converting the source code written in a programming language into another computer code, which is often called object code in binary form. The purpose of this conversion process is usually to generate an executable program, which is then executed by the computer hardware. For example: the compiler will compile the entire source code of the third-party application into machine code, so that the hardware of the electronic device can directly execute the compiled machine code.
[0145] The interpreter is used to directly execute the code written in a programming language or scripting language without pre-compiling the source code into machine code. Exemplarily, an interpreter usually executes the program code in the following ways: the interpreter reads the source code of the third-party application line by line, that is, analyzes the source code line by line (for example: the java file corresponding to the third-party application), and directly executes it; or, translates the source code into relatively more efficient intermediate code and then immediately executes it; or, executes the code saved after being pre-compiled by the compiler inside the interpreter. It can be understood that the interpreter can be regarded as a black box, and when the source code is input, the result will be returned in real time.
[0146] For example: In the embodiment of the present application, after the delay information is updated to the message queue, the interpreter can continue to interpret and execute the next corresponding function in the third-party application.
[0147] For another example: When it is determined that the currently interpreted and executed function is not a critical function, continue to interpret and execute the function. The interpreter can interpret and execute the function corresponding to the third-party application, and can also interpret and execute the hook function after the function corresponding to the third-party application is instrumented. The embodiment of the present application does not make specific limitations on this.
[0148] In the embodiment of the present application, the instrumentation module can be used to perform instrumentation Hook processing on the function currently interpreted and executed by the interpreter (that is, the target function) to determine the target instrumentation point corresponding to the target function. Among them, Hook means intercepting the original function that was originally to be called in the original target application program through a hook program, and modifying the entry address of the original function to the entry address of the called hook function, so as to achieve the function of calling the hook function before executing the call to the original function, thereby realizing the modification or extension of the corresponding function of the target application program. During the running of the program, the operations of inserting a hook program, removing a hook program, and changing a hook program can be called dynamic hooking. Implementing dynamic hooking using the dynamic hook mechanism can flexibly modify and extend the functions of the target application program.
[0149] The third-party application's Java functions that are about to be executed or are being executed are instrumented through the instrumentation module, that is, key functions are hooked (i.e., instrumented), and corresponding target instrumentation points are determined. Based on this instrumentation information, the positioning of key events in the third-party application can be indicated, and then the performance of the third-party application can be optimized in a targeted manner to improve the user experience. For example: when the third-party application calls functions at the starting point of the content loading process and the delay points during the loading process, instrumentation processing is performed respectively, so that the operating system of the electronic device can locate the start instrumentation point and the delay instrumentation point of the content loading process. Among them, the start instrumentation point is used to trigger the execution of the performance optimization strategy, the delay instrumentation point is used to trigger the end instrumentation point after a preset time, and the end instrumentation point is used to trigger the end of the performance optimization strategy. Furthermore, based on this start instrumentation point and the delay instrumentation point, while determining the relevant measurement information such as the content loading duration of the third-party application, it is also possible to terminate the preset time corresponding to the previous triggered delay instrumentation point and start the preset time corresponding to the current delay instrumentation point when repeatedly triggering the delay instrumentation point (for example, repeatedly triggering the delay instrumentation point corresponding to a target function and / or different delay instrumentation points corresponding to different target functions), so as to dynamically adjust the trigger time of the end instrumentation point, enabling the execution of corresponding performance optimization strategies to be controlled based on the performance optimization module for various complex content loading scenarios. For example, adjusting the working frequency of the processor during the content loading process of the third-party application (such as: increasing), so that while greatly reducing the content loading duration of the third-party application, it is also possible to more flexibly and accurately control the trigger execution and end timing of the performance optimization strategy to adapt to various different content loading scenarios, greatly improving the user experience.
[0150] Among them, the specific implementation manners of the above-mentioned various modules can be correspondingly referred to the following related embodiments, and the embodiments of the present application will not be elaborated herein for the time being.
[0151] In addition, please refer to the attached Figure 9 , Figure 9 is a schematic flowchart of an instrumentation Hook method provided by an embodiment of the present application. As Figure 9 As shown, after the electronic device is powered on, the Iaware process is automatically started. Iaware automatically scans and reads the configuration files. These configuration files contain the system's management strategies for different scenarios (which may be control scenarios for performance, resources, or other aspects). Once the configuration files are read, Iaware will start a process to execute these management scenarios, thereby controlling the system characteristics to ensure that it has the best configuration during operation to achieve more efficient performance or resource management. Further, Iaware initializes and configures various characteristics, functions, or resources in the system to ensure that the system can operate in the best state when starting up or during operation. After the characteristic initialization, Iaware ensures that the system configuration can reflect the latest requirements and conditions when the application is actually running by reading some initialized parameters or the configuration files of the characteristics. Then iAware can respond to Binder, transfer specific data, configuration information, or perform corresponding control operations for effective communication and collaboration between different processes. Among them, Binder is a mechanism for inter-process communication in the Android system. By passing Binder objects between processes, it realizes the cross-process transfer of objects.
[0152] Further, during the application compilation stage, the dex2oat process is first started. This process is responsible for converting the Dalvik bytecode of the Android application into native machine code to improve the application's running efficiency. During this process, it is necessary to obtain function information through the Binder mechanism. After obtaining the function information related to Binder, the inlining operation of intercepting associated functions is performed during further compilation. Inlining is a compiler optimization technique that replaces the code at the function call site with the actual code of the called function to reduce the overhead of function calls. The inlining operation of intercepting associated functions is to facilitate the subsequent identification of key functions based on the names of key functions.
[0153] Furthermore, in the application process stage, when the application starts, it involves interactions with third-party processes, including the creation of third-party processes, obtaining function information through Binder, passing information to the Runtime through the Java Native Interface (JNI), and the process of loading functions for judgment and marking. Specifically, when the application starts, a third-party process related to the application is created, which can be used to perform some specific tasks, provide services, or perform other processing required by the application. Then, through the Binder mechanism, information related to specific functions is obtained, and next, the obtained function information is passed to the Runtime through the Java Native Interface (JNI). JNI is an interface provided by the Java virtual machine for implementing the interaction between Java programs and native code. Finally, when loading the functions, key functions are judged and marked to perform corresponding operations (such as instrumentation Hook operations, etc.) during subsequent execution. When the application is running, it involves the execution of key functions, the triggering of instrumentation points and sending messages after triggering, and further processing of the instrumentation point Hook messages to judge the event type. Specifically, when the application starts running, the key functions start to be executed, and these key functions may contain the core logic of the application or the functions to perform specific tasks. Further, based on these key functions, the corresponding instrumentation points are triggered and Hook messages are sent. Among them, the triggering of the instrumentation point Hook injects custom code before or after the execution of the key function to facilitate monitoring the behavior of the function. The corresponding Hook messages sent can be used to notify other components or modules that a specific event has occurred, and this message usually contains the context information of the triggered HOOK, the event type, etc. Further process this Hook message, judge the event type based on this Hook message, so as to execute specific logic related to the event or take corresponding measures. This enables the application to send messages at specific times and then perform further logical judgments by processing these messages.
[0154] It should be noted that the relevant descriptions of the above method embodiments are only possible implementation manners of an instrumentation Hook method flow provided by the embodiments of the present application, and do not constitute a specific limitation on the following method embodiments. In other embodiments, the instrumentation Hook method flow may include more or fewer steps, some steps may be in other orders or performed simultaneously, or some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution.
[0155] Next, first based on the above Figure 8 shown software structure, the overall process of the instrumentation method based on the interpreter is introduced exemplarily.
[0156] First, it should be noted that the user involved in the embodiments of the present application and the following related embodiments is the user of the electronic device. In some other embodiments, the user may also be the associated person of the electronic device. In this regard, the embodiments of the present application do not make specific limitations.
[0157] Secondly, based on the above Figure 8 shown software structure, combined with the performance optimization method based on the interpreter provided in the present application, the technical problems proposed in the present application are specifically analyzed and solved.
[0158] Please refer to Figure 10 , Figure 10 which is a schematic flowchart of a performance optimization method based on an interpreter provided by an embodiment of the present application.
[0159] The performance optimization method based on the interpreter can be applied to the software architecture described above Figure 8 and can be applied to the electronic device described above Figure 6 . It can also be implemented through the software architecture above Figure 7 so that the electronic device can be used to support and execute Figure 10 the method flow steps S201 - S203 shown. Among them, the specific relevant descriptions of each step are as follows:
[0160] Step S201: Perform stub Hook processing on the target function to determine the target stub point corresponding to the target function.
[0161] Specifically, the target function is the function currently being interpreted and executed by the interpreter, and one target function corresponds to one target stub point. The stub module can perform stub Hook processing on the function currently being interpreted and executed by the interpreter (that is, the target function) to determine the corresponding target stub point, so as to further determine whether the current trigger condition of the target stub point is met based on the target stub point.
[0162] In a possible implementation manner, before performing stub Hook processing on the target function, the stub module can also obtain the function information of the function to be interpreted and executed. The function information includes the function name of the function; based on the function information and the pre-obtained configuration file, it is determined whether the function is a key function. The configuration file includes the function names corresponding to one or more key functions. It can be understood that the embodiments of the present application do not make specific limitations on the acquisition method of this configuration file. When the function is the key function, it is determined that the function is the target function.
[0163] Specifically, in the embodiments of the present application, relevant function information such as the function name of the function to be interpreted and executed can be obtained. At the same time, based on a pre-obtained configuration file, it is determined whether the function to be interpreted and executed currently is a key function. If the function is a key function, it indicates that the function is the trigger point of a key event during the application content loading process. The function can be determined as the target function, and then the function is subjected to stub Hook processing to determine its corresponding target stub point, so as to accurately and efficiently perform performance optimization strategies for the content loading process to improve the user experience.
[0164] Furthermore, since the configuration file includes function names corresponding to one or more key functions, the stubbing module can determine whether there is a function name in the configuration file that is the same as the function name of the function based on the function information and the configuration file; if so, it is determined that the function is the corresponding key function; if not, it is determined that the function is a non-key function. In the embodiments of the present application, it can be determined whether the function to be interpreted and executed by the current interpreter (i.e., the function to be interpreted and executed) is a key function through the function name, thereby greatly improving the efficiency of confirming the key function, so as to target the content loading process during the operation of the third-party application based on the key function, and accurately and efficiently determine the trigger execution and end timing of the performance optimization strategy, thereby reducing the loading duration to improve the user experience.
[0165] It can be understood that if the function to be interpreted and executed is a non-key function, it indicates that the running function is not the trigger point of a key event of the third-party application. At this time, the running function can still be continuously interpreted and executed by the interpreter.
[0166] Exemplarily, if the configuration file includes the following information: the function name A1 of key function 1, the function name A2 of key function 2. Among them, when determining whether the function to be interpreted and executed is a key function, it is learned that the function name of the function to be interpreted and executed 1 is A1, then it can be confirmed that the function to be interpreted and executed 1 is a key function and is key function 1 in the configuration file. If the function name of running function 1 is B2, the function to be interpreted and executed 1 is a non-key function.
[0167] In a possible implementation manner, after the stubbing module determines the target stub point corresponding to the target function, based on the target stub point, the stub point information corresponding to the target stub point is determined; the stub point information includes position information, trigger conditions, and trigger rules; the position information is used to indicate the stubbing position of the target stub point in the target function, the trigger condition is used to indicate the condition for the target stub point to be triggered, and the trigger rule is used to indicate the operation to be performed when the target stub point is triggered.
[0168] Specifically, in the embodiments of the present application, based on the position information in the stub point information, the stub insertion position of the target stub point in the key function (i.e., the target function) currently being interpreted and executed by the interpreter can be determined to ensure that the triggering of the target stub point can accurately reflect the key time point of the content loading process. At the same time, based on the triggering condition of the stub point information, it can be determined whether the target stub point is triggered when the corresponding target function is executed, so as to avoid the situation where the target stub point is triggered in advance or repeatedly. In addition, based on the triggering rule in the stub point information, the operation executed by the electronic device when the target stub point is triggered can be determined, so as to achieve targeted control of the electronic device to execute the corresponding performance optimization strategy during the content loading process, reduce the loading duration, and improve the user experience.
[0169] Step S202: When the target function is executed, determine whether the current situation satisfies the triggering condition of the target stub point.
[0170] Specifically, when the target function is executed by the electronic device, the stub insertion module is further used to determine whether the current situation satisfies the triggering condition of the target stub point. Among them, the types of target stub points include start stub points and delay stub points. The start stub point is used to trigger the execution of the performance optimization strategy, and the delay stub point is used to trigger the end stub point after a preset time. The end stub point is used to trigger the end of the performance optimization strategy. Therefore, for all target functions in the entire content loading process of the third-party application, there is at least one start stub point and one delay stub point, so as to achieve targeted control of the execution process of the performance optimization strategy during the content loading process of the application, and avoid a significant increase in the temperature of the electronic device due to continuous execution of the performance optimization strategy during the application operation, resulting in automatic frequency reduction and poor performance optimization effect.
[0171] In a possible implementation manner, the step of "when the target function is executed, determine whether the current situation satisfies the triggering condition of the target stub point" may include: when the target function is executed, based on the stub point information corresponding to the target function, determine whether the current situation satisfies the triggering condition of the target stub point.
[0172] Specifically, when the key function (i.e., the target function) currently being interpreted and executed by the interpreter is executed, the stub insertion module can, through the stub point information corresponding to the target function, determine whether the current situation satisfies the triggering condition of the corresponding target stub point, so as to determine whether the corresponding target stub point is triggered currently, avoid the situation where the target stub point is triggered in advance or repeatedly, improve the accuracy of controlling the electronic device to execute the corresponding performance optimization strategy for the content loading process, ensure that the target stub point is triggered at the correct time, and thus reduce the loading duration and improve the user experience.
[0173] In a possible implementation manner, the types of the target stake points may further include start pre-stake points and / or delay pre-stake points; the start pre-stake points can be used to change the pre-state to the start pre-state, and the delay pre-stake points can be used to change the pre-state to the delay pre-state, where the pre-state is the program state before executing the target function corresponding to the target stake point.
[0174] Specifically, the start pre-stake point can change the program state (i.e., the pre-state) before the electronic device executes the target function corresponding to the target stake point to the start pre-state, and the pre-stake point can change the program state (i.e., the pre-state) before the electronic device executes the target function corresponding to the target stake point to the delay pre-state. Therefore, during the entire content loading process of the third-party application, different types of target stake points can be set for key functions according to the complexity of the actual situation, and through the free combination of different types of target stake points, it is ensured that key events corresponding to various different content loading scenarios can be targeted, so as to more flexibly and accurately control the triggering execution and ending timing of the performance optimization strategy to adapt to various different content loading scenarios.
[0175] In a possible implementation manner, the start stake point is further used to record the time when the performance optimization strategy is triggered to execute and change the pre-state to the start state; the end stake point is further used to record the time when the execution of the performance optimization strategy ends and change the pre-state to the end state.
[0176] Specifically, the start stake point (which can also be called the policy distribution stake point) can trigger the execution of the performance optimization strategy, and at the same time, it can be used to record the time when the performance optimization strategy is triggered to execute and change the program state (i.e., the pre-state) before executing the target function corresponding to the target stake point to the start state; the end stake point can be used to trigger the end of the performance optimization strategy, and at the same time, it can be used to record the time when the execution of the performance optimization strategy ends and change the program state (i.e., the pre-state) before the electronic device executes the target function corresponding to the target stake point to the end state, which is beneficial to calculating relevant dimension measurement information such as the execution duration of the performance optimization strategy through the timestamps recorded when the start stake point and the end stake point are triggered. At the same time, through the change of this pre-state, especially for the case of complex loading logic, it is possible to quickly determine the execution situation of each key event during the content loading process, which helps to more comprehensively and meticulously analyze and understand the behavior of the program in scenarios such as debugging, dimension measurement, or performance analysis, so as to further conduct corresponding fault analysis or optimization to improve the user experience.
[0177] In a possible implementation, the performance optimization strategy includes increasing the operating frequency of the processor. The performance optimization strategy in the embodiments of the present application may include increasing the operating frequency of the processor (for example, sending a frequency increase instruction to the processor) to enable quick response to user operations (such as opening a third-party application or clicking on a page) during the content loading process of the third-party application, quickly loading the page content and displaying it, thereby enhancing the user experience.
[0178] In a possible implementation, the type of the target stake point further includes the start pre-stake point; determining whether the trigger condition of the target stake point is currently satisfied may include: if the target stake point is the start stake point, determining whether the pre-state is the start pre-state based on the stake point information corresponding to the start stake point; if so, determining that the trigger condition corresponding to the start stake point is satisfied; if not, determining that the trigger condition corresponding to the start stake point is not satisfied.
[0179] Specifically, when, for the entire content loading process of a third-party application, the type of the target stake point corresponding to all target functions further includes the start pre-stake point, if the target stake point corresponding to the key function (i.e., the target function) currently being interpreted and executed by the interpreter is the start stake point, the instrumentation module may determine whether the program state (i.e., the pre-state) before the electronic device executes the target function corresponding to this start stake point (i.e., the target stake point) is the start pre-state based on the stake point information corresponding to this start stake point, so as to determine whether the trigger condition of this start stake point (i.e., the target stake point) is currently satisfied. Further, if this pre-state is the start pre-state, it may be determined that the trigger condition corresponding to this start stake point is satisfied; if this pre-state is not the start pre-state, it may be determined that the trigger condition corresponding to this start stake point is not satisfied, such that after the start pre-stake point is triggered, the start stake point can be triggered, thereby ensuring that the start stake point will not be triggered in advance during the content loading process, so as to ensure that the triggering of the start stake point can accurately reflect the start node of the content loading process and improve the positioning accuracy.
[0180] In a possible implementation, the type of the target stake point further includes the delay pre-stake point; determining whether the trigger condition of the target stake point is currently satisfied may include: if the target stake point is a delay stake point, determining whether the pre-state is the delay pre-state based on the stake point information corresponding to the delay stake point; if so, determining that the trigger condition corresponding to the delay stake point is satisfied; if not, determining that the trigger condition corresponding to the delay stake point is not satisfied.
[0181] Specifically, when, for the entire content loading process of a third-party application, the types of target stubs corresponding to all target functions also include delayed pre-stubs, if the target stub corresponding to the key function (i.e., the target function) currently being interpreted and executed by the interpreter is a delayed stub, the stub insertion module can, based on the stub information corresponding to the delayed stub, determine whether the program state (i.e., the pre-state) before the electronic device executes the target function corresponding to the delayed stub (i.e., the target stub) is a delayed pre-state, so as to determine whether the trigger condition of the current delayed stub (i.e., the target stub) is satisfied. Further, if the pre-state is a delayed pre-state, it can be determined that the trigger condition corresponding to the delayed stub is satisfied; if the pre-state is not a delayed pre-state, it can be determined that the trigger condition corresponding to the delayed stub is not satisfied, so that after the delayed pre-stub is triggered, the delayed stub can be triggered, thus ensuring that the delayed stub will not be triggered in advance during the content loading process, so as to ensure that the triggering of the delayed stub can accurately reflect the delay node of the content loading process and improve the positioning accuracy.
[0182] In a possible implementation manner, the determining whether the trigger condition of the target stub is currently satisfied may include: if the target stub is the delayed pre-stub, determining whether the pre-state is the start state based on the stub information corresponding to the delayed pre-stub; if so, determining that the trigger condition corresponding to the delayed pre-stub is satisfied; if not, determining that the trigger condition corresponding to the delayed pre-stub is not satisfied.
[0183] Specifically, if the target stub corresponding to the key function (i.e., the target function) currently being interpreted and executed by the interpreter is a delayed pre-stub, the stub insertion module can, based on the stub information corresponding to the delayed pre-stub, determine whether the program state (i.e., the pre-state) before the electronic device executes the target function corresponding to the delayed pre-stub (i.e., the target stub) is the start state, so as to determine whether the trigger condition of the current delayed pre-stub (i.e., the target stub) is satisfied. Further, if the pre-state is the start state, it can be determined that the trigger condition corresponding to the delayed pre-stub is satisfied; if the pre-state is not the start state, it can be determined that the trigger condition corresponding to the delayed pre-stub is not satisfied, so that after the start stub is triggered, the delayed pre-stub can be triggered, thus ensuring that the delayed pre-stub will not be triggered in advance during the content loading process, so as to ensure that the triggering of the delayed pre-stub can accurately reflect the delay pre-node of the content loading process and improve the positioning accuracy.
[0184] Step S203: If the target stub is a delayed stub and the trigger condition corresponding to the delayed stub is satisfied, terminate the preset time corresponding to the previous triggered delayed stub, start the preset time corresponding to the current delayed stub, and trigger the end stub after the preset time.
[0185] Specifically, if the target stake point is a delay stake point and the triggering condition corresponding to the delay stake point is satisfied, the performance management module can terminate the preset time corresponding to the previously triggered delay stake point, start the preset time corresponding to the current delay stake point, and trigger the end stake point after the preset time. Therefore, in the embodiments of the present application, when repeatedly triggering delay stake points (for example, repeatedly triggering delay stake points corresponding to a target function and / or different delay stake points corresponding to different target functions), the preset time corresponding to the previously triggered delay stake point can be terminated, and the preset time corresponding to the current delay stake point can be started, so as to dynamically adjust the triggering time of the end stake point. In a scenario where the loading process is relatively complex (for example, a content loading scenario where it is difficult to find a key function with strong logical relevance as the content of the end stake point), it is not necessary to find a key function related to the loading logic as the end stake point of the performance optimization strategy, and the electronic device can still accurately execute the corresponding performance optimization strategy for the content loading process, thereby reducing the loading duration to improve the user experience.
[0186] In a possible implementation manner, if the target stake point is a delay stake point and the triggering condition corresponding to the delay stake point is satisfied, terminating the preset time corresponding to the previously triggered delay stake point, starting the preset time corresponding to the current delay stake point, and triggering the end stake point after the preset time may include: if the target stake point is the delay stake point and the triggering condition corresponding to the delay stake point is satisfied, sending delay information, where the delay information is used to trigger the end stake point after the preset time; during the preset time when the delay message is waiting in the message queue and during the process of executing the next target function, continuously determining whether the triggering condition of the delay stake point is currently satisfied; if satisfied, removing the previously sent delay message from the message queue, simultaneously sending the latest delay message, and updating the latest delay message to the message queue; if not satisfied, triggering the end stake point after the preset time of the delay message has passed.
[0187] Specifically, when the target stake point corresponding to the key function currently interpreted and executed by the interpreter (i.e., the target function) is a delay stake point and the triggering condition corresponding to the delay stake point is satisfied, the instrumentation module can send delay information that can be used to trigger the end stake point after a preset time (e.g., 500 ms). Further, within the preset time (e.g., 500 ms) that the delay message waits in the message queue and during the execution of the next target function, continue to determine whether the triggering condition of the delay stake point is currently satisfied. If it is satisfied, the performance management module removes the previously sent delay message from the message queue, and at the same time, the instrumentation module sends the latest delay message, and the performance management module updates the latest delay message to the message queue, so as to achieve that when the delay stake point is repeatedly triggered (e.g., repeatedly trigger the delay stake point corresponding to a target function and / or different delay stake points corresponding to different target functions), terminate the preset time corresponding to the previous triggered delay stake point, start the preset time corresponding to the current delay stake point, and trigger the end stake point to end the execution of the performance optimization strategy when the delay stake point is not triggered again before the preset time (e.g., 500 ms) ends. Through the embodiments of the present application, the triggering time of the end stake point can be continuously and dynamically adjusted, so that in a scenario where the loading process is relatively complex (e.g., a content loading scenario where it is difficult to find a key function with strong logical relevance as the content of the end stake point of the performance optimization strategy), it is not necessary to find a key function related to the loading logic as the end stake point of the performance optimization strategy, and the electronic device can accurately execute the corresponding performance optimization strategy for the content loading process, thereby reducing the loading duration to improve the user experience.
[0188] In a possible implementation manner, the method further includes: if the target stake point is the start pre-stake point and the triggering condition corresponding to the start pre-stake point is satisfied, change the pre-state to the start pre-state; if the target stake point is the start stake point and the triggering condition corresponding to the start stake point is satisfied, trigger the execution of the performance optimization strategy, record the time when the performance optimization strategy is triggered, and change the pre-state to the start state; if the target stake point is the delay pre-stake point and the triggering condition corresponding to the delay pre-stake point is satisfied, change the pre-state to the delay pre-state.
[0189] Specifically, when the target staking point corresponding to the key function (i.e., the target function) currently being interpreted and executed by the interpreter is the start pre-staking point, and the triggering condition corresponding to the start pre-staking point is satisfied, the electronic device can change the program state (i.e., the pre-state) before the target function corresponding to the start pre-staking point (i.e., the target staking point) to the start pre-state through the staking module, so as to ensure that the start pre-staking point (including the start pre-staking point corresponding to one target function and / or different start pre-staking points corresponding to different target functions) will not be repeatedly triggered during the content loading process. That is, the start pre-staking point can only be triggered once during the entire content loading process, so as to ensure that the triggering of the start pre-staking point can accurately reflect the start pre-node of the content loading process and improve the positioning accuracy. When the target staking point corresponding to the key function (i.e., the target function) currently being interpreted and executed by the interpreter is the start staking point, and the triggering condition corresponding to the start staking point is satisfied, the electronic device can trigger the execution of the performance optimization strategy through the performance management module and record the time when the performance optimization strategy is triggered, so as to quickly determine the start time and other maintenance test information of the performance optimization strategy in the maintenance test scenario, and further perform corresponding fault analysis or optimization to improve the user experience. In addition, the electronic device can also change the program state (i.e., the pre-state) before the target function corresponding to the start staking point (i.e., the target staking point) to the start state through the staking module, so as to ensure that the start staking point (including the start staking point corresponding to one target function and / or different start staking points corresponding to different target functions) will not be repeatedly triggered during the content loading process. That is, the start staking point can only be triggered once during the entire content loading process, so as to ensure that the triggering of the start staking point can accurately reflect the start node of the content loading process. When the target staking point corresponding to the key function (i.e., the target function) currently being interpreted and executed by the interpreter is the delay pre-staking point, and the triggering condition corresponding to the delay pre-staking point is satisfied, the electronic device can change the program state (i.e., the pre-state) before the target function corresponding to the delay pre-staking point (i.e., the target staking point) to the delay pre-state through the staking module, so as to ensure that the delay pre-staking point (including the delay pre-staking point corresponding to one target function and / or different delay pre-staking points corresponding to different target functions) will not be repeatedly triggered during the content loading process. That is, the delay pre-staking point can only be triggered once during the entire content loading process, so as to ensure that the triggering of the delay pre-staking point can accurately reflect the delay pre-node of the content loading process and improve the positioning accuracy.
[0190] In a possible implementation manner, the end staking point is further used to record the time when the performance optimization strategy ends and change the pre-state to the end state; the method further includes: when the end staking point is triggered, trigger the end of the performance optimization strategy, record the time when the performance optimization strategy ends, and change the pre-state to the end state.
[0191] Specifically, the end stake point can also be used to record the time when the end performance optimization strategy is executed, and change the program state (i.e., the pre-state) before executing the target function corresponding to the target stake point to the start state and then to the end state. Correspondingly, when the end stake point is triggered, the electronic device can trigger the end execution of the performance optimization strategy through the performance management module, record the time of the end execution of the performance optimization strategy, and change the program state (i.e., the pre-state) before executing the target function corresponding to the target stake point to the end state through the stubbing module, so as to ensure that the triggering of the end stake point can accurately reflect the end node of the content loading process. Further, when the electronic device ends the execution of the performance optimization strategy, recording the time when the end execution of the performance optimization strategy is triggered is beneficial to monitoring the process of the electronic device executing the performance optimization strategy, so as to quickly determine the end time and other monitoring information of the performance optimization strategy, so as to perform corresponding fault analysis or optimization in the scenario of monitoring the third-party application, so as to improve the user experience.
[0192] Please refer to Figure 11 , Figure 11 FIG. is a schematic flowchart of a specific process of a performance optimization method based on an interpreter provided by an embodiment of the present application. This performance optimization method can be applied to the above Figure 6 described electronic device, and is also implemented in the software architecture above Figure 8 wherein, the interpreter can be used to interpret and execute functions corresponding to third-party applications, and the stubbing module can be used to support and execute the Figure 11 method flow steps S301 - step S309B and part of step S309A shown in Figure 11 and the performance management module can be used to support and execute part of step S309A and step S310 in the method flow shown in
[0193] Step S301: Obtain function information of a function to be interpreted and executed. Wherein, the function information includes the function name of the function.
[0194] Step S302: Based on the function information and a pre-obtained configuration file, determine whether the function is a critical function. The configuration file includes function names respectively corresponding to one or more critical functions.
[0195] Step S303: In the case where the function is a critical function, determine the function as the target function.
[0196] Specifically, the descriptions of steps S301 - S303 can be referred to the above Figure 10 The relevant description of S201 will not be elaborated here. It can be understood that if the function to be interpreted and executed is a non-critical function, it indicates that the function is not the trigger point of the key event of the third-party application when it is called. At this time, the function can still be interpreted and executed by the interpreter.
[0197] Step S304: Perform stub Hook processing on the target function to determine the target stub point corresponding to the target function. Among them, the target function is the function currently being interpreted and executed by the interpreter, and one target function corresponds to one target stub point.
[0198] Step S305: Based on the target stub point, determine the stub point information corresponding to the target stub point.
[0199] Among them, the stub point information includes location information, trigger conditions, and trigger rules; the location information is used to indicate the stub insertion position of the target stub point in the target function, the trigger condition is used to indicate the condition for the target stub point to be triggered, and the trigger rule is used to indicate the operation to be performed when the target stub point is triggered.
[0200] Specifically, for the description of steps S304 - S305, reference can be made to the relevant description of S201 above Figure 10 which will not be elaborated here.
[0201] Step S306: When the target function is executed, based on the stub point information corresponding to the target function, determine whether the current situation meets the trigger condition of the target stub point.
[0202] Among them, the types of target stub points include start stub points and delay stub points. The start stub point is used to trigger the execution of the performance optimization strategy, the delay stub point is used to trigger the end stub point after a preset time, and the end stub point is used to trigger the end of the performance optimization strategy.
[0203] In a possible implementation manner, the types of target stub points may further include start pre-stub points and / or delay pre-stub points; the start pre-stub point can be used to change the pre-state to the start pre-state, and the delay pre-stub point can be used to change the pre-state to the delay pre-state. The pre-state is the program state before executing the target function corresponding to the target stub point.
[0204] In a possible implementation manner, the performance optimization strategy may include increasing the working frequency of the processor.
[0205] Exemplarily, when the type of the target stub point further includes a start pre-stub point, if the target stub point is the start stub point, based on the stub point information corresponding to the start stub point, determine whether the pre-state is the start pre-state; if so, it is determined that the trigger condition corresponding to the start stub point is met; if not, it is determined that the trigger condition corresponding to the start stub point is not met.
[0206] Exemplarily, when the type of the target stake point further includes a delayed pre-stake point, if the target stake point is a delayed stake point, it is determined whether the pre-state is a delayed pre-state based on the stake point information corresponding to the delayed stake point; if so, it is determined that the trigger condition corresponding to the delayed stake point is satisfied; if not, it is determined that the trigger condition corresponding to the delayed stake point is not satisfied.
[0207] Exemplarily, if the target stake point is the delayed pre-stake point, it is determined whether the pre-state is the start state based on the stake point information corresponding to the delayed pre-stake point; if so, it is determined that the trigger condition corresponding to the delayed pre-stake point is satisfied; if not, it is determined that the trigger condition corresponding to the delayed pre-stake point is not satisfied. In a possible implementation manner, the start stake point is further used to record the time when the performance optimization strategy is triggered to execute, and change the pre-state to the start state; the end stake point is further used to record the time when the performance optimization strategy ends to execute, and change the pre-state to the end state.
[0208] Specifically, for the description of the above step S306, reference can be made to the relevant description of S202 above Figure 10 and will not be elaborated here.
[0209] Step S307: If the target stake point is a delayed stake point and the trigger condition corresponding to the delayed stake point is satisfied, a delay message is sent. Wherein, the delay message can be used to trigger the end stake point after a preset time (such as 500 ms).
[0210] Step S308: During the preset time when the delay message is waiting in the message queue and during the process of executing the next target function, it is continuously determined whether the trigger condition of the delayed stake point is currently satisfied.
[0211] Step S309A: If satisfied, the previously sent delay message in the message queue is removed, and at the same time, the latest delay message is sent, and the latest delay message is updated to the message queue. Since in the embodiments of the present application, the delayed stake point can be triggered repeatedly (such as repeatedly triggering the delayed stake point corresponding to a target function and / or different delayed stake points corresponding to different target functions), therefore, after step S309A, it turns to step S308.
[0212] Step S309B: If not satisfied, the end stake point is triggered after the delay message passes through the preset time.
[0213] Step S310: When the end stake point is triggered, the end performance optimization strategy is triggered, and at the same time, the time when the end performance optimization strategy is triggered is recorded, and the pre-state is changed to the end state.
[0214] In a possible implementation, if the target stake point is the start pre-stake point and the trigger condition corresponding to the start pre-stake point is satisfied, the embodiment of the present application can change the pre-state to the start pre-state through the stake insertion module; if the target stake point is the start stake point and the trigger condition corresponding to the start stake point is satisfied, the performance optimization strategy is triggered to be executed through the performance management module, and at the same time, the time when the performance optimization strategy is triggered to be executed is recorded, and the pre-state is changed to the start state through the stake insertion module; if the target stake point is the delay pre-stake point and the trigger condition corresponding to the delay pre-stake point is satisfied, the pre-state can be changed to the delay pre-state through the stake insertion module.
[0215] Specifically, for the descriptions of the above steps S307 - S310, reference can be made to the relevant descriptions of S203 above, which will not be elaborated here. Figure 10 of S203, which will not be elaborated here.
[0216] It should be noted that for the foregoing method embodiments, for simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps may be adopted in other sequences or simultaneously, or some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution.
[0217] The above described in detail the method of the embodiment of the present application. It can be understood that for each device to implement the corresponding functions above, it includes the corresponding hardware structure and / or software module for executing each function. Combining the units and steps of each example described in the embodiments disclosed in this article, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the way of hardware or computer software driving hardware depends on the specific application and design constraint conditions of the technical solution.
[0218] Exemplarily, please refer to Figure 12 , Figure 12 which is a schematic diagram of the stake point trigger process in a performance optimization method provided by an embodiment of the present application.
[0219] As Figure 12 As shown, among all the stub points triggered by the performance optimization method for the entire content loading process of the third-party application, the stub point types include at least one start stub point and one delay stub point. After the delay stub point is triggered, it can be determined whether the delay stub point is triggered again during the delay waiting process. If the delay stub point is triggered again during the delay waiting process (i.e., the preset time, such as 500 ms), it is judged again during the latest delay waiting process. The repeated triggering of the delay stub point can be the repeated triggering of the delay stub point corresponding to a target function, or the triggering of different delay stub points corresponding to different target functions, and the number of times the delay stub point is triggered is an integer greater than 1. The embodiments of the present application do not make specific limitations on this. If it is not triggered again during the delay waiting process, the end stub point can be triggered after the preset time to ensure the integrity of the stub point triggering process. Optionally, the types of the triggered stub points in the flowchart may further include a start pre-stub point and / or a delay pre-stub point. In practical applications, according to the complexity of the content loading scenario, through the free combination of different types of target stub points, it can be ensured that the key events of various different content loading scenarios can be corresponded, so as to more flexibly and accurately control the triggering execution and end timing of the performance optimization strategy to adapt to various different content loading scenarios. In the embodiments of the present application, the start pre-stub point is triggered before the start stub point, and the delay pre-stub point is triggered after the start stub point and before the delay stub point. In addition, except for the delay stub point, triggering other corresponding stub points will change the program state (i.e., the pre-state) before the electronic device executes the target function corresponding to the delay stub point (i.e., the target stub point) to the type corresponding to the triggered stub point. Therefore, except that the delay stub point can be repeatedly triggered, the other types of stub points can only be triggered once in a stub point triggering process, and it is ensured that the other types of stub points will not be triggered in advance during the content loading process to ensure that the triggering of the corresponding stub points can accurately reflect the key nodes of the content loading process and improve the positioning accuracy. In addition, since the delay stub point trigger can be repeatedly triggered, and the other types of stub points are triggered multiple times in a stub point triggering process, the embodiments of the present application can dynamically adjust the triggering time of the end stub point through the delay stub point, so that in a scenario where the loading process is relatively complex (such as a content loading scenario where it is difficult to find a key function with strong logical relevance as the end stub point), it is not necessary to find a key function related to the loading logic as the end stub point of the performance optimization strategy, and the electronic device can also be accurately controlled to execute the corresponding performance optimization strategy for the content loading process, thereby reducing the loading duration to improve the user experience.
[0220] Further, based on the description of the delay stub point trigger in the above steps S306 - S310, for example, it can be referred to Figure 13 , Figure 13 which is a schematic diagram of a delay stub point trigger process provided by the embodiments of the present application.
[0221] As Figure 13 shown, during the process of content loading by a third-party application, when the target function corresponding to the delay stake point is executed, that is, when the target stake point corresponding to the key function currently interpreted and executed by the interpreter (i.e., the target function) is a delay stake point, the instrumentation module can determine whether the current situation meets the trigger condition of the delay stake point. Exemplarily, when the type of the target stake point in the entire stake point trigger process includes a delay pre-stake point, the trigger condition of the delay stake point can determine whether the program state (i.e., the pre-state) before the electronic device executes the target function corresponding to this delay stake point (i.e., the target stake point) is a delay pre-state. It can be understood that the trigger condition of the delay stake point in the embodiments of the present application is user-defined and may change according to different content loading scenarios of different applications. The embodiments of the present application only exemplarily introduce a possible implementation manner. In some embodiments, the trigger condition of the delay stake point may include other information, and the embodiments of the present application do not limit this. Further, when the target stake point does not meet the trigger condition of the delay stake point, no related operations regarding the delay stake point are performed; when the target stake point meets the trigger condition of the delay stake point, the performance management module removes the previously sent delay message from the message queue, and at the same time, the instrumentation module sends the latest delay message, and the performance management module updates the latest delay message to the message queue, so as to achieve that when the delay stake point is repeatedly triggered (for example, repeatedly triggering the delay stake point corresponding to a target function and / or different delay stake points corresponding to different target functions), the preset time corresponding to the previous triggered delay stake point is terminated and the preset time corresponding to the current delay stake point is started. Further, within the preset time (i.e., the delay process) when the delay message is waiting in the message queue, when the electronic device executes the next target function, it continues to determine whether the current situation meets the trigger condition of the delay stake point, that is, to determine whether the delay stake point is triggered again during the delay process. If it meets the condition, the delay stake point is triggered again; if it does not meet the condition, after the delay process ends, that is, after the preset time, the end stake point is triggered to end the execution of the performance optimization strategy. It can be understood that the preset time for the delay stake point in the embodiments of the present application to trigger the end stake point can be user-defined, and the embodiments of the present application do not limit this.
[0222] Further, please refer to Figure 14 , Figure 14 which is a schematic diagram of a dynamic search end point provided by the embodiments of the present application.
[0223] As Figure 14 As shown, among all the stubs triggered by the performance optimization method during the entire content loading process of the third-party application, the delay stubs can be triggered multiple times. And each time a delay stub is triggered, the preset time corresponding to the previous triggered delay stub will be terminated, the preset time corresponding to the current delay stub will be started, and if the delay stub is not triggered again before the preset time (e.g., 500 ms) ends, the end stub will be triggered to end the execution of the performance optimization strategy. Through the delay stub, the embodiments of the present application can implement a dynamic search method, no longer limited to finding key functions related to the loading logic as fixed end points in the prior art. In the face of scenarios where the loading logic repeats, the delay stubs can continue to be captured during the delay message period to cover the entire content loading interval. It should be noted that the delay stubs in the embodiments of this method can be triggered multiple times, which can be to repeatedly trigger the delay stub corresponding to a target function, or to trigger different delay stubs corresponding to different target functions. The embodiments of the present application do not make any limitations on this.
[0224] Exemplarily, please refer to Figure 15 , Figure 15 which is a schematic flowchart of a process for identifying and processing delay messages through a switch structure provided by the embodiments of the present application.
[0225] As Figure 15 shown, for the running function written in the Java language of the third-party application, it is interpreted and executed by the virtual machine interpreter. When the stub type corresponding to the function being interpreted and executed by the interpreter is a delay stub, and the triggering condition of the delay stub is satisfied, and the corresponding delay message is sent, the performance management module can first call the message handling function handlemessage() to process the received delay message, further identify the stub type corresponding to the delay message based on the switch structure, and by calling the condition matching function matchCondition(), determine whether the current state meets the preconditions and can execute the system behavior. If it is satisfied, the message removal function removeMessages() is called to remove the previous delay message from the message queue, and then the delay end function sendEndMsgDelay() is called to send the latest delay message to delay the triggering of the end node. It should be noted that the above embodiments only exemplarily illustrate a possible implementation manner for processing delay messages and do not constitute a specific limitation on the method of the present application.
[0226] Exemplarily, please refer to Table 2 below. Table 2 is a table of the content loading time of running a third-party application after adopting the performance optimization method of the present application provided by the embodiments of the present application.
[0227] Table 2
[0228]
[0229] As shown in Table 2 above, compared with the performance optimization method using the prior art (i.e., the solution of this application is not activated), after using the performance optimization method provided by the embodiments of this application, the content loading time of the electronic device when running third-party applications (such as the Dazhong Dianping applet, Meituan applet, etc.) is significantly reduced, and the time benefit increases as the temperature of the electronic device increases, thus avoiding the problem of too long loading time caused by temperature control and frequency reduction limitations when the electronic device runs third-party applications for content loading. In addition, the method of this application can be applied to various different loading scenarios. The above method embodiments only exemplarily introduce several possible loading scenarios. In other embodiments, the performance optimization method provided by the embodiments of this application can be applied to content loading scenarios including but not limited to various applets and application programs APPs. The embodiments of this application are not limited thereto. Through the embodiments of this application, for various complex content loading scenarios, such as content loading scenarios where it is difficult to find key functions with strong logical relevance as the end stubs, by dynamically adjusting the trigger time of the end stubs, the content loading process is accurately targeted, and the electronic device is controlled to execute corresponding performance optimization strategies, thereby reducing the loading duration to improve the user experience.
[0230] The application scenarios and method embodiments of the embodiments of this application are elaborated in detail above. It can be understood that in order for each device to implement the corresponding functions above, it includes the corresponding hardware structure and / or software module for executing each function. Combining the units and steps of each example described in the embodiments disclosed in this article, this application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the way of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application. Next, the systems and devices provided by the embodiments of this application are introduced.
[0231] Please refer to Figure 16 , Figure 16 which is a schematic structural diagram of a performance optimization system provided by the embodiments of this application. The performance optimization system 1600 may include an instrumentation module 1601 and a performance management module 1602; among them, the detailed descriptions of each module are as follows:
[0232] The instrumentation module 1601 is used for: performing instrumentation Hook processing on the target function to determine the target instrumentation point corresponding to the target function; the target function is the function currently being interpreted and executed by the interpreter, and one target function corresponds to one target instrumentation point; when the target function is executed, determining whether the trigger condition of the target instrumentation point is currently satisfied; the types of the target instrumentation points include start instrumentation points and delay instrumentation points, the start instrumentation point is used to trigger the execution of the performance optimization strategy, the delay instrumentation point is used to trigger the end instrumentation point after a preset time, and the end instrumentation point is used to trigger the end of the performance optimization strategy.
[0233] The performance management module 1602 is used for: if the target instrumentation point is a delay instrumentation point and the trigger condition corresponding to the delay instrumentation point is satisfied, terminating the preset time corresponding to the previously triggered delay instrumentation point, starting the preset time corresponding to the current delay instrumentation point, and triggering the end instrumentation point after the preset time.
[0234] Through the embodiments of the present application, when repeatedly triggering delay instrumentation points (for example, repeatedly triggering the delay instrumentation points corresponding to a target function and / or different delay instrumentation points corresponding to different target functions), the preset time corresponding to the previously triggered delay instrumentation point can be terminated, and the preset time corresponding to the current delay instrumentation point can be started, so as to dynamically adjust the trigger time of the end instrumentation point, such that in a scenario where the loading process is relatively complex (for example, a content loading scenario where it is difficult to find a key function with strong logical relevance as the content of the end instrumentation point), it is not necessary to find a key function related to the loading logic as the end instrumentation point of the performance optimization strategy, and the electronic device can accurately execute the corresponding performance optimization strategy for the content loading process, thereby reducing the loading duration to improve the user experience.
[0235] In a possible implementation manner, the instrumentation module 1601 is further used for: obtaining the function information of the function to be interpreted and executed, where the function information includes the function name of the function; based on the function information and the pre-obtained configuration file, determining whether the function is a key function, and the configuration file includes the function names corresponding to one or more key functions respectively; in the case where the function is the key function, determining the function as the target function.
[0236] In a possible implementation manner, the instrumentation module 1601 is specifically used for: based on the function information and the configuration file, determining whether there is a function name in the configuration file that is the same as the function name of the function; if so, determining the function as the corresponding key function; if not, determining the function as a non-key function.
[0237] In a possible implementation manner, the instrumentation module 1601 is further configured to: determine the instrumentation point information corresponding to the target instrumentation point based on the target instrumentation point; the instrumentation point information includes location information, trigger conditions, and trigger rules; the location information is used to indicate the instrumentation position of the target instrumentation point in the target function, the trigger conditions are used to indicate the conditions for the target instrumentation point to be triggered, and the trigger rules are used to indicate the operations to be performed when the target instrumentation point is triggered.
[0238] In a possible implementation manner, the instrumentation module 1601 is specifically configured to: when the target function is executed, determine whether the current situation satisfies the trigger conditions of the target instrumentation point based on the instrumentation point information corresponding to the target function.
[0239] In a possible implementation manner, the types of the target instrumentation points further include start pre-instrumentation points and / or delayed pre-instrumentation points; the start pre-instrumentation points are used to change the pre-state to the start pre-state, and the delayed pre-instrumentation points are used to change the pre-state to the delayed pre-state, where the pre-state is the program state before executing the target function corresponding to the target instrumentation point.
[0240] In a possible implementation manner, the start instrumentation point is further used to record the time when the performance optimization strategy is triggered for execution, and change the pre-state to the start state; the end instrumentation point is further used to record the time when the execution of the performance optimization strategy ends, and change the pre-state to the end state.
[0241] In a possible implementation manner, the performance optimization strategy includes increasing the working frequency of the processor.
[0242] In a possible implementation manner, the types of the target instrumentation points further include the start pre-instrumentation points; the instrumentation module 1601 is specifically configured to: if the target instrumentation point is the start instrumentation point, determine whether the pre-state is the start pre-state based on the instrumentation point information corresponding to the start instrumentation point; if so, it is determined that the trigger conditions corresponding to the start instrumentation point are satisfied; if not, it is determined that the trigger conditions corresponding to the start instrumentation point are not satisfied.
[0243] In a possible implementation manner, the types of the target instrumentation points further include the delayed pre-instrumentation points; the instrumentation module 1601 is specifically configured to: when the target instrumentation point is a delayed instrumentation point, determine whether the pre-state is the delayed pre-state based on the instrumentation point information corresponding to the delayed instrumentation point; if so, it is determined that the trigger conditions corresponding to the delayed instrumentation point are satisfied; if not, it is determined that the trigger conditions corresponding to the delayed instrumentation point are not satisfied.
[0244] In a possible implementation manner, the staking module 1601 is specifically configured to: if the target stake point is the delay pre-stake point, determine whether the pre-state is the start state based on the stake point information corresponding to the delay pre-stake point; if so, determine that the trigger condition corresponding to the delay pre-stake point is satisfied; if not, determine that the trigger condition corresponding to the delay pre-stake point is not satisfied.
[0245] In a possible implementation manner, the performance management module 1602 is further configured to: if the target stake point is the start pre-stake point and the trigger condition corresponding to the start pre-stake point is satisfied, change the pre-state to the start pre-state; if the target stake point is the start stake point and the trigger condition corresponding to the start stake point is satisfied, trigger the execution of the performance optimization strategy, record the time when the performance optimization strategy is triggered, and change the pre-state to the start state; if the target stake point is the delay pre-stake point and the trigger condition corresponding to the delay pre-stake point is satisfied, change the pre-state to the delay pre-state.
[0246] In a possible implementation manner, the performance management module 1602 is specifically configured to: if the target stake point is the delay stake point and the trigger condition corresponding to the delay stake point is satisfied, send a delay message, where the delay message is used to trigger the end stake point after the preset time; within the preset time when the delay message is waiting in the message queue and during the process of executing the next target function, continue to determine whether the trigger condition of the delay stake point is currently satisfied; if satisfied, remove the previously sent delay message from the message queue, send the latest delay message, and update the latest delay message to the message queue; if not satisfied, trigger the end stake point after the preset time of the delay message has passed.
[0247] In a possible implementation manner, the end stake point is further configured to record the time when the performance optimization strategy ends and change the pre-state to the end state; the performance management module 1602 is further configured to: when the end stake point is triggered, trigger the end of the performance optimization strategy, record the time when the performance optimization strategy ends, and change the pre-state to the end state.
[0248] It should be noted that for the functions of each module in the performance optimization system 1600 described in the embodiments of the present application, reference may be made to the relevant descriptions in the foregoing method embodiments, and details will not be repeated here. It can be understood that the devices and methods provided in the embodiments of the present application can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For example, the above division of modules or units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces, and the indirect couplings or communication connections of devices or units can be in electrical, mechanical or other forms.
[0249] Please refer to Figure 17 , Figure 17 which is a schematic hardware structure diagram of another electronic device provided in the embodiments of the present application. As Figure 17 shown, the electronic device 1700 includes at least one processor 1701 and a memory 1702. Among them, the processor 1701 is coupled to the memory 1702, and the coupling in the embodiments of the present application can be a communication connection, which can be electrical or in other forms. The processor 1701 and the memory 1702 can be connected through a bus 1703. Specifically, the memory 1702 is used to store program instructions. The processor 1701 is used to call the program instructions stored in the memory 1702, so that the electronic device 1700 can execute the steps in the method for dividing a geographical fence provided in the embodiments of the present application. The descriptions of its various components and related steps can be referred to above, and details will not be repeated here.
[0250] It should be noted that the electronic device 1700 provided in the embodiments of the present application may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The components shown in the figure can be implemented in hardware, software, or any combination of software and hardware.
[0251] The embodiments of the present application also provide a computer-readable storage medium, wherein the computer-readable storage medium can store a program, and when the computer program is executed by a processor, it realizes some or all of the steps of any one of the methods for dividing a geographical fence recorded in the foregoing method embodiments.
[0252] The embodiments of the present application also provide a computer program, which includes instructions, and when the computer program is executed by a computing device, the computing device can execute some or all of the steps of any one of the foregoing methods for dividing a geographical fence.
[0253] In the above embodiments, the descriptions of the respective embodiments each have their own focuses. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0254] As used in the above embodiments, depending on the context, the term "when..." can be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if detecting (the stated condition or event)" can be interpreted to mean "if determining..." or "in response to determining..." or "when detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)".
[0255] It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps may be performed in other sequences or simultaneously, or some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present application. It should also be noted that the features and functions of two or more devices according to the present disclosure can be embodied in one device. Conversely, the features and functions of one device described above can be further divided and embodied by multiple devices.
[0256] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in this application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line) or wirelessly (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk).
[0257] Those of ordinary skill in the art can understand that all or part of the processes in the above method embodiments can be completed by relevant hardware instructed by a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. The aforementioned storage medium includes various media that can store program codes, such as ROM or random access memory RAM, magnetic disks, or optical discs.
[0258] In summary, the above description is only an example of the technical solution of this application and is not intended to limit the protection scope of this application. Any modifications, equivalent replacements, improvements, etc. made based on the disclosure of this application shall be included within the protection scope of this application.< / canvas> < / video> < / videoview> < / imgview> < / textview>
Claims
1. An interpreter-based performance optimization method, characterized in that, The method includes: Performing instrumentation Hook processing on the target function to determine the target instrumentation point corresponding to the target function; the target function is the function currently being interpreted and executed by the interpreter, and one target function corresponds to one target instrumentation point; When the target function is executed, determining whether the triggering condition of the target instrumentation point is currently satisfied; the types of the target instrumentation points include start instrumentation points and delay instrumentation points, the start instrumentation point is used to trigger the execution of the performance optimization strategy, the delay instrumentation point is used to trigger an end instrumentation point after a preset time, and the end instrumentation point is used to trigger the end of the performance optimization strategy; If the target instrumentation point is a delay instrumentation point and the triggering condition corresponding to the delay instrumentation point is satisfied, then terminate the preset time corresponding to the previously triggered delay instrumentation point, start the preset time corresponding to the current delay instrumentation point, and trigger the end instrumentation point after the preset time.
2. The method according to claim 1, wherein The method further includes: Obtaining function information of the function to be interpreted and executed, where the function information includes the function name of the function; Based on the function information and a pre-obtained configuration file, determining whether the function is a critical function, where the configuration file includes function names corresponding to one or more critical functions respectively; In the case where the function is the critical function, determining the function as the target function.
3. The method according to claim 2, wherein The determining whether the function is a critical function based on the function information and the pre-obtained configuration file includes: Based on the function information and the configuration file, determining whether there is a function name in the configuration file that is the same as the function name of the function; If so, determining the function as the corresponding critical function; If not, determining the function as a non-critical function.
4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: Based on the target instrumentation point, determining the instrumentation point information corresponding to the target instrumentation point; the instrumentation point information includes location information, triggering conditions, and triggering rules; the location information is used to indicate the instrumentation position of the target instrumentation point in the target function, the triggering condition is used to indicate the condition for the target instrumentation point to be triggered, and the triggering rule is used to indicate the operation to be performed when the target instrumentation point is triggered.
5. The method according to claim 4, wherein The determining whether the triggering condition of the target instrumentation point is currently satisfied when the target function is executed includes: When the target function is executed, determining whether the triggering condition of the target instrumentation point is currently satisfied based on the instrumentation point information corresponding to the target function.
6. The method according to any one of claims 1-5, characterized in that, The types of the target instrumentation points further include start pre-instrumentation points and / or delay pre-instrumentation points; the start pre-instrumentation point is used to change the pre-state to the start pre-state, the delay pre-instrumentation point is used to change the pre-state to the delay pre-state, and the pre-state is the program state before executing the target function corresponding to the target instrumentation point.
7. The method according to claim 6, wherein The start instrumentation point is further used to record the time when the performance optimization strategy is triggered to be executed and change the pre-state to the start state; the end instrumentation point is further used to record the time when the execution of the performance optimization strategy ends and change the pre-state to the end state.
8. The method according to any one of claims 1-7, characterized in that, The performance optimization strategy includes increasing the working frequency of the processor.
9. The method according to any one of claims 6-8, characterized in that, The type of the target stake point further includes the start pre-stake point; judging whether the trigger condition of the target stake point is currently satisfied includes: If the target stake point is the start stake point, judging whether the pre-state is the start pre-state based on the stake point information corresponding to the start stake point; If so, it is judged that the trigger condition corresponding to the start stake point is satisfied; if not, it is judged that the trigger condition corresponding to the start stake point is not satisfied.
10. The method according to any one of claims 6-9, characterized in that, The type of the target stake point further includes the delay pre-stake point; judging whether the trigger condition of the target stake point is currently satisfied includes: When the target stake point is a delay stake point, judging whether the pre-state is the delay pre-state based on the stake point information corresponding to the delay stake point; If so, it is judged that the trigger condition corresponding to the delay stake point is satisfied; if not, it is judged that the trigger condition corresponding to the delay stake point is not satisfied.
11. The method according to any one of claims 6-10, characterized in that, Judging whether the trigger condition of the target stake point is currently satisfied includes: If the target stake point is the delay pre-stake point, judging whether the pre-state is the start state based on the stake point information corresponding to the delay pre-stake point; If so, it is judged that the trigger condition corresponding to the delay pre-stake point is satisfied; if not, it is judged that the trigger condition corresponding to the delay pre-stake point is not satisfied.
12. The method according to any one of claims 6-11, characterized in that, The method further includes: If the target stake point is the start pre-stake point and the trigger condition corresponding to the start pre-stake point is satisfied, then change the pre-state to the start pre-state; If the target stake point is the start stake point and the trigger condition corresponding to the start stake point is satisfied, then trigger the execution of the performance optimization strategy, record the time when the performance optimization strategy is triggered, and change the pre-state to the start state; If the target stake point is the delay pre-stake point and the trigger condition corresponding to the delay pre-stake point is satisfied, then change the pre-state to the delay pre-state.
13. The method according to any one of claims 1-12, characterized in that, The step that if the target stake point is a delay stake point and the trigger condition corresponding to the delay stake point is satisfied, then terminate the preset time corresponding to the previously triggered delay stake point, start the preset time corresponding to the current delay stake point, and trigger the end stake point after the preset time includes: If the target stake point is the delay stake point and the trigger condition corresponding to the delay stake point is satisfied, then send a delay message, and the delay message is used to trigger the end stake point after the preset time; During the preset time when the delay message is waiting in the message queue and during the process of executing the next target function, continue to judge whether the trigger condition of the delay stake point is currently satisfied; If satisfied, remove the previously sent delay message from the message queue, send the latest delay message at the same time, and update the latest delay message to the message queue; If not satisfied, trigger the end stake point after the preset time of the delay message.
14. The method according to any one of claims 6 - 13, characterized in that, The end stake point is further used to record the time when the performance optimization strategy ends, change the pre-state to the end state; the method further includes: When the end stake point is triggered, the performance optimization strategy is triggered to end. Meanwhile, the time when the performance optimization strategy ends is recorded, and the pre-state is changed to the end state.
15. An interpreter-based performance optimization system, characterized in that, The system includes an instrumentation module and a performance management module; The instrumentation module is used for: Performing instrumentation Hook processing on the target function to determine the target stake point corresponding to the target function; the target function is the function currently being interpreted and executed by the interpreter, and one target function corresponds to one target stake point; When the target function is executed, it is judged whether the triggering condition of the target stake point is currently satisfied; the types of the target stake points include a start stake point and a delay stake point. The start stake point is used to trigger the execution of the performance optimization strategy, the delay stake point is used to trigger the end stake point after a preset time, and the end stake point is used to trigger the end of the performance optimization strategy; The performance management module is used for: If the target stake point is a delay stake point and the triggering condition corresponding to the delay stake point is satisfied, the preset time corresponding to the previous triggered delay stake point is terminated, the preset time corresponding to the current delay stake point is started, and the end stake point is triggered after the preset time.
16. An electronic device, characterized in that, The electronic device includes a memory and a processor. Among them, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the method according to any one of claims 1-14.
17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1-14 is implemented.
18. A computer program, characterized in that, The computer program includes instructions, and the computer program is executed by a computing device to implement the method according to any one of claims 1-14.
Citation Information
Patent Citations
Method for reducing power consumption of mobile terminal and mobile terminal
CN106095059A
Method for triggering and controlling Packet-In message
CN107809385A
Instrumentation method and system based on interpreter and related electronic equipment
CN116467221A
Method of collecting and tracing call chain and electronic device
WO2021190354A1