CN115129390A - Method, device, equipment and medium for determining execution duration of client code interval - Google Patents

Method, device, equipment and medium for determining execution duration of client code interval Download PDF

Info

Publication number
CN115129390A
CN115129390A CN202210689293.3A CN202210689293A CN115129390A CN 115129390 A CN115129390 A CN 115129390A CN 202210689293 A CN202210689293 A CN 202210689293A CN 115129390 A CN115129390 A CN 115129390A
Authority
CN
China
Prior art keywords
node
execution
program code
client
time length
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210689293.3A
Other languages
Chinese (zh)
Inventor
廖露阳
彭飞
邓竹立
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing 58 Information Technology Co Ltd
Original Assignee
Beijing 58 Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing 58 Information Technology Co Ltd filed Critical Beijing 58 Information Technology Co Ltd
Priority to CN202210689293.3A priority Critical patent/CN115129390A/en
Publication of CN115129390A publication Critical patent/CN115129390A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention provides a method, a device, equipment and a medium for determining execution duration of a client code interval. The method is applied to a client, a plurality of nodes are inserted into a program code of the client in advance, each node is a code segment and is used for counting the execution time of the program code from the beginning of execution to the execution of the node; the method comprises the following steps: responding to the starting operation of a user on a client, executing a program code of the client and acquiring a node pairing group issued by a server, wherein the node pairing group comprises a starting node and an ending node; according to the node pairing group, acquiring a first execution time length from the beginning of execution to the beginning of the node and a second execution time length from the beginning of execution to the ending of the node of the program code; and determining the execution time length of the program code from the starting node to the ending node according to the first execution time length and the second execution time length. By the method, the time-consuming data of different code intervals of the client can be flexibly controlled and collected, and the development cost is reduced.

Description

