Function time consumption processing method and device, equipment and storage medium

By collecting and recording the correspondence between the wall-mounted timestamps and CPU timestamps of the objective function, the problem of CPU time-consuming determination and resource consumption in the existing technology is solved, and accurate CPU time-consuming determination and application performance improvement are achieved.

CN119938458APending Publication Date: 2025-05-06BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311460195.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-03
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

In the prior art, CPU time-consuming determination methods consume resources, seriously affecting application performance, and need to reduce resource consumption to improve performance.

Method used

By collecting the wall hanging timestamp in response to the execution event of the objective function, the time difference between it and the target wall hanging timestamp in the preset timestamp list is determined. If it is greater than the preset accuracy threshold, the CPU timestamp is collected and the correspondence between it and the wall hanging timestamp is recorded to determine the CPU time-consuming of the objective function.

Benefits of technology

Based on the preset timestamp list that records the correspondence between the CPU timestamp and the wall timestamp, it accurately determines the CPU time-consuming of the objective function, which reduces the resource consumption during the CPU time-consuming determination process and improves the performance of the application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119938458A_ABST
    Figure CN119938458A_ABST
Patent Text Reader

Abstract

The invention provides a function time consumption processing method and device, equipment and a storage medium, and the method comprises the steps: responding to a target execution event corresponding to a first target function, and collecting a wall-mounted timestamp as a first wall-mounted timestamp of the first target function; determining a time difference value between the first wall-mounted timestamp and a target wall-mounted timestamp in a preset timestamp list; if it is determined that the time difference is larger than the preset progress threshold value, CPU timestamps are collected, and the corresponding relation between the CPU timestamps and the first wall-mounted timestamps is recorded in a preset timestamp list; wherein the preset timestamp list is used for determining the CPU time consumption of the first target function. Visibly, according to the embodiment of the invention, the CPU time consumption of the first target function can be determined based on the preset timestamp list in which the corresponding relationship between the CPU timestamp and the first wall-mounted timestamp is recorded, so that the resource consumption in the CPU time consumption determination process is reduced, and the performance of the application program is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing, and in particular to a method, device, equipment and storage medium for time-consuming function processing. Background Art

[0002] In the process of application development or use, it is usually necessary to continuously optimize the relevant source code to improve the performance of the application. For example, the relevant source code can be optimized by analyzing the CPU time consumption corresponding to the function. The current method of determining the CPU time consumption is relatively resource-intensive and seriously affects the performance of the application.

[0003] Therefore, how to reduce the resource consumption in the process of determining the CPU time consumption and improve the performance of the application is a technical problem that needs to be solved urgently. Summary of the invention

[0004] In order to solve the above technical problems, an embodiment of the present disclosure provides a method for time-consuming function processing.

[0005] In a first aspect, the present disclosure provides a method for processing time-consuming functions, the method comprising:

[0006] In response to a target execution event corresponding to the first target function, a wall-hanging timestamp is collected as a first wall-hanging timestamp of the first target function; wherein the target execution event includes a preset start execution event and a preset end execution event during the execution of the first target function;

[0007] Determine a time difference between the first wall-mounting timestamp and a target wall-mounting timestamp in a preset timestamp list; wherein the target wall-mounting timestamp is the latest recorded wall-mounting timestamp in the preset timestamp list;

[0008] If it is determined that the time difference is greater than a preset accuracy threshold, the CPU timestamp is collected, and the correspondence between the CPU timestamp and the first wall-mounted timestamp is recorded in a preset timestamp list; wherein the preset timestamp list is used to determine the CPU time consumption of the first objective function.

[0009] In an optional implementation manner, the preset timestamp list includes a start execution wall mounting timestamp and an end execution wall mounting timestamp of the first objective function, and the method further includes:

[0010] Based on the preset timestamp list, a time difference between CPU timestamps corresponding to the start execution wallmounting timestamp and the end execution wallmounting timestamp of the first objective function is determined as the CPU time consumption of the first objective function.

[0011] In an optional implementation manner, the method further includes:

[0012] Determine the function time consumption of the first objective function based on the start execution wall mounting timestamp and the end execution wall mounting timestamp of the first objective function;

[0013] The CPU time consumption type to which the first objective function belongs is determined according to a ratio between the CPU time consumption of the first objective function and the function time consumption of the first objective function.

[0014] In an optional implementation manner, the step of collecting a wall-hanging timestamp in response to a target execution event corresponding to the first target function as a first wall-hanging timestamp of the first target function further includes:

[0015] During the code compilation phase of the target application, the first target function is determined based on pre-configured function features; wherein the source code of the target application includes the first target function.

[0016] In an optional implementation manner, the method further includes:

[0017] A preset function code is inserted into the target code position of the first target function; wherein the preset function code is used to collect the wall-mounting timestamp and the CPU timestamp.

[0018] In an optional implementation, the first objective function is at least one type of function selected from the group consisting of a lifecycle function, a task entry function, and a time-consuming characteristic function.

[0019] In an optional implementation, the CPU time consumed by the first objective function is used to optimize source code related to the first objective function.

[0020] In a second aspect, the present disclosure provides a time-consuming function processing device, the device comprising:

[0021] A first collection module, configured to collect a wall-hanging timestamp in response to a target execution event corresponding to a first target function, as a first wall-hanging timestamp of the first target function; wherein the target execution event includes a preset start execution event and a preset end execution event during the execution of the first target function;

[0022] A first determining module, configured to determine a time difference between the first wall-mounting timestamp and a target wall-mounting timestamp in a preset timestamp list; wherein the target wall-mounting timestamp is the latest recorded wall-mounting timestamp in the preset timestamp list;

[0023] The second acquisition module is used to collect the CPU timestamp if it is determined that the time difference is greater than a preset accuracy threshold, and record the correspondence between the CPU timestamp and the first wall-mounted timestamp in a preset timestamp list; wherein the preset timestamp list is used to determine the CPU time consumption of the first objective function.

[0024] In a third aspect, the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the above method.

[0025] In a fourth aspect, the present disclosure provides a time-consuming function processing device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method when executing the computer program.

[0026] In a fifth aspect, the present disclosure provides a computer program product, wherein the computer program product comprises a computer program / instructions, and the computer program / instructions implement the above method when executed by a processor.

[0027] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has at least the following advantages:

[0028] The disclosed embodiment provides a function time-consuming processing method. First, in response to a target execution event corresponding to a first target function, a wall-mounted timestamp is collected as a first wall-mounted timestamp of the first target function; wherein the target execution event includes a preset start execution event and a preset end execution event during the execution of the first target function; then, a time difference between the first wall-mounted timestamp and a target wall-mounted timestamp in a preset timestamp list is determined; wherein the target wall-mounted timestamp is the latest recorded wall-mounted timestamp in the preset timestamp list; if it is determined that the time difference is greater than a preset progress threshold, a CPU timestamp is collected, and the corresponding relationship between the CPU timestamp and the first wall-mounted timestamp is recorded in the preset timestamp list; wherein the preset timestamp list is used to determine the CPU time consumption of the first target function.

[0029] It can be seen that the embodiment of the present disclosure can determine the CPU time consumption of the first objective function based on the preset timestamp list that records the correspondence between the CPU timestamp and the first wall-mounted timestamp, thereby reducing the resource consumption in the CPU time consumption determination process and improving the performance of the application. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0031] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0032] Figure 1 A flowchart of a method for processing time-consuming functions provided by an embodiment of the present disclosure;

[0033] Figure 2 A schematic diagram of a preset timestamp list provided in an embodiment of the present disclosure;

[0034] Figure 3 A schematic diagram of another preset timestamp list provided in an embodiment of the present disclosure;

[0035] Figure 4 A schematic diagram of determining CPU timestamp and CPU time consumption provided by an embodiment of the present disclosure;

[0036] Figure 5 A flowchart of another method for processing time-consuming functions provided by an embodiment of the present disclosure;

[0037] Figure 6 A schematic diagram of the structure of a time-consuming function processing device provided in an embodiment of the present disclosure;

[0038] Figure 7 A schematic diagram of the structure of a time-consuming function processing device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0039] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.

[0040] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0041] In the process of application development or use, it is usually necessary to continuously optimize the relevant source code to improve the performance of the application. For example, the relevant source code can be optimized by analyzing the CPU time consumption corresponding to the function. The current method of determining the CPU time consumption is relatively resource-intensive and seriously affects the performance of the application.

[0042] Therefore, how to reduce the resource consumption in the process of determining the CPU time consumption and improve the performance of the application is a technical problem that needs to be solved urgently.

[0043] To this end, an embodiment of the present disclosure provides a function time-consuming processing method. First, in response to a target execution event corresponding to a first target function, a wall-mounted timestamp is collected as a first wall-mounted timestamp of the first target function; wherein the target execution event includes a preset start execution event and a preset end execution event during the execution of the first target function; then the time difference between the first wall-mounted timestamp and the target wall-mounted timestamp in a preset timestamp list is determined; wherein the target wall-mounted timestamp is the latest recorded wall-mounted timestamp in the preset timestamp list; if it is determined that the time difference is greater than a preset progress threshold, a CPU timestamp is collected, and the correspondence between the CPU timestamp and the first wall-mounted timestamp is recorded in the preset timestamp list; wherein the preset timestamp list is used to determine the CPU time consumption of the first target function.

[0044] It can be seen that the embodiment of the present disclosure can determine the CPU time consumption of the first objective function based on the preset timestamp list that records the correspondence between the CPU timestamp and the first wall-mounted timestamp, thereby reducing the resource consumption in the CPU time consumption determination process and improving the performance of the application.

[0045] Based on this, the embodiment of the present disclosure provides a method for processing time-consuming functions, referring to Figure 1 , is a flow chart of a method for processing time-consuming functions provided by an embodiment of the present disclosure, the method specifically comprising:

[0046] S101: In response to a target execution event corresponding to a first target function, collecting a wall mounting timestamp as a first wall mounting timestamp of the first target function.

[0047] The target execution event includes a preset start execution event and a preset end execution event during the execution of the first target function.

[0048] In the disclosed embodiment, the wall time (i.e., wallclocktime) refers to the time elapsed by the clock from the start to the end of the first objective function, i.e., the overall duration of the execution of the first objective function. A timestamp refers to a sequence of characters or coded information. In practical applications, a timestamp can be used to identify an event that occurs at a certain moment. In the disclosed embodiment, a wall time stamp can be used to identify the system time corresponding to a certain moment in the execution of the first objective function.

[0049] In the disclosed embodiment, the target execution event includes a preset start execution event and a preset end execution event during the execution of the first target function, wherein the preset start execution event refers to an event used to trigger the start execution of the first target function. For example, when the start statement in the first target function is executed, the wall timestamp can be collected as the first wall timestamp of the first target function.

[0050] The preset end execution event refers to an event used to trigger the end of execution of the first target function. For example, when a return statement in the first target function is executed, a wall timestamp may be collected as the first wall timestamp of the first target function.

[0051] In an optional implementation, the first objective function may be at least one type of function among a lifecycle function, a task entry function, and a time-consuming characteristic function.

[0052] Among them, life cycle functions may include, for example, Activity life cycle functions, Application life cycle functions, etc.; task entry function refers to the function that each new task is scheduled to execute, such as the run function in the Runnable interface, the call function in the Callable interface, etc.; time-consuming feature functions may include, for example, functions related to the fromJson and toJson methods in the Gson class library, and functions related to the JSONObject object, etc.

[0053] S102: Determine a time difference between the first wall-mounting timestamp and a target wall-mounting timestamp in a preset timestamp list.

[0054] The target wall-mounting timestamp is the wall-mounting timestamp of the latest record in the preset timestamp list.

[0055] In the embodiment of the present disclosure, after the first wall-mounted timestamp of the first objective function is collected, the first wall-mounted timestamp may be compared with a target wall-mounted timestamp in a preset timestamp list to obtain a time difference between the first wall-mounted timestamp and the target timestamp.

[0056] like Figure 2 FIG. 1 is a schematic diagram of a preset timestamp list provided by an embodiment of the present disclosure, wherein: Figure 2 The correspondence between the wall-hanging timestamp and the CPU timestamp is recorded in the .thread ID refers to the ID corresponding to the thread in which the function is executed.

[0057] S103: If it is determined that the time difference is greater than a preset accuracy threshold, a CPU timestamp is collected, and a corresponding relationship between the CPU timestamp and the first wall-mounted timestamp is recorded in a preset timestamp list.

[0058] The preset timestamp list is used to determine the CPU time consumption of the first objective function.

[0059] In the embodiment of the present disclosure, CPU time (i.e., CPUtime) refers to the duration of the CPU occupied by the first target function during the execution process. In practical applications, the performance of the application program can be improved by optimizing the CPU time. The CPU timestamp is the CPU time corresponding to a certain moment during the execution of the first target function.

[0060] In the embodiment of the present disclosure, the preset progress threshold may be determined based on actual needs, for example, may be set to 5 milliseconds.

[0061] For example, when the target execution event corresponding to the first target function is monitored, the wall-hanging timestamp, for example, 14:24:00, is collected as the first wall-hanging timestamp of the first target function, and then the first wall-hanging timestamp (i.e., 14:24:00) is calculated and Figure 2 The time difference between the target wall-mounted timestamp (i.e., 14:23:20) in the preset timestamp list shown is 00:00:40. The time difference 00:00:40 is compared with a preset accuracy threshold (e.g., 5 milliseconds). When it is determined that the time difference is greater than the preset accuracy threshold, the CPU timestamp, such as 14:23:30, is collected, and the corresponding relationship between the CPU timestamp (i.e., 14:23:30) and the first wall-mounted timestamp (i.e., 14:24:00) is recorded in the preset timestamp list.

[0062] In the function time-consuming processing method provided by the embodiment of the present disclosure, first, in response to the target execution event corresponding to the first target function, a wall-mounted timestamp is collected as the first wall-mounted timestamp of the first target function; wherein the target execution event includes a preset start execution event and a preset end execution event during the execution of the first target function; then the time difference between the first wall-mounted timestamp and the target wall-mounted timestamp in the preset timestamp list is determined; wherein the target wall-mounted timestamp is the wall-mounted timestamp of the latest record in the preset timestamp list; if it is determined that the time difference is greater than the preset progress threshold, the CPU timestamp is collected, and the correspondence between the CPU timestamp and the first wall-mounted timestamp is recorded in the preset timestamp list; wherein the preset timestamp list is used to determine the CPU time consumption of the first target function.

[0063] It can be seen that the embodiment of the present disclosure can determine the CPU time consumption of the first objective function based on the preset timestamp list that records the correspondence between the CPU timestamp and the first wall-mounted timestamp, thereby reducing the resource consumption in the CPU time consumption determination process and improving the performance of the application.

[0064] In an optional implementation, since the target execution event may include a preset start execution event and a preset end execution event, when a preset start execution event is monitored during the execution of the first target function, the collected wall-mounted timestamp may be used as the start execution wall-mounted timestamp of the first target function, and, when a preset end execution event is monitored during the execution of the first target function, the collected wall-mounted timestamp may be used as the end execution wall-mounted timestamp of the first target function.

[0065] In actual applications, after collecting the start execution wall-hanging timestamp and the end execution wall-hanging timestamp of the first target function, the start execution wall-hanging timestamp and the end execution wall-hanging timestamp can be recorded in a preset timestamp list, so that the CPU time consumption of the first target function can be determined based on the preset timestamp list later.

[0066] Specifically, based on the preset timestamp list, the time difference between the CPU timestamps corresponding to the start wallhanging timestamp and the end wallhanging timestamp of the first objective function is determined as the CPU time consumption of the first objective function.

[0067] like Figure 3 FIG. 1 is a schematic diagram of another preset timestamp list provided in an embodiment of the present disclosure, wherein the preset timestamp list may include Figure 3 (a) shows a list of correspondences between wall time stamps and CPU time stamps, and Figure 3 The record shown in (b) is a list of the function's start execution wall timestamp and end execution wall timestamp.

[0068] In actual applications, in order to enable the application to continue the state before restart after a fault restart, the corresponding relationship between the wall timestamp and the CPU timestamp can be recorded based on the persistent storage unit. In addition, in order to reduce the memory usage of the application during data storage, the function's start execution wall timestamp and end execution wall timestamp can also be stored in the cache unit.

[0069] Specifically, Figure 3 (b) records the wall timestamps collected by thread 1 during the execution of function 10010 and function 12345, where "type" is used to identify the type of target execution event corresponding to the first target function. Specifically, the "start" type is used to indicate the wall timestamp corresponding to the preset start execution event of the first target function, i.e., the start execution wall timestamp; the "end" type is used to indicate the wall timestamp corresponding to the preset end execution event of the first target function, i.e., the end execution wall timestamp.

[0070] For example, when the preset start execution event corresponding to function 10010 is detected, the start execution wall timestamp of function 10010, i.e. 14:21:00, is collected and recorded in Figure 3 (b) is a preset timestamp list shown in FIG. 10; for another example, when the preset end execution event corresponding to function 10010 is detected, the end execution wall timestamp of function 10010, i.e., 14:23:20, is collected and recorded in Figure 3 (b) is a list of preset timestamps shown.

[0071] In practical applications, it can be based on Figure 3 (a) and Figure 3 (b) shows the preset timestamp list, and calculates the CPU time consumption of the first objective function. Specifically, first, based on the function identifier of the first objective function, Figure 3 (b) determining the start execution wall hanging timestamp and the end execution wall hanging timestamp of the first objective function; then based on the start execution wall hanging timestamp, Figure 3 (a) determines the CPU timestamp corresponding to the start wall-hanging timestamp and determines the CPU timestamp corresponding to the end wall-hanging timestamp; then calculates the time difference between the CPU timestamp corresponding to the start wall-hanging timestamp and the CPU timestamp corresponding to the end wall-hanging timestamp as the CPU time consumption of the first objective function. By analyzing the CPU time consumption of the first objective function, the technician can optimize the source code related to the first objective function, thereby further improving the performance of the application.

[0072] like Figure 4 As shown, a schematic diagram of determining CPU timestamp and CPU time consumption provided by an embodiment of the present disclosure is provided. Specifically, assuming that the first objective function is function 10010, first, determine the start execution wall-hanging timestamp (14:21:00) and the end execution wall-hanging timestamp (14:23:20) of the first objective function 10010; then, based on the start execution wall-hanging timestamp (14:21:00), determine the CPU timestamp (14:21:20) corresponding to the start execution wall-hanging timestamp (14:21:00) and the CPU timestamp (14:22:10) corresponding to the end execution wall-hanging timestamp (14:23:20); further, calculate the time difference between the CPU timestamp (14:21:20) corresponding to the start execution wall-hanging timestamp and the CPU timestamp (14:22:10) corresponding to the end execution wall-hanging timestamp, that is, 00:00:50, as the CPU time consumption of the first objective function 10010.

[0073] In actual applications, since functions belong to different CPU time-consuming types, the corresponding code optimization processing methods are not the same for functions of different CPU time-consuming types. Therefore, before optimizing the relevant source code of the function, it is also necessary to analyze the CPU time-consuming type of the function to further improve the performance of the application.

[0074] In the disclosed embodiment, first, the function timing of the first objective function is determined based on the start execution wall-mounting timestamp and the end execution wall-mounting timestamp of the first objective function; then, the CPU timing type to which the first objective function belongs is determined based on the ratio between the CPU timing of the first objective function and the function timing of the first objective function.

[0075] In the disclosed embodiment, the CPU time consumption type may include CPU intensive (i.e. on-CPU time consumption) and CPU non-intensive (i.e. off-CPU time consumption); wherein, the CPU time consumption of a CPU intensive function is determined by the code of the function itself, and the optimization of a CPU intensive function is mainly aimed at optimizing the complexity of the relevant source code and optimizing the position in the task thread, while the CPU time consumption of a CPU non-intensive function is determined by the execution process of other functions or threads. By determining the CPU time consumption type to which the first target function belongs, it can further facilitate the technician to optimize the relevant source code of the first target function.

[0076] In practical applications, a function whose ratio between CPU time consumption and function time consumption is greater than a preset ratio threshold value can be determined as a CPU-intensive function, and a function whose ratio between CPU time consumption and function time consumption is less than or equal to a preset ratio threshold value can be determined as a CPU-intensive function. The preset ratio threshold value can be set to 0.5:1.

[0077] For example, assuming that the first objective function is function 10010, Figure 3 It can be seen that the start execution wall-hanging timestamp of the first objective function 10010 is 14:21:00, and the end execution wall-hanging timestamp is 14:23:20, so it can be determined that the function time of the first objective function 10010 is 00:02:20; then, the ratio between the CPU time (00:00:50) and the function time (00:02:20) of the first objective function 10010 is calculated, which is 5:14; since the ratio 5:14 is less than the preset ratio threshold (0.5:1), it can be determined that the CPU time consumption type of the first objective function 10010 is CPU non-intensive (i.e., off-CPU time consumption type).

[0078] It can be seen that the embodiment of the present disclosure can determine the CPU time consumption type of the first objective function based on the ratio between the CPU consumption of the first objective function and the function consumption of the first objective function, further facilitating technicians to optimize the relevant source code of the first objective function.

[0079] In actual applications, since some functions may be in a waiting state during execution, no CPU time consumption will occur at this time, or when the function is communicating across processes, no CPU time consumption will occur at this time. When optimizing the performance of the application, it is actually only necessary to perform CPU time consumption analysis on the first target function that has CPU time consumption, which can reduce the frequency of collecting COU timestamps, thereby optimizing the performance of the application. Therefore, before collecting the first wall-hanging timestamp of the first target function, the embodiment of the present disclosure also needs to determine the first target function.

[0080] Based on this, the embodiment of the present disclosure also provides a method for processing time-consuming functions, referring to Figure 5 , is a flowchart of another method for processing time-consuming functions provided by an embodiment of the present disclosure. Specifically, the method includes:

[0081] S501: During the code compilation phase of the target application, the first target function is determined based on pre-configured function features.

[0082] The source code of the target application includes the first target function.

[0083] In an embodiment of the present disclosure, in response to a target execution event corresponding to a first target function, a wall mounting timestamp is collected as a first wall mounting timestamp of the first target function. Furthermore, during the code compilation phase of the target application, the first target function can be determined based on pre-configured function features.

[0084] In the disclosed embodiment, function features can be used to characterize the CPU time consumption of a function during its execution. By pre-configured function features, functions that consume CPU time can be screened out, thereby further reducing resource consumption during CPU timestamp collection and improving application performance.

[0085] In the disclosed embodiment, the source code of the target application includes a first target function. In actual applications, a function having function features can be identified as the first target function during the code compilation phase of the target application through pre-configured function features.

[0086] In an optional implementation, during the code compilation stage of the target application, after determining the first target function based on function characteristics, such as a lifecycle function, the lifecycle function can be marked. Subsequently, during the execution of the source code of the target application, the step of collecting the wall timestamp as the first wall timestamp of the first target function is performed only when the code where the lifecycle function is located is executed.

[0087] S502: Inserting a preset function code into the target code position of the first target function.

[0088] The preset function code is used to collect the wall-mounting timestamp and the CPU timestamp.

[0089] In the embodiment of the present disclosure, after determining the first target function, a preset function code may be inserted at the target code position of the first target function, so that in the subsequent process of the first target function, the wall hanging timestamp and the CPU timestamp may be collected through the preset function.

[0090] In the embodiment of the present disclosure, the target code position of the first target function may include the start running position and the end running position in the source code of the first target function; specifically, the preset function code is inserted at the start running position in the source code of the first target function, and the preset function code is inserted at the end running position in the source code of the first target function, so that when the first target function is subsequently executed, the start execution wall hanging timestamp and the end execution wall hanging timestamp of the first target function can be collected through the preset function code.

[0091] In an optional implementation, the preset function code may also include a first preset function code and a second preset function code, wherein the first preset function code is used to collect the start execution wall-hanging timestamp of the first target function, and the second preset function code is used to collect the end execution wall-hanging timestamp of the first target function.

[0092] Specifically, when a preset start execution event corresponding to the first target function is monitored, the start execution wall-mounted timestamp of the first target function is collected based on the first preset function code, and, when a preset end execution event corresponding to the first target function is monitored, the end execution wall-mounted timestamp of the first target function is collected based on the second preset function code, so that the CPU time consumption of the first target function can be determined based on the CPU timestamp corresponding to the start execution wall-mounted timestamp of the first target function and the CPU timestamp corresponding to the end execution wall-mounted timestamp of the first target function, so that technical personnel can analyze the CPU time consumption and optimize the relevant source code of the first target function.

[0093] For example, assuming that the first target function is named onCreate(), a first preset function code Trace.bc() is defined at the start of the first target function, and a second preset function code Trace.ec() is defined at the end of the first target function.

[0094] The first preset function code Trace.bc() can be used to collect the start execution wall-hanging timestamp of the first target function onCreate(), and the second preset function code Trace.ec() can be used to collect the end execution wall-hanging timestamp of the first target function onCreate().

[0095] S503: In response to a target execution event corresponding to the first target function, a wall-mounting timestamp is collected based on a preset function code as a first wall-mounting timestamp of the first target function.

[0096] The target execution event includes a preset start execution event and a preset end execution event during the execution of the first target function.

[0097] In the disclosed embodiment, since the preset function code can be used to collect the wall-hanging timestamp, during the process of executing the relevant source code of the first target function, when the target execution event corresponding to the first target function is monitored, the wall-hanging timestamp can be collected based on the preset function code as the first wall-hanging timestamp of the first target function.

[0098] S504: Determine a time difference between the first wall-mounting timestamp and a target wall-mounting timestamp in a preset timestamp list.

[0099] The target wall-mounting timestamp is the wall-mounting timestamp of the latest record in the preset timestamp list.

[0100] S505: If it is determined that the time difference is greater than a preset accuracy threshold, a CPU timestamp is collected based on a preset function code, and a corresponding relationship between the CPU timestamp and the first wall-mounted timestamp is recorded in a preset timestamp list.

[0101] The preset timestamp list is used to determine the CPU time consumption of the first objective function.

[0102] In the disclosed embodiment, since the preset function code can be used to collect the CPU timestamp of the first target function, when it is determined that the time difference is greater than the preset accuracy threshold, the CPU timestamp can be collected based on the preset function code, and the correspondence between the CPU timestamp and the first wall-mounted timestamp can be recorded in the preset timestamp list.

[0103] It can be seen that the embodiment of the present disclosure can determine the first target function based on pre-configured function characteristics during the code compilation stage of the target application, thereby further reducing the resource consumption during the CPU timestamp collection process, thereby improving the performance of the application.

[0104] Based on the above method embodiment, the present disclosure also provides a function time-consuming processing device, referring to Figure 6 , is a schematic diagram of a structure of a time-consuming function processing device provided by an embodiment of the present disclosure, the device comprising:

[0105] A first acquisition module 601 is used to collect a wall-mounting timestamp in response to a target execution event corresponding to a first target function as a first wall-mounting timestamp of the first target function; wherein the target execution event includes a preset start execution event and a preset end execution event during the execution of the first target function;

[0106] A first determining module 602 is used to determine a time difference between the first wall-mounting timestamp and a target wall-mounting timestamp in a preset timestamp list; wherein the target wall-mounting timestamp is the latest recorded wall-mounting timestamp in the preset timestamp list;

[0107] The second acquisition module 603 is used to collect the CPU timestamp if it is determined that the time difference is greater than a preset accuracy threshold, and record the correspondence between the CPU timestamp and the first wall-mounted timestamp in a preset timestamp list; wherein the preset timestamp list is used to determine the CPU time consumption of the first objective function.

[0108] In an optional implementation manner, the preset timestamp list includes a start execution wall mounting timestamp and an end execution wall mounting timestamp of the first objective function, and the device further includes:

[0109] The second determination module is used to determine, based on the preset timestamp list, a time difference between CPU timestamps corresponding to the start execution wallmounting timestamp and the end execution wallmounting timestamp of the first objective function, as the CPU time consumption of the first objective function.

[0110] In an optional implementation, the device further includes:

[0111] A third determination module, configured to determine a function time consumption of the first objective function based on a start execution wall mounting timestamp and an end execution wall mounting timestamp of the first objective function;

[0112] The fourth determination module is used to determine the CPU time consumption type to which the first objective function belongs according to the ratio between the CPU consumption of the first objective function and the function consumption of the first objective function.

[0113] In an optional implementation, the device further includes:

[0114] A fifth determination module is used to determine the first target function based on pre-configured function features during the code compilation phase of the target application; wherein the first target function is included in the source code of the target application.

[0115] In an optional implementation, the device further includes:

[0116] The insertion module is used to insert a preset function code into the target code position of the first target function; wherein the preset function code is used to collect the wall hanging timestamp and the CPU timestamp.

[0117] In an optional implementation, the first objective function is at least one type of function selected from the group consisting of a lifecycle function, a task entry function, and a time-consuming characteristic function.

[0118] In an optional implementation, the CPU time consumed by the first objective function is used to optimize source code related to the first objective function.

[0119] In the function time-consuming processing device provided by the embodiment of the present disclosure, first, in response to the target execution event corresponding to the first target function, a wall-mounted timestamp is collected as the first wall-mounted timestamp of the first target function; wherein the target execution event includes a preset start execution event and a preset end execution event during the execution of the first target function; then the time difference between the first wall-mounted timestamp and the target wall-mounted timestamp in the preset timestamp list is determined; wherein the target wall-mounted timestamp is the wall-mounted timestamp of the latest record in the preset timestamp list; if it is determined that the time difference is greater than the preset progress threshold, the CPU timestamp is collected, and the correspondence between the CPU timestamp and the first wall-mounted timestamp is recorded in the preset timestamp list; wherein the preset timestamp list is used to determine the CPU time consumption of the first target function.

[0120] It can be seen that the embodiment of the present disclosure can determine the CPU time consumption of the first objective function based on the preset timestamp list that records the correspondence between the CPU timestamp and the first wall-mounted timestamp, thereby reducing the resource consumption in the CPU time consumption determination process and improving the performance of the application.

[0121] In addition to the above-mentioned method and apparatus, the embodiments of the present disclosure also provide a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device implements the time-consuming function processing method described in the embodiments of the present disclosure.

[0122] The embodiment of the present disclosure further provides a computer program product, which includes a computer program / instruction. When the computer program / instruction is executed by a processor, the function time-consuming processing method described in the embodiment of the present disclosure is implemented.

[0123] In addition, the embodiment of the present disclosure also provides a function time-consuming processing device, see Figure 7 As shown, it may include:

[0124] Processor 701, memory 702, input device 703 and output device 704. The number of processors 701 in the function time-consuming processing device can be one or more. Figure 7 In some embodiments of the present disclosure, the processor 701, the memory 702, the input device 703 and the output device 704 may be connected via a bus or other means, wherein: Figure 7 The example of connecting through bus is taken in the following.

[0125] The memory 702 can be used to store software programs and modules. The processor 701 executes various functional applications and data processing of the function time-consuming processing device by running the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc. In addition, the memory 702 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. The input device 703 may be used to receive input digital or character information, and to generate signal input related to user settings and function control of the function time-consuming processing device.

[0126] Specifically in this embodiment, the processor 701 will load the executable files corresponding to the processes of one or more applications into the memory 702 according to the following instructions, and the processor 701 will run the applications stored in the memory 702, thereby realizing the various functions of the above-mentioned function time-consuming processing device.

[0127] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0128] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for processing time-consuming functions, characterized in that: The method comprises: In response to a target execution event corresponding to the first target function, a wall-hanging timestamp is collected as a first wall-hanging timestamp of the first target function; wherein the target execution event includes a preset start execution event and a preset end execution event during the execution of the first target function; Determine a time difference between the first wall-mounting timestamp and a target wall-mounting timestamp in a preset timestamp list; wherein the target wall-mounting timestamp is the latest recorded wall-mounting timestamp in the preset timestamp list; If it is determined that the time difference is greater than a preset accuracy threshold, the CPU timestamp is collected, and the correspondence between the CPU timestamp and the first wall-mounted timestamp is recorded in the preset timestamp list; wherein the preset timestamp list is used to determine the CPU time consumption of the first objective function.

2. The method according to claim 1, characterized in that: The preset timestamp list includes a start execution wall-hanging timestamp and an end execution wall-hanging timestamp of the first objective function, and the method further includes: Based on the preset timestamp list, a time difference between CPU timestamps corresponding to the start execution wallmounting timestamp and the end execution wallmounting timestamp of the first objective function is determined as the CPU time consumption of the first objective function.

3. The method according to claim 2, characterized in that The method further comprises: Determine the function time consumption of the first objective function based on the start execution wall mounting timestamp and the end execution wall mounting timestamp of the first objective function; The CPU time consumption type to which the first objective function belongs is determined according to a ratio between the CPU time consumption of the first objective function and the function time consumption of the first objective function.

4. The method according to claim 1, characterized in that Before collecting the wall-mounting timestamp as the first wall-mounting timestamp of the first objective function in response to the target execution event corresponding to the first objective function, the method further includes: During the code compilation phase of the target application, the first target function is determined based on pre-configured function features; wherein the source code of the target application includes the first target function.

5. The method according to claim 4, characterized in that The method further comprises: A preset function code is inserted into the target code position of the first target function; wherein the preset function code is used to collect the wall-mounting timestamp and the CPU timestamp.

6. The method according to claim 1, characterized in that The first objective function is at least one type of function among a life cycle function, a task entry function, and a time-consuming characteristic function.

7. The method according to claim 1, characterized in that The CPU time consumed by the first target function is used to optimize the source code related to the first target function.

8. A live broadcast processing device, characterized in that: The device comprises: A first collection module, configured to collect a wall-hanging timestamp in response to a target execution event corresponding to a first target function, as a first wall-hanging timestamp of the first target function; wherein the target execution event includes a preset start execution event and a preset end execution event during the execution of the first target function; A first determining module, configured to determine a time difference between the first wall-mounting timestamp and a target wall-mounting timestamp in a preset timestamp list; wherein the target wall-mounting timestamp is the latest recorded wall-mounting timestamp in the preset timestamp list; The second acquisition module is used to collect the CPU timestamp if it is determined that the time difference is greater than a preset accuracy threshold, and record the correspondence between the CPU timestamp and the first wall-mounted timestamp in a preset timestamp list; wherein the preset timestamp list is used to determine the CPU time consumption of the first objective function.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the method according to any one of claims 1 to 7.

10. A time-consuming function processing device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.