Method, device, equipment and medium for determining execution duration of client code interval
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a medium for determining an execution duration of a client code interval.
Background
With the continuous development of computer technology, the application of the client is more and more extensive, and many problems may exist in the use process of the client, so that the performance optimization needs to be continuously performed on the client. The performance optimization of the client comprises a plurality of aspects, and the running speed (such as the starting speed, the page opening speed and the like) of the good client has a positive effect on improving the user experience. The key for optimizing the client running speed is to find out which time-consuming methods or time-consuming intervals in the client running process, and after the time-consuming methods or the time-consuming intervals are determined, the client running speed can be optimized in a targeted manner. Finding a time-consuming place for performing optimization in the client running process through the related technology is a very effective means for optimizing the speed.
However, in the method for determining the time-consuming interval of the client, it is necessary to explicitly know the execution time length between which code is to be counted when the client program code is developed, and to insert a record point at a specific position of the code. Once the program code is developed, the method can only count the time consumption of the position of the inserted recording point, and if a user wants to insert a new recording point into the program code to count the time consumption of other code intervals or wants to remove some inserted recording points from the code intervals and no longer counts the time consumption of some code intervals, the method can only solve the problem by re-developing a new client version, namely re-writing the program code of the client, which causes the workload of developers to be increased and the development cost of the client to be high.
Disclosure of Invention
The embodiment of the invention provides a method, a device, equipment and a medium for determining execution duration of a client code interval, so as to flexibly control and collect time-consuming data of different code intervals of a client and reduce the workload of developers.
The first aspect of the embodiments of the present invention provides a method for determining an execution duration of a client code interval, which is applied to a client, where a plurality of nodes are pre-inserted into a program code of the client, each node is a code segment and is used to count an execution duration from the beginning of execution to the execution of the program code to the node; the method comprises the following steps:
responding to the starting operation of a user on the client, executing a program code of the client, and acquiring a node pairing group issued by a server, wherein the node pairing group comprises a starting node and an ending node;
acquiring a first execution time length from the beginning of execution to the beginning of execution of the program code to the ending node and a second execution time length from the beginning of execution to the ending node of the program code according to the node pairing group;
and determining the execution time length of the program code from the starting node to the ending node according to the first execution time length and the second execution time length.
Optionally, each node in the plurality of nodes has a unique node identifier; the obtaining, according to the node pairing group, a first execution duration from the start of execution to the start of execution of the program code to the start node, and a second execution duration from the start of execution to the end of execution of the program code to the end node, includes:
when the program code is executed to a first node, acquiring the execution duration of the program code from the beginning of execution to the first node, wherein the first node is any one of the plurality of nodes;
comparing the node identification of the first node with the identification of the end node;
if the node identification of the first node is not matched with the node identification of the end node, determining that the first node is an executed node, and storing the node identification of the executed node and the execution duration of the program code from the beginning of execution to the executed node in an associated manner;
if the node identifier of the first node is matched with the node identifier of the end node, determining that the first node is the end node, and taking the execution time length from the beginning of execution to the end node of the program code as the second execution time length;
determining a target executed node with a node identifier matched with the node identifier of the starting node, reading the execution time length from the beginning of execution to the starting node of the program code stored in association with the node identifier of the starting node according to the node identifier of the target executed node, and taking the read execution time length as the first execution time length.
Optionally, after the client is started, the method further includes:
under the condition that a trigger condition is detected, acquiring a latest node pairing group issued by the server, wherein the latest node pairing group comprises a latest starting node and a latest finishing node; wherein the trigger condition includes at least one of: the user performs specified operation on the client and receives a pull instruction issued by the server;
and determining the execution time length of the program code from the latest starting node to the latest ending node based on the latest node pairing group, and stopping determining the execution time length of the code interval of the node pairing group acquired in history.
Optionally, the node is encapsulated into a macro before inserting the program code, and the macro takes the node identification of the node as a parameter.
Optionally, after determining the execution duration of the program code from the start node to the end node, the method further includes:
and reporting the execution time of the program code from the starting node to the ending node to the server so that the server can visualize the execution time.
A second aspect of the embodiments of the present invention provides a device for determining an execution duration of a client code interval, which is applied to a client, where a plurality of nodes are pre-inserted into a program code of the client, each node is a code segment and is used to count an execution duration from start of execution to execution of the program code to the node; the device comprises:
the first acquisition module is used for responding to the starting operation of a user on the client, executing a program code of the client and acquiring a node pairing group issued by a server, wherein the node pairing group comprises a starting node and an ending node;
a first time length determining module, configured to obtain, according to the node pairing group, a first execution time length from start of execution to execution of the program code to the start node, and a second execution time length from start of execution to execution of the program code to the end node;
and a second duration determining module, configured to determine, according to the first execution duration and the second execution duration, an execution duration from the start node to the end node of the program code.
Optionally, each node in the plurality of nodes has a unique node identifier; the first duration determining module includes:
a first time length determining submodule, configured to, when the program code is executed to a first node, obtain an execution time length from start of execution to execution of the program code to the first node, where the first node is any one of the plurality of nodes;
a comparison module for comparing the node identity of the first node with the identity of the end node;
a storage module, configured to determine that the first node is an executed node if the node identifier of the first node does not match the node identifier of the end node, and store the node identifier of the executed node and an execution duration of the program code from the beginning of execution to the executed node in an associated manner;
a second duration determining submodule, configured to determine that the first node is the end node if the node identifier of the first node matches the node identifier of the end node, and use an execution duration from the start of execution to the end node of the program code as the second execution duration;
and the third time length determining submodule is used for determining a target executed node with a node identifier matched with the node identifier of the starting node, reading the execution time length from the beginning of execution to the beginning of execution of the program code stored in association with the node identifier of the starting node according to the node identifier of the target executed node, and taking the read execution time length as the first execution time length.
Optionally, the apparatus further comprises:
a second obtaining module, configured to obtain a latest node pairing group issued by the server when a trigger condition is detected, where the latest node pairing group includes a latest start node and a latest end node; wherein the trigger condition includes at least one of: the user performs specified operation on the client and receives a pull instruction issued by the server;
and a third time length determining module, configured to determine, based on the latest node pairing group, an execution time length from the execution of the program code from the latest start node to the latest end node, and stop performing the determination of the execution time length of the code interval of the node pairing group obtained in history.
Optionally, the node is encapsulated into a macro before inserting the program code, and the macro takes the node identifier of the node as a parameter.
Optionally, the apparatus further comprises:
and the reporting module is used for reporting the execution time of the program code from the starting node to the ending node to the server so that the server can visualize the execution time.
A third aspect of the embodiments of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps in the method for determining the execution duration of the client code interval according to the first aspect of the present invention.
A fourth aspect of the embodiments of the present invention provides an electronic device, including a memory, a processor, and a computer program that is stored in the memory and is executable on the processor, where the processor, when executing the computer program, implements the steps of the method for determining the execution duration of the client code interval according to the first aspect of the present invention.
By adopting the method for determining the execution duration of the client code interval provided by the embodiment of the invention, enough nodes are inserted into the program code of the client in advance, each node can be used for counting the execution duration of the program code from the beginning of execution to the execution of the node, and the client actively acquires any node pairing group dynamically issued by the server to flexibly control and collect code execution time-consuming data between any two different nodes in the client execution code. When the time-consuming data between a certain node pairing group is not required to be collected any more or a new node pairing group is required to be collected, the issued node pairing group is dynamically adjusted only by the server, and different nodes can be combined at will to determine the time consumption of any different code intervals on the premise of not requiring the client to re-issue, so that the workload of developers is reduced, and the development cost is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a schematic diagram of an application scenario according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a method for determining an execution duration of a client code interval according to an embodiment of the present invention;
fig. 3 is a schematic diagram illustrating a node identifier generation method according to an embodiment of the present invention;
fig. 4 is a schematic diagram illustrating a method for determining an execution duration of a client code interval according to an embodiment of the present invention;
fig. 5 is a block diagram illustrating a structure of an apparatus for determining an execution duration of a client code interval according to an embodiment of the present invention;
fig. 6 is a schematic diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As described above, in the conventional scheme for determining the time-consuming interval of the client, the time when the current code is executed to the position a is recorded by inserting a recording point a into one position in the code, and the time when the current code is executed to the position B is recorded by inserting a recording point B into another position, so that the time difference between B and a is A, B execution times of two code intervals. When enough recording points are inserted, the execution time of a plurality of code intervals can be obtained, so that the analysis of which code intervals are time-consuming can be realized. This solution has the following drawbacks:
1) once the scheme is determined, only the time consumption of the position of the inserted record point can be counted, if the time consumption of other code intervals is needed, a client must add a new record point at a new position and then release a new version for solving, the scheme lacks the time consumption capability of randomly combining nodes in different code intervals, and has a large defect on later expansion;
2) for some points which are being counted, if no more statistics is needed on line, the reporting is not finished immediately, so that the resource of the server is wasted, and the situation can be solved by releasing a new version and dropping unneeded record points in the new version;
3) when a client program code is developed, the execution time length between which codes are to be counted needs to be known definitely, a code for counting time is inserted into a specific position of the program code, when a recording point is newly added, each position needs to record the current position and time manually, and when an end node is met, a logic for calculating time consumption needs to be added, so that the access cost of a service access party is high.
In order to at least partially solve one or more of the above problems and other potential problems, an embodiment of the present invention provides a method for determining an execution duration of a code interval of a client, where a concept of a node is abstracted, so that enough nodes capable of counting the time from the start of execution of a program code to the execution time of the node are inserted in advance in the program code of the client, and a server dynamically issues a node pairing group to control the client to obtain code execution time-consuming data between any two nodes in the node pairing group, so that on the premise that a client re-releases the program, when a user no longer wants to collect time-consuming data between a certain node pairing group or wants to collect time-consuming data between new node pairing groups, the server only needs to dynamically adjust the node pairing group to randomly combine different nodes to determine the time-consuming of any different code intervals, thereby reducing the workload of developers and reducing the development cost.
Fig. 1 is a schematic diagram of an application scenario according to an embodiment of the present invention. As shown in fig. 1, the application scenario of the present embodiment includes a server 100 and a client 110, where the server 100 is in communication connection with the client 110. In this embodiment, the client may refer to a program providing a local service for a user, and the client may implement the same software function in different program forms; for example, the client may be an application software APP, an applet, a web browser, or the like. The server may be a background server of the client, for example, the server may be a computer communicatively connected to the client. It should be noted that fig. 1 is only an example provided in this embodiment, a server in this embodiment may simultaneously connect to multiple clients for communication, and this embodiment does not set any specific limitation on the number of clients connected to the server.
Referring to fig. 2, fig. 2 is a flowchart illustrating a method for determining an execution duration of a client code interval according to an embodiment of the present invention. The method for determining the execution duration of the client code interval provided in this embodiment may be applied to the client in fig. 1, where a plurality of nodes are inserted in advance in the program code of the client, and each node is a code segment. For example, a developer may preset (insert) any number of nodes somewhere in the program code during the process of writing the program code of the client in the development stage of the client. The node in this embodiment may be a code segment having specific functions, where the specific functions at least include: marking the insertion position of the node, and counting the execution time length of the program code from the beginning to the execution to the insertion position of the node, so that the node can use the execution time length of the program code from the beginning to the execution to the node.
In this embodiment, the number of nodes pre-inserted into the extent code of the client is not less than the threshold of the number of nodes, so as to ensure that enough nodes are pre-inserted into the program code of the client, and the number of the nodes can meet the requirement of a developer for counting the execution time of each code interval of the client. The node quantity threshold is the minimum node quantity which is set in advance according to manual experience and can meet the requirement of a developer for counting a client code interval, the node quantity threshold can be set randomly according to the requirement, and the specific numerical value of the node quantity threshold is not limited in the embodiment.
As shown in fig. 2, the method for determining the execution duration of the client code interval in this embodiment may include the following steps:
step S11: and responding to the starting operation of the user on the client, executing the program code of the client, and acquiring a node pairing group issued by the server, wherein the node pairing group comprises a starting node and an ending node.
In this embodiment, a user may perform a start operation on a client on a terminal, for example, a touch operation may be performed on a control corresponding to the client displayed on the terminal (e.g., a device such as a mobile phone, a computer, a tablet, a car machine, and a smart watch), for example, a long-time press, a single-click, a double-click, and the like, so as to start the client. The client responds to the starting operation of the user on the client, executes the program code of the client, starts the client, and actively acquires the node pairing group issued by the server.
The node pairing group comprises a start node and an end node, a user can set one or more node pairing groups on a server according to requirements, the node pairing groups are used for controlling a client to count code execution time between any two nodes (namely, between the start node and the end node in the node pairing group), and each node pairing group comprises a start node and an end node. The node pairing group in the server can be updated according to user requirements, and all actively acquired by the client at each time are the node pairing group issued by the current server.
Step S12: and acquiring a first execution time length from the beginning of execution to the beginning of the execution of the program code to the ending node and a second execution time length from the beginning of execution to the ending node of the program code according to the node pairing group.
In this embodiment, the client actively pulls the node pair group configured by the server from the server, and the pulled node pair group can be stored in the local client. The client may obtain, according to the node pairing group, a first execution duration from the start of execution to the start of the program code in the node pairing group, and obtain a second execution duration from the start of execution to the end of the program code in the node pairing group, so as to obtain a first execution duration and a second execution duration corresponding to each node pairing group obtained from the server.
Step S13: and determining the execution time length of the program code from the starting node to the ending node according to the first execution time length and the second execution time length.
In this embodiment, after the client acquires the first execution duration and the second execution duration corresponding to the node pairing group, the execution duration from the start node of the node pairing group to the end node of the node pairing group of the client program code may be determined according to the first execution duration and the second execution duration. In one embodiment, the first execution duration may be subtracted from the obtained second execution duration to obtain an execution duration from a start node of the node pairing group to an end node of the node pairing group.
Thus, for the node matching groups issued from the server (i.e. all the node matching groups actively pulled by the client), the code execution time between the start node and the end node corresponding to each node matching group can be obtained by the above method, therefore, the time consumption between any two points in the client program code required by the user is obtained, when the user does not need to collect the time consumption data between a certain node pairing group any more or needs to collect the time consumption data between a new node pairing group, only the distributed node pairing group is dynamically adjusted through the server, therefore, the positions, which are relatively time-consuming for executing the codes, in the client are found (such as a relatively time-consuming interval in a client starting stage, a relatively time-consuming interval in a subsequent running stage of the client and the like), so that a basis is provided for optimizing the starting speed or the running speed of the client subsequently.
In this embodiment, enough nodes are pre-inserted into the program code of the client, and each node can be used to count the execution time of the program code from the beginning of execution to the execution of the node, the server-side issuing node pairing group is actively pulled by the client, and the code execution time between two nodes in each node pairing group is counted in the client code execution process, so that the collection of code execution time-consuming data between any two different nodes in the client-side executing code is flexibly controlled by obtaining any node pairing group dynamically issued by the server. When the time-consuming data between a certain node pairing group is not required to be collected any more or a new node pairing group is required to be collected, the issued node pairing group is dynamically adjusted only by the server, and different nodes can be combined at will to determine the time consumption of different code intervals under the condition that the client is not required to re-issue, so that the workload of developers is reduced, and the development cost is reduced.
With reference to the foregoing embodiment, in an implementation manner, an embodiment of the present invention further provides a method for determining an execution duration of a client code interval. In the method, each node in a plurality of nodes pre-inserted in a client program code has a unique node identifier, the node identifier is used for identifying a corresponding node, and the corresponding node can be found through the node identifier. Specifically, in this embodiment, the specific functions further include: a unique node identification corresponding to the node is generated by invoking the generator. The node may generate a unique and unique node identifier for each node by calling a generator, as shown in fig. 3, and fig. 3 is a schematic diagram illustrating a node identifier generation method according to an embodiment of the present invention.
In fig. 3, in order to generate meaningful and easily understood node identifiers as much as possible, a node generates a specified prefix and a random number for a current node by calling a generator, the specified prefix characterizes a function to which the node (i.e. the segment of code) belongs, in one embodiment, the generator may be spliced by capturing names of modules where the node currently exists, and the random number is a number randomly generated by the generator; the generator then synthesizes the node identification of the node (which can be understood as generating the unique code of the node) according to the generated specified prefix and the random number. And in order to make the node identification of each node unique, the de-duplication process is carried out after the node identifications of the nodes are synthesized: and detecting whether the currently generated node identification is repeated, if so, generating a new appointed prefix and a random number for the node again through the generator (in one case, the appointed prefix can be unchanged, and only the random number is changed), so as to regenerate the node identification of the node, and outputting the node identification of the node (namely outputting the unique code of the node) until judging that the node identification of the current node is not repeated. By way of example, the node identification may be represented by the following form: nodeIdentifier is SDKInit36379, wherein nodeIdentifier is a node identifier, SDKInit is a specified prefix, and 36379 is a random number.
In an embodiment, the step S12 specifically includes steps S21 to S25:
step S21: when the program code is executed to a first node, acquiring the execution duration of the program code from the beginning of execution to the first node, wherein the first node is any one of the plurality of nodes.
The first node in this embodiment is any one of a plurality of nodes into which a program code is inserted in advance, the client executes the program code of the client after starting, and when the program code is executed to the first node, the execution duration from the start of execution to the execution of the program code to the first node is obtained. That is, when the program code of the client is executed to each node inserted in advance, the execution duration from the start of execution to the execution of the program code to the node is obtained through the node.
Step S22: comparing the node identification of the first node with the identification of the end node.
In this embodiment, the node pairing group refers to a pairing combination composed of two node identifiers, and may be represented by node identifiers corresponding to a start node and an end node, that is, the node identifiers corresponding to every two nodes (a start node and an end node) form a node pairing group, for example: (nodeIndexierrA, nodeIndexierB), wherein nodeIndexierrA is the node identification of the start node, nodeIndexierB is the node identification of the end node, and the form of the node pairing group dynamically issued by the server side can be: [ (nodeindifierra, nodeindifierb), (nodeindifierc, nodeindifierd),. ].
When the program code of the client is executed to the first node, in addition to acquiring the execution time length from the beginning of the execution to the first node of the program code, the node identification of the first node is compared with the identification of the end node in the node pairing group. Specifically, the node identification of the first node may be compared with the end node of each end node in the node pairing group acquired by the client from the server.
Step S23: and if the node identification of the first node is not matched with the node identification of the end node, determining that the first node is an executed node, and associating and storing the node identification of the executed node and the execution time length from the beginning of execution to the execution of the program code to the executed node.
In this embodiment, when the node pairing group acquired from the server is a node pairing group, if the node identifier of the first node is not matched with the node identifier of the end node in the node pairing group; or when the node pairing group acquired from the server is a plurality of node pairing groups, if the node identification of the first node is not matched with the node identifications of all the end nodes in the node pairing group acquired from the server; and determining that the first node is an executed node, and associating and storing the node identification of the executed node and the execution time length of the program code from the beginning of execution to the executed node. In one embodiment, the node identification of the executed node and the execution duration of the program code from the beginning of execution to the executed node may be stored in an executed node database local to the client.
Step S24: and if the node identifier of the first node is matched with the node identifier of the end node, determining that the first node is the end node, and taking the execution time length from the beginning of execution to the end node of the program code as the second execution time length.
In this embodiment, if the node identifier of the first node matches the node identifiers of one or more end nodes in the node pairing group acquired from the server, it is determined that the first node is an end node, and the execution duration of the acquired program code from the start of execution to the end node is taken as the second execution duration.
Step S25: determining a target executed node with a node identifier matched with the node identifier of the starting node, reading the execution time length from the beginning of execution to the starting node of the program code stored in association with the node identifier of the starting node according to the node identifier of the target executed node, and taking the read execution time length as the first execution time length.
In this embodiment, after determining that the currently executed first node is an end node, determining a target executed node whose node identifier matches the node identifier of the start node corresponding to the end node; specifically, the node identifier of the start node corresponding to the end node may be obtained by querying in the node pairing group obtained from the server according to the node identifier of the end node, and the node corresponding to the node identifier is determined as the target executed node (i.e., the start node corresponding to the end node is found).
And reading the execution time length from the beginning of execution to the beginning of execution of the program code stored in association with the node identifier of the starting node corresponding to the ending node before according to the node identifier of the target executed node (namely the node identifier of the starting node corresponding to the ending node), and determining the read execution time length as the first execution time length. Specifically, in an embodiment, the execution duration corresponding to the node identifier of the target executed node may be searched in the executed node database according to the node identifier of the target executed node, and the execution duration may be determined as a first execution duration from the start of execution to the start of execution of the program code.
If the currently executed first node is an end node and the end node corresponds to a plurality of start nodes in a node pairing group acquired from the server, the first execution duration corresponding to each start node can be determined according to the method.
In this embodiment, when the program code of the client is executed to each node (i.e., the first node), the execution time from the start of execution to the first node of the program code is obtained, and whether the currently executed node is the end node of the node pairing group is determined according to the node identifier of the first node, if the currently executed node is the end node, the start node corresponding to the currently executed node is determined according to the end node, and then the time consumption of the code interval represented between two nodes in the node pairing group corresponding to the currently executed end node is determined according to the first execution time from the execution of the program code to the start node and the second execution time from the execution to the end node. In this embodiment, by determining whether the currently executed first node is an end node, and if the currently executed first node is the end node, representing that the code interval corresponding to a certain node pairing group has been executed, the client can immediately count the time consumed for acquiring a certain section of code interval corresponding to the node pairing group, so that the determination of the execution time of the code intervals corresponding to all the node pairing groups can be completed through the sequential execution of the program codes.
With reference to the foregoing embodiments, in an implementation manner, an embodiment of the present invention further provides a method for determining an execution duration of a client code interval. In the method, after the client is started, the method may further include step S31 and step S32:
step S31: and under the condition that the trigger condition is detected, acquiring a latest node pairing group issued by the server, wherein the latest node pairing group comprises a latest starting node and a latest finishing node.
In this embodiment, the client may not only obtain the node pairing group issued by the server in response to a start operation of the client by the user (i.e., in a start process of the client), but also obtain the latest node pairing group issued by the server when the client detects a trigger condition after the client is started. That is, in the running process of the client, if the client detects the trigger condition, the client may actively acquire the latest node pairing group issued by the server to the server again.
The trigger condition in this embodiment includes at least one of the following: and the user performs specified operation on the client and receives a pulling instruction issued by the server. The operation specified by the user to the client may be a preset operation with a specific function performed by the user to the client, for example, an opening operation (having a function of opening the client) performed by the user to the client, an opening operation (having a function of opening a client page or interface) performed by the user to a certain page or interface of the client, a refreshing operation (having a function of refreshing a page) performed by the user to a certain page of the client, and the like. And receiving a pull instruction issued by the server means: the client obtains the node pairing group pull instruction issued by the server, for example, the server notifies the client to actively pull the node pairing group by issuing a push, and the client executes a pull command according to the pull instruction issued by the server after receiving the push, so as to actively obtain the latest node pairing group issued by the server to the server.
Step S32: and determining the execution time length of the program code from the latest starting node to the latest ending node based on the latest node pairing group, and stopping determining the execution time length of the code interval of the node pairing group acquired in history.
In this embodiment, after the client acquires the latest node pairing group delivered by the server, the execution duration from the latest start node to the latest end node of the program code of the client is determined by the above method (steps S12-S13 or steps S21-S25) based on the latest node pairing group, and the execution of the determination of the execution duration of the code interval in the node pairing group acquired in history (that is, the node pairing group acquired before the latest node pairing group acquired this time) is stopped.
The latest node pairing group can be the same as or different from the previously acquired node pairing group, and the node pairing group issued by the server can be dynamically updated according to the requirements of the user. If the user updates the node pairing group configured in the server before the client detects the trigger condition and acquires the latest node pairing group issued by the server, the acquired latest node pairing group is different from the previously acquired node pairing group; if the user does not update the node pairing group configured in the server before the client detects the trigger condition and acquires the latest node pairing group issued by the server, the acquired latest node pairing group is the same as the previously acquired node pairing group, and in this case, the determination of the execution duration of the code interval in the node pairing group acquired in the history can be performed according to the continuation.
In this embodiment, the client may actively pull the node pairing group issued by the server according to the situation: because the client has only one starting stage after starting, the time consumption acquisition of the code interval of the starting stage of the client can be controlled according to the node pairing group which is actively pulled in the starting process; in the running process after the client is started, when the client can repeatedly execute some interactions or operations, for example, when the client performs frequent interactions or some specific operations, the client actively updates the local node pairing group according to the dynamic control of the server, so that the update of the node pairing group is really realized, and the time consumption determination for any program code interval of the client is further realized.
In combination with the above embodiments, in an implementation, the node is encapsulated into a macro before the program code is inserted, and the macro takes the node identification of the node as a parameter.
Before each Node in this embodiment inserts a program code, each Node may be encapsulated into a predefined macro (for example, the macro name may be a Node) that is convenient to use and easy to access, and the macro receives a parameter, where the parameter is a Node identifier corresponding to the Node. A developer may insert a macro into program code as if it were a very compact symbol, which may correspond to placing the symbol (e.g., node (node) in a location in the program code) to which the macro may be deployed to execute logic within the node that represents a featured function.
In the embodiment, a developer can encapsulate the nodes into macro form and insert the macro form into the program code of the client, which is much more convenient than the way of inserting record points into the code in the prior art, and the workload of the developer is further reduced.
With reference to any one of the foregoing embodiments, in an implementation manner, an embodiment of the present invention further provides a method for determining an execution duration of a client code interval. In this method, after the determining the execution duration of the program code from the starting node to the ending node, step S41 may be further included:
step S41: and reporting the execution time of the program code from the starting node to the ending node to the server so that the server can visualize the execution time.
In this embodiment, after determining the execution duration of the program code from the start node to the end node according to the first execution duration and the second execution duration, the client may report the execution duration of the code interval corresponding to the node pairing group to the server, that is, report the execution duration of the program code from the start node to the end node in the node pairing group to the server, so that the server visualizes the execution duration, so that a user can know the consumption duration of each code interval in the client, thereby performing subsequent targeted optimization on the client.
In an embodiment, referring to fig. 4, fig. 4 is a schematic diagram illustrating a method for determining an execution duration of a client code interval according to an embodiment of the present invention. As shown in fig. 4, taking a client as an APP for example, the method for determining the execution duration of a client code interval in the embodiment of the present invention is described. In the stage of developing the client program code by the developer, the development stage processing flow of the developer is as follows: a developer inserts a newly added node (node identifier) into a program code, and generates a unique node identifier for the node based on the scheme of the above fig. 3; at the starting stage of the APP, the operation flow of the APP starting process is as follows: in the APP starting process, pulling the node dynamic group dynamically configured by the server, and storing the node dynamic group dynamically configured by the server; the APP executes the program code, and when the APP executes a node (any node) in the program code, executes the processing flow inside the node: when a node (node identifier) is executed, inquiring a node pairing group from a node pairing group NodeIdentifier obtained by a server based on a node identifier of the node, and determining whether the node is an end node; if the node is not an end node (1, the node is not in a node pairing group acquired from a server side, 2, the node is a starting node in the node pairing group acquired from the server side), recording the time nodeStartTime from the beginning of execution to the execution of the program code to the node, and storing the node identification of the node and the time correlation of the program code from the beginning of execution to the node into an executed node database AlreadExecutioneNodeData local to the client side; if the node is an end node, recording the time nodeEndTime from the beginning of execution to the execution of the program code to the node, inquiring a corresponding start node from a node pairing group NodePairGroup issued by the server, inquiring the start time of the corresponding start node from an executed node database AlreadExecutionNodeData according to the node identifier of the start node, thereby calculating the time consuming nodeEndTime-nodeStartTime between the start node and the end node in the node pairing group, and reporting the obtained time consuming data between the two nodes to the server. When a certain code interval is repeatedly executed (for example, when a certain page is repeatedly opened by a client), the time for repeatedly calculating the code interval does not have the problem of subtraction between the execution time from the second execution to the end node and the execution time from the first execution to the start node. In addition, in an embodiment, since there may be an end node in one node pairing group and also a start node in another node pairing group, the obtained time nodeentime from execution to end node may also be stored into the executed node database alreadexecutenode data together in this embodiment.
It should be noted that for simplicity of description, the method embodiments are shown as a series of combinations of acts, but those skilled in the art will recognize that the embodiments are not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Based on the same inventive concept, an embodiment of the present invention provides an apparatus 500 for determining an execution duration of a client code interval, where the apparatus 500 is applied to a client, a plurality of nodes are inserted in advance in a program code of the client, and each node is a code segment and is used to count an execution duration from the beginning of execution to the execution of the program code to the node. Referring to fig. 5, fig. 5 is a block diagram illustrating a structure of an apparatus for determining an execution duration of a client code interval according to an embodiment of the present invention. As shown in fig. 5, the apparatus 500 includes:
a first obtaining module 501, configured to execute a program code of the client in response to a start operation of the client by a user, and obtain a node pairing group issued by a server, where the node pairing group includes a start node and an end node;
a first duration determining module 502, configured to obtain, according to the node pair group, a first execution duration from the start of execution to the start node of the program code, and a second execution duration from the start of execution to the end node of the program code;
a second duration determining module 503, configured to determine, according to the first execution duration and the second execution duration, an execution duration from the start node to the end node of the program code.
Optionally, each node in the plurality of nodes has a unique node identifier; the first duration determining module 502 includes:
a first time length determining submodule, configured to, when the program code is executed to a first node, obtain an execution time length from start of execution to execution of the program code to the first node, where the first node is any one of the plurality of nodes;
a comparison module for comparing the node identity of the first node with the identity of the end node;
a storage module, configured to determine that the first node is an executed node if the node identifier of the first node does not match the node identifier of the end node, and store the node identifier of the executed node and an execution duration of the program code from the beginning of execution to the executed node in an associated manner;
a second duration determining submodule, configured to determine that the first node is the end node if the node identifier of the first node matches the node identifier of the end node, and use an execution duration from the start of execution to the end node of the program code as the second execution duration;
and the third time length determining submodule is used for determining a target executed node with a node identifier matched with the node identifier of the starting node, reading the execution time length from the beginning of execution to the beginning of execution of the program code stored in association with the node identifier of the starting node according to the node identifier of the target executed node, and taking the read execution time length as the first execution time length.
Optionally, the apparatus 500 further includes:
a second obtaining module, configured to obtain a latest node pairing group issued by the server when a trigger condition is detected, where the latest node pairing group includes a latest start node and a latest end node; wherein the trigger condition includes at least one of: the user performs specified operation on the client and receives a pull instruction issued by the server;
and a third time length determining module, configured to determine, based on the latest node pairing group, an execution time length from the execution of the program code from the latest start node to the latest end node, and stop performing the determination of the execution time length of the code interval of the node pairing group obtained in history.
Optionally, the node is encapsulated into a macro before inserting the program code, and the macro takes the node identification of the node as a parameter.
Optionally, the apparatus 500 further includes:
and the reporting module is used for reporting the execution time of the program code from the starting node to the ending node to the server so that the server can visualize the execution time.
Based on the same inventive concept, another embodiment of the present invention provides an electronic device 600, as shown in fig. 6. Fig. 6 is a schematic diagram of an electronic device according to an embodiment of the present invention. The electronic device includes a memory 602, a processor 601 and a computer program stored on the memory and executable on the processor, and when the processor executes the computer program, the steps in the method for determining the execution duration of the client code interval according to any of the above embodiments of the present invention are implemented.
Based on the same inventive concept, another embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the steps in the method for determining the execution duration of the client code interval according to any of the above embodiments of the present invention.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (12)

1. A method for determining the execution duration of a client code interval is characterized in that the method is applied to a client, a plurality of nodes are pre-inserted into a program code of the client, each node is a code segment and is used for counting the execution duration of the program code from the beginning of execution to the execution of the node; the method comprises the following steps:
responding to the starting operation of a user on the client, executing a program code of the client, and acquiring a node pairing group issued by a server, wherein the node pairing group comprises a starting node and an ending node;
according to the node pairing group, acquiring a first execution time length from the beginning of execution to the beginning of the execution of the program code to the ending node, and a second execution time length from the beginning of execution to the ending node of the program code;
and determining the execution time length of the program code from the starting node to the ending node according to the first execution time length and the second execution time length.
2. The method of claim 1, wherein each node in the plurality of nodes has a unique node identification; the acquiring, according to the node pairing group, a first execution duration from the start of execution to the start node of the program code, and a second execution duration from the start of execution to the end node of the program code, includes:
when the program code is executed to a first node, acquiring the execution duration of the program code from the beginning of execution to the first node, wherein the first node is any one of the plurality of nodes;
comparing the node identification of the first node with the identification of the end node;
if the node identification of the first node is not matched with the node identification of the end node, determining that the first node is an executed node, and storing the node identification of the executed node and the execution duration of the program code from the beginning of execution to the executed node in an associated manner;
if the node identifier of the first node is matched with the node identifier of the end node, determining that the first node is the end node, and taking the execution time length from the beginning of execution to the end node of the program code as the second execution time length;
determining a target executed node with a node identifier matched with the node identifier of the starting node, reading the execution time length from the beginning of execution to the starting node of the program code stored in association with the node identifier of the starting node according to the node identifier of the target executed node, and taking the read execution time length as the first execution time length.
3. The method of claim 1, wherein after the client boots, the method further comprises:
under the condition that a trigger condition is detected, acquiring a latest node pairing group issued by the server, wherein the latest node pairing group comprises a latest starting node and a latest finishing node; wherein the trigger condition includes at least one of: the user performs specified operation on the client and receives a pulling instruction issued by the server;
and determining the execution time length of the program code from the latest starting node to the latest ending node based on the latest node pairing group, and stopping determining the execution time length of the code interval of the node pairing group acquired in history.
4. The method of claim 2, wherein the node is encapsulated into a macro prior to inserting the program code, the macro having a node identification of the node as a parameter.
5. The method of any of claims 1-4, wherein after the determining the length of time the program code has been executed from the start node to the end node, the method further comprises:
and reporting the execution time of the program code from the starting node to the ending node to the server so that the server can visualize the execution time.
6. A device for determining the execution duration of a client code interval is applied to a client, a plurality of nodes are pre-inserted into a program code of the client, each node is a code segment and is used for counting the execution duration of the program code from the beginning of execution to the execution of the node; the device comprises:
the first acquisition module is used for responding to the starting operation of a user on the client, executing a program code of the client and acquiring a node pairing group issued by a server, wherein the node pairing group comprises a starting node and an ending node;
a first time length determining module, configured to obtain, according to the node pairing group, a first execution time length from start of execution to execution of the program code to the start node, and a second execution time length from start of execution to execution of the program code to the end node;
and the second time length determining module is used for determining the execution time length of the program code from the starting node to the ending node according to the first execution time length and the second execution time length.
7. The apparatus of claim 6, wherein each node of the plurality of nodes has a unique node identification; the first duration determining module includes:
the first time length determining submodule is used for acquiring the execution time length from the beginning of execution to the first node of the program code when the program code is executed to the first node, and the first node is any one of the plurality of nodes;
a comparison module for comparing the node identity of the first node with the identity of the end node;
a storage module, configured to determine that the first node is an executed node if the node identifier of the first node does not match the node identifier of the end node, and store the node identifier of the executed node and an execution duration of the program code from the beginning of execution to the executed node in an associated manner;
a second duration determining submodule, configured to determine that the first node is the end node if the node identifier of the first node matches the node identifier of the end node, and use an execution duration from the start of execution to the end node of the program code as the second execution duration;
and the third time length determining submodule is used for determining a target executed node with a node identifier matched with the node identifier of the starting node, reading the execution time length from the beginning of execution to the beginning of execution of the program code stored in association with the node identifier of the starting node according to the node identifier of the target executed node, and taking the read execution time length as the first execution time length.
8. The apparatus of claim 6, further comprising:
a second obtaining module, configured to obtain a latest node pairing group issued by the server when a trigger condition is detected, where the latest node pairing group includes a latest start node and a latest end node; wherein the trigger condition includes at least one of: the user performs specified operation on the client and receives a pulling instruction issued by the server;
and a third time length determining module, configured to determine, based on the latest node pairing group, an execution time length from the execution of the program code from the latest start node to the latest end node, and stop performing the determination of the execution time length of the code interval of the node pairing group obtained in history.
9. The apparatus of claim 7, wherein the node is encapsulated into a macro prior to inserting the program code, and wherein the macro is parameterized by a node identification of the node.
10. The apparatus of any of claims 6-9, further comprising:
and the reporting module is used for reporting the execution time of the program code from the starting node to the ending node to the server so that the server can visualize the execution time.
11. An electronic device, comprising: processor, memory and computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the method for determining an execution duration of a client code interval according to any one of claims 1 to 5.
12. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method for determining an execution duration of a client code interval according to any one of claims 1 to 5.
CN202210689293.3A 2022-06-17 2022-06-17 Method, device, equipment and medium for determining execution duration of client code interval Pending CN115129390A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210689293.3A CN115129390A (en) 2022-06-17 2022-06-17 Method, device, equipment and medium for determining execution duration of client code interval

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210689293.3A CN115129390A (en) 2022-06-17 2022-06-17 Method, device, equipment and medium for determining execution duration of client code interval

Publications (1)

Publication Number Publication Date
CN115129390A true CN115129390A (en) 2022-09-30

Family

ID=83378366

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210689293.3A Pending CN115129390A (en) 2022-06-17 2022-06-17 Method, device, equipment and medium for determining execution duration of client code interval

Country Status (1)

Country Link
CN (1) CN115129390A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117149632A (en) * 2023-08-31 2023-12-01 重庆赛力斯新能源汽车设计院有限公司 Method and device for analyzing cold start of vehicle-mounted application program

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117149632A (en) * 2023-08-31 2023-12-01 重庆赛力斯新能源汽车设计院有限公司 Method and device for analyzing cold start of vehicle-mounted application program

Similar Documents

Publication Publication Date Title
CN111061484B (en) Code compiling method, device, server, user terminal and readable medium
CN107169094B (en) Information aggregation method and device
CN109582470B (en) Data processing method and data processing device
CN112714359B (en) Video recommendation method and device, computer equipment and storage medium
CN109657107B (en) Terminal matching method and device based on third-party application
CN111813788A (en) Information query method and device and information synchronization method and device
CN108965383A (en) File synchronisation method, device, computer equipment and storage medium
CN115129390A (en) Method, device, equipment and medium for determining execution duration of client code interval
CN110247796A (en) Monitoring alarm method, apparatus and relevant device
CN109325056A (en) A kind of big data processing method and processing device, communication equipment
CN111464351A (en) Network distribution method and device for intelligent household equipment, terminal equipment and storage medium
CN111147226B (en) Data storage method, device and storage medium
CN109561126B (en) Data synchronization method and device, storage medium and processor
CN116132630A (en) Video processing method, device, equipment and storage medium
CN115599793A (en) Method, device and storage medium for updating data
CN109246297B (en) Method, device and storage medium for determining factory reset time of mobile terminal
CN113660359A (en) Management method and device for domain name resolution record, storage medium and electronic equipment
CN111491060B (en) Information click log and ticket splicing method and device
CN112068810A (en) Activity event processing method and device, electronic equipment and storage medium
CN112449022A (en) Cloud edge coordination method, device and system and electronic equipment
CN111061701A (en) Information processing method, device, server and computer readable medium
CN112131267A (en) Counting processing method, device, server and counting processing system
CN106775854B (en) Method and device for generating configuration file
CN111145803A (en) Voice information acquisition method and device, storage medium and electronic device
CN113011507B (en) Method for establishing synchronous time prediction model, data synchronization method and corresponding device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination