CN115981985A - Code block monitoring method and device, electronic equipment and readable storage medium - Google Patents

Code block monitoring method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN115981985A
CN115981985A CN202310044377.6A CN202310044377A CN115981985A CN 115981985 A CN115981985 A CN 115981985A CN 202310044377 A CN202310044377 A CN 202310044377A CN 115981985 A CN115981985 A CN 115981985A
Authority
CN
China
Prior art keywords
code block
code
instruction
target
monitoring
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
CN202310044377.6A
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 Keynote Network Inc
Original Assignee
Beijing Keynote Network Inc
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 Keynote Network Inc filed Critical Beijing Keynote Network Inc
Priority to CN202310044377.6A priority Critical patent/CN115981985A/en
Publication of CN115981985A publication Critical patent/CN115981985A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application relates to the field of software and discloses a code block monitoring method, a code block monitoring device, electronic equipment and a readable storage medium, wherein the method comprises the following steps: analyzing the target code data according to preset code block identification characteristics to acquire the position of a code block existing in the target code data; embedding a corresponding monitoring code into at least one code block according to the position of the code block, and acquiring the operating parameters of the code block through the monitoring code; and when the consumption of at least one code block is determined to be larger than a preset threshold value, displaying the running parameters of the code block. By the method and the device, the code blocks which cause overlarge consumption can be accurately positioned, and a user can conveniently maintain the codes.

Description

Code block monitoring method and device, electronic equipment and readable storage medium
Technical Field
The present application relates to the field of software, and in particular, to a code block monitoring method and apparatus, an electronic device, and a readable storage medium.
Background
When the application code runs (such as java code), the problem of consuming too much can occur. When the problem of excessive consumption occurs, application Performance Monitor (APM) software can be used for monitoring and searching for the problem.
However, most of the current APMs monitor databases (Data Base, DB), and call remotely by means of pre-embedding points. The positioning accuracy is not enough, and the codes which are too large to be positioned are consumed.
Disclosure of Invention
Based on the technical problem, the application provides a code block monitoring method, a code block monitoring device, an electronic device and a readable storage medium, which can solve the problem that excessive code consumption is caused by insufficient positioning accuracy and incapability of positioning.
In order to solve the technical problem, the following technical scheme is adopted in the application:
in a first aspect, the present application provides a code block monitoring method, including:
and analyzing the target code data according to the preset code block identification characteristics to obtain the position of the code block in the target code data. And embedding a corresponding monitoring code into at least one code block according to the position of the code block, and acquiring the operating parameters of the code block through the monitoring code. And when the consumption of at least one code block is determined to be larger than a preset threshold value, displaying the running parameters of the code block.
In some embodiments, the code block comprises a loop code block, and the identifying characteristic of the loop code block comprises a start instruction and an end instruction of the loop code block.
Analyzing the target code data according to the preset code block identification characteristics to acquire the position of the code block existing in the target code data, wherein the method comprises the following steps:
a start instruction and an end instruction are identified in the object code data. And when the identified start instruction has a corresponding end instruction, obtaining the position of the loop code block according to the positions of the start instruction and the end instruction in the target code data.
In some embodiments, obtaining the operating parameter of the code block by monitoring the code includes: and acquiring the total execution time of the loop code block according to the time for executing the starting instruction and the ending instruction. The starting instruction comprises a forward jump instruction, and the execution times of the loop code block are obtained according to a target instruction of the forward jump instruction jump. And acquiring each execution time of the loop code block according to the interval of executing the target instruction each time.
In some embodiments, the code blocks include synchronization code blocks, and the identifying characteristics of the synchronization code blocks include lock holding statements and lock releasing statements.
Analyzing the target code data according to the preset code block identification characteristics to acquire the position of the code block existing in the target code data, wherein the method comprises the following steps: lock holding statements and lock releasing statements are identified in the object code data. And when the lock holding statement and the lock releasing statement are identified, obtaining the position of the synchronous code block according to the positions of the lock holding statement and the lock releasing statement in the target code data.
In some embodiments, obtaining the operating parameter of the code block by monitoring the code includes: and acquiring the time for executing the lock holding statement to block, wherein the blocking time is the waiting time for acquiring the lock. And acquiring the lock holding time of the synchronous code block according to the execution time of the lock holding statement and the lock releasing statement.
In some embodiments, embedding a corresponding monitoring code into at least one code block includes: when a plurality of code blocks exist in the target code data, the identification of each code block is obtained and displayed. A user instruction is received, the user instruction including an identification of at least one code block. And embedding a corresponding monitoring code into the code block indicated by the identification of the code block contained in the user instruction.
In some embodiments, when it is determined that the consumption of at least one code block is greater than a preset threshold, presenting the operating parameters of the code block includes: and when the running time of the code block is greater than a preset threshold value, displaying the running parameters of the code block.
In the first aspect, a code block is identified in target code data by an identification feature of the code block, and a corresponding monitoring code is embedded for the code block. And acquiring the operating parameters of the code block by monitoring the code. And displaying the operating parameters of the code block when the consumption of the code block is greater than a preset threshold. The code blocks which cause over-consumption can be accurately positioned, and the user can conveniently maintain the codes.
In a second aspect, the present application provides a code block monitoring apparatus, including:
the analysis module is used for analyzing the target code data according to preset code block identification characteristics to acquire the position of the code block in the target code data;
the embedding module is used for embedding a corresponding monitoring code into at least one code block according to the position of the code block and acquiring the operating parameters of the code block through the monitoring code;
a display module, configured to display the operating parameter of the code block when it is determined that consumption of at least one of the code blocks is greater than a preset threshold.
In some embodiments, the code block comprises a loop code block, and the identifying characteristic of the loop code block comprises a start instruction and an end instruction of the loop code block.
And the analysis module is specifically used for identifying a start instruction and an end instruction in the target code data. And when the identified start instruction has a corresponding end instruction, obtaining the position of the loop code block according to the positions of the start instruction and the end instruction in the target code data.
In some embodiments, the embedded module is specifically configured to obtain a total execution time of the loop code block according to a time of executing the start instruction and the end instruction. The starting instruction comprises a forward jump instruction, and the execution times of the loop code block are obtained according to a target instruction of the forward jump instruction jump. And acquiring each execution time of the cyclic code block according to the interval of executing the target instruction each time.
In some embodiments, the code blocks include synchronization code blocks, and the identifying characteristics of the synchronization code blocks include lock holding statements and lock releasing statements.
And the analysis module is specifically used for identifying lock holding statements and lock releasing statements in the target code data. And when the lock holding statement and the lock releasing statement are identified, obtaining the position of the synchronous code block according to the positions of the lock holding statement and the lock releasing statement in the target code data.
In some embodiments, the embedding module is specifically configured to obtain a time for blocking execution of the lock holding statement, where the time for blocking is a waiting time for obtaining the lock. And acquiring the lock holding time of the synchronous code block according to the execution time of the lock holding statement and the lock releasing statement.
In some embodiments, the embedding module is specifically configured to, when multiple code blocks exist in the target code data, obtain an identifier of each code block and display the identifier. A user instruction is received, the user instruction including an identification of at least one code block. And embedding the corresponding monitoring code into the code block indicated by the identification of the code block contained in the user instruction.
In some embodiments, the display module is configured to display the operating parameter of the code block when the operating duration of the code block is greater than a preset threshold.
In a third aspect, the present application provides an electronic device comprising a processor and a memory; the memory has stored therein instructions executable by the processor; the processor is configured to execute the instructions such that the electronic device implements the method of the first aspect described above.
In a fourth aspect, a non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method described above.
In a fifth aspect, the present application provides a computer program product, which, when run on an electronic device, causes the electronic device to perform the steps of the method related to the first aspect described above, so as to implement the method of the first aspect described above.
For the beneficial effects of the second to fifth aspects, reference may be made to the first and second aspects, which are not described in detail.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the description below are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a schematic flowchart illustrating a code block monitoring method provided in an embodiment of the present application;
fig. 2 shows a block diagram of a code block monitoring apparatus according to an embodiment of the present application;
FIG. 3 shows a schematic block diagram of an electronic device 300 that may be used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of the embodiments of the disclosure are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 illustrates a flowchart of a code block monitoring method provided in an embodiment of the present application.
In some embodiments, the code block monitoring method may be applied to an electronic device, and the electronic device may be a device capable of running a code, such as a server, a computer, a smart phone, a tablet computer, a notebook computer, and the like, which is not limited in this application.
Referring to fig. 1, the code block monitoring method includes steps S101 to S103.
S101, analyzing target code data according to preset code block identification features, and acquiring the positions of code blocks in the target code data.
In some embodiments, each code block has its unique identifying characteristics. Common java loop code blocks and java synchronization code blocks are taken as examples.
As an example, when the code block is a loop code block, the loop code block may include a for i loop (java enhanced for loop), a for each loop (for loop), a while true loop (while loop), a do while loop, and the like.
Wherein, while loop can be realized in the following form:
Figure BDA0004054813840000051
the do while loop may be implemented in the following form:
Figure BDA0004054813840000061
the loop code block of java is essentially only the syntactical sugar (syntactical sugar) of java. In any of the above grammatical saccharides, there are two important points when implemented by the corresponding code, namely: a start instruction and an end instruction. Wherein the start instruction may be a jump instruction to jump forward. For example, the java byte code corresponding to "testfor" includes a "goto" instruction; the java byte code corresponding to the testForNotFinish comprises a goto instruction. The ending instruction may be a jump instruction for jumping out of the loop, for example, a plurality of "ifcmpg" instructions exist in the java bytecode corresponding to "testfor" and may jump out of the loop when the condition is met.
In some embodiments, the loop body may only have a start instruction and no jump instruction, i.e., the loop body is a dead loop. For example, in the java byte code corresponding to "testForNotFinish", none of the jump instructions can jump out of the loop body, i.e., the loop body is a dead loop. For the endless loop, the embodiment of the present application does not process it for the time being.
In some embodiments, a start instruction and an end instruction may be identified in the object code data. And when the identified start instruction has a corresponding end instruction, obtaining the position of the loop code block according to the positions of the start instruction and the end instruction in the target code data.
For example, in the java byte code corresponding to "testfor", the start position of the behavior loop code block where the "goto" instruction is located, and the end position of the behavior loop code block where the "ifcmpg" instruction is located.
In other examples, when the code block is a java synchronization code block, for example, it may be a Synchronized (Synchronized) synchronization code block. The method provided in the application can realize the monitoring of the non-method level of modification by using synchronized.
As an example, the use of synchronized retouched methods may be to manually perform a locked object. For example, it may be a "this" instruction, or it may be a custom lock. The implementation code may include:
Figure BDA0004054813840000071
/>
Figure BDA0004054813840000081
the use of synchronized decorated non-methods may also refer to designating a lock object as a class object. The implementation code may include:
Figure BDA0004054813840000082
/>
Figure BDA0004054813840000091
the synchronized code block of java is only grammar sugar of java essentially, and the identification characteristics of the synchronized code block comprise lock holding sentences and lock releasing sentences.
In some embodiments, lock holding statements and lock releasing statements may be identified in the object code data. And when the lock holding statement and the lock releasing statement are identified, obtaining the position of the synchronous code block according to the positions of the lock holding statement and the lock releasing statement in the target code data.
As an example, the lock holding statement of a synchronized synchronous code block may be a "monitorenter" instruction at the beginning of the code block. This instruction corresponds to the implementation of lock blocking. For example, if the current lock object is not occupied by another thread, then the next instruction may continue to be executed, and if the current lock is already held, then the current lock object may be blocked on the monitorenter instruction until the lock is released and the next instruction may continue to be executed.
The lockdown statement of the synchronized synchronous code block may be a "monitorexit" instruction. This instruction is used to implement lockdown. It should be noted that, there may be multiple "monitorexit" instructions in a synchronized code block, but this does not mean that multiple "monitorexit" instructions are executed, and the multiple "monitorexit" instructions are only used to execute the lock releasing again in an abnormal condition, so as to improve the accuracy of the lock releasing.
S102, embedding a corresponding monitoring code into at least one code block according to the position of the code block, and acquiring the running parameters of the code block through the monitoring code.
In some embodiments, referring to S101, when the code block is a loop code block, the monitor code may be embedded at a skip ahead instruction, a skip out instruction, and a target instruction at which the skip ahead instruction indicates a jump. And acquiring the total execution time of the loop code block according to the time for executing the starting instruction and the ending instruction. The starting instruction comprises a forward jump instruction, and the execution times of the loop code block are obtained according to a target instruction of the forward jump instruction. And acquiring each execution time of the loop code block according to the interval of executing the target instruction each time.
In other embodiments, referring to S102, when the code block is a synchronous code block, the lock holding statement may be preceded and followed by the code embedding, and the lock releasing statement may be preceded and followed. And when the lock holding statement and the lock releasing statement are identified, embedding codes according to the outgoing of the lock holding statement and the lock releasing statement. And acquiring the time for executing the lock holding statement to block, wherein the blocking time is the waiting time for acquiring the lock. And acquiring the lock holding time of the synchronous code block according to the execution time of the lock holding statement and the lock releasing statement.
In some embodiments, when the target code data includes a plurality of code blocks, each code block may be subjected to embedding.
Or when a plurality of code blocks exist in the target code data, the identification of each code block can be obtained and displayed. And then waits for the user to determine the code blocks that need to be embedded. And returning a user instruction after the user is determined, and receiving the user instruction, wherein the user instruction comprises the identifier of at least one code block. And embedding the corresponding monitoring code into the code block indicated by the identification of the code block contained in the user instruction.
In some embodiments, the code blocks comprise cyclic code blocks, and the operating parameters of the cyclic code blocks comprise: number of executions, total time, single maximum time, minimum time, number of cycles, etc.
In some embodiments, the obtained operation parameters of the cyclic code block may be recorded by the following codes:
Figure BDA0004054813840000111
Figure BDA0004054813840000121
wherein, transactionId is the corresponding code block identification, and the identification is globally unique. Traceid is the identity of the corresponding "tracemethod", unique within an ActionTrace. startTime is the monitoring start time. Clazz is the qualified name of class and Method is the name of the Method. The codeLine is code line related monitoring data. Type is Type, for example, "loop" indicates that the monitored Type is a circular code block, "monitorenter" indicates the time when the monitored Type is to monitor for acquiring a lock, and "monitorexit" indicates the time when the monitored Type is to monitor for holding a lock. startLine is the code block's starting line number, endLine is the code block's ending line number, and Metric is the measurement (Metric) data. For example, in this example, the measurement data of a loop is:
Figure BDA0004054813840000122
in some embodiments, the code blocks include a synchronization code block, and the operating parameters of the synchronization code block include: the time the lock is acquired and the time the lock is held, etc.
S103, when the consumption of at least one code block is determined to be larger than a preset threshold value, displaying the running parameters of the code block.
In some embodiments, the operating parameters of the code block are presented when the operating duration of the code block is greater than a preset threshold. It should be understood that the consumption of the code block may also be determined by one or more other indicators, which are not limited in this application.
For example, when the loop code blocks run for too long (e.g., more than 10 seconds), the running parameters of each loop code block may be retrieved and the user may be assisted in optimizing the code according to the indicators in the running parameters.
In an exemplary embodiment, an embodiment of the present disclosure further provides a code block monitoring apparatus, which may be used to implement the bypass test method provided in the foregoing embodiment.
Fig. 2 shows a block diagram of a code block monitoring apparatus according to an embodiment of the present application.
Referring to fig. 2, a code block monitoring apparatus includes:
the analysis module 21 is configured to analyze target code data according to a preset code block identification feature, and obtain a position of the code block existing in the target code data;
the embedding module 22 is configured to embed a corresponding monitoring code into at least one code block according to the position of the code block, and obtain an operating parameter of the code block through the monitoring code;
a display module 23, configured to display the operating parameter of the code block when it is determined that consumption of at least one of the code blocks is greater than a preset threshold.
In some embodiments, the code block comprises a loop code block, and the identifying characteristic of the loop code block comprises a start instruction and an end instruction of the loop code block.
The analysis module 21 is specifically configured to identify a start instruction and an end instruction in the target code data. And when the identified start instruction has a corresponding end instruction, obtaining the position of the loop code block according to the positions of the start instruction and the end instruction in the target code data.
In some embodiments, the embedding module 22 is specifically configured to obtain the total execution time of the loop code block according to the time of executing the start instruction and the end instruction. The starting instruction comprises a forward jump instruction, and the execution times of the loop code block are obtained according to a target instruction of the forward jump instruction jump. And acquiring each execution time of the loop code block according to the interval of executing the target instruction each time.
In some embodiments, the code blocks include synchronization code blocks, and the identifying characteristics of the synchronization code blocks include lock holding statements and lock releasing statements.
The analysis module 21 is specifically configured to identify a lock holding statement and a lock releasing statement in the target code data. And when the lock holding statement and the lock releasing statement are identified, obtaining the position of the synchronous code block according to the positions of the lock holding statement and the lock releasing statement in the target code data.
In some embodiments, the embedding module 22 is specifically configured to obtain a time for blocking execution of the lock holding statement, where the time for blocking is a waiting time for obtaining the lock. And acquiring the lock holding time of the synchronous code block according to the execution time of the lock holding statement and the lock releasing statement.
In some embodiments, the embedding module 22 is specifically configured to, when multiple code blocks exist in the target code data, obtain an identifier of each code block and display the identifier. A user instruction is received, the user instruction including an identification of at least one code block. And embedding a corresponding monitoring code into the code block indicated by the identification of the code block contained in the user instruction.
In some embodiments, the presenting module 23 is configured to present the operation parameter of the code block when the operation duration of the code block is greater than a preset threshold.
The present disclosure also provides an electronic device, a readable storage medium, and a computer program product according to embodiments of the present disclosure.
An electronic device, comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a method as provided in the above embodiments.
In an exemplary embodiment, the readable storage medium may be a non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method according to the above embodiments.
In an exemplary embodiment, the computer program product comprises a computer program which, when executed by a processor, implements a method according to the provision in the above embodiments.
FIG. 3 illustrates a schematic block diagram of an example electronic device 300 that can be used to implement embodiments of the present disclosure.
Electronic devices are intended to represent various forms of devices having computing capabilities, such as personal computers, laptop computers, tablet computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic devices may also represent various forms of mobile devices, such as personal digital processors, cellular telephones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 3, the first device 300 includes a computing unit 301 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 302 or a computer program loaded from a storage unit 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the device 300 can also be stored. The calculation unit 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
Various components in device 300 are connected to I/O interface 305, including: an input unit 306 such as a keyboard, a mouse, or the like; an output unit 307 such as various types of displays, speakers, and the like; a storage unit 308 such as a magnetic disk, optical disk, or the like; and a communication unit 309 such as a network card, modem, wireless communication transceiver, etc. The communication unit 309 allows the device 300 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The computing unit 301 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of the computing unit 301 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The calculation unit 301 executes the respective methods and processes described above, such as a page rendering method. For example, in some embodiments, the page rendering method may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as storage unit 305.
In some embodiments, part or all of the computer program may be loaded and/or installed onto device 300 via ROM 302 and/or communication unit 309. When the computer program is loaded into RAM 303 and executed by computing unit 301, one or more steps of the page rendering method described above may be performed. Alternatively, in other embodiments, the computing unit 301 may be configured to perform the code block monitoring method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user may provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server with a combined blockchain.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be executed in parallel or sequentially or in different orders, and are not limited herein as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved.
The above detailed description should not be construed as limiting the scope of the disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present disclosure should be included in the scope of protection of the present disclosure.

Claims (10)

1. A code block monitoring method, comprising:
analyzing target code data according to preset code block identification characteristics to obtain the position of the code block in the target code data;
embedding a corresponding monitoring code into at least one code block according to the position of the code block, and acquiring the operating parameters of the code block through the monitoring code;
when the consumption of at least one code block is determined to be larger than a preset threshold value, displaying the running parameters of the code block.
2. The method of claim 1, wherein the code block comprises a loop code block, and wherein the identifying characteristics of the loop code block comprise a start instruction and an end instruction of the loop code block;
the analyzing the target code data according to the preset code block identification characteristics to obtain the position of the code block existing in the target code data includes:
identifying the start instruction and the end instruction in the object code data;
and when the identified starting instruction has the corresponding ending instruction, obtaining the position of the loop code block according to the positions of the starting instruction and the ending instruction in the target code data.
3. The method of claim 2, wherein obtaining the operating parameters of the code block through the monitoring code comprises:
acquiring the total execution time of the cyclic code block according to the time for executing the starting instruction and the ending instruction;
the starting instruction comprises a forward jump instruction, and the execution times of the loop code block are obtained according to a target instruction which indicates jump by the forward jump instruction;
and acquiring each execution time of the cyclic code block according to the interval of executing the target instruction each time.
4. The method of claim 1, wherein the code blocks comprise synchronous code blocks, and wherein the identifying characteristics of the synchronous code blocks comprise lock holding statements and lock releasing statements;
the analyzing the target code data according to the preset code block identification characteristics to obtain the position of the code block existing in the target code data includes:
identifying the lock holding statement and the lock releasing statement in the object code data;
and when the lock holding statement and the lock releasing statement are identified, obtaining the position of the synchronous code block according to the positions of the lock holding statement and the lock releasing statement in the target code data.
5. The method of claim 4, wherein obtaining the operating parameter of the code block through the monitoring code comprises:
acquiring the time for executing blocking by the lock holding statement, wherein the blocking time is the waiting time for acquiring the lock;
and acquiring the lock holding time of the synchronous code block according to the execution time of the lock holding statement and the lock releasing statement.
6. The method according to any one of claims 1-5, wherein said embedding a corresponding monitoring code into at least one of said code blocks comprises:
when a plurality of code blocks exist in the target code data, acquiring and displaying the identifier of each code block;
receiving a user instruction, wherein the user instruction comprises an identification of at least one code block;
and embedding a corresponding monitoring code into the code block indicated by the identification of the code block contained in the user instruction.
7. The method according to any one of claims 1-5, wherein the presenting the operating parameters of the code blocks when it is determined that the consumption of at least one of the code blocks is greater than a preset threshold comprises:
and when the running time of the code block is greater than a preset threshold value, displaying the running parameters of the code block.
8. A code block monitoring apparatus, comprising:
the analysis module is used for analyzing the target code data according to preset code block identification characteristics to acquire the position of the code block in the target code data;
the embedding module is used for embedding a corresponding monitoring code into at least one code block according to the position of the code block and acquiring the operating parameters of the code block through the monitoring code;
a display module, configured to display the operating parameter of the code block when it is determined that consumption of at least one of the code blocks is greater than a preset threshold.
9. An electronic device, characterized in that the electronic device comprises: a processor and a memory having executable instructions stored therein;
the processor is configured to, when executing the instructions, cause the electronic device to implement the method of any of claims 1-7.
10. A non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method of any one of claims 1-7.
CN202310044377.6A 2023-01-28 2023-01-28 Code block monitoring method and device, electronic equipment and readable storage medium Pending CN115981985A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310044377.6A CN115981985A (en) 2023-01-28 2023-01-28 Code block monitoring method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310044377.6A CN115981985A (en) 2023-01-28 2023-01-28 Code block monitoring method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN115981985A true CN115981985A (en) 2023-04-18

Family

ID=85964631

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310044377.6A Pending CN115981985A (en) 2023-01-28 2023-01-28 Code block monitoring method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN115981985A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090249304A1 (en) * 2008-03-26 2009-10-01 Wu Zhou Code Instrumentation Method and Code Instrumentation Apparatus
CN107967216A (en) * 2017-12-18 2018-04-27 网易(杭州)网络有限公司 Code detection method and device, equipment, computer-readable recording medium
CN109491907A (en) * 2018-11-05 2019-03-19 网易(杭州)网络有限公司 A kind of Caton detection method, device, electronic equipment and storage medium
CN112199261A (en) * 2019-07-08 2021-01-08 腾讯科技(深圳)有限公司 Application program performance analysis method and device and electronic equipment
CN115587046A (en) * 2022-11-08 2023-01-10 平安付科技服务有限公司 Code exception processing method and device, storage medium and computer equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090249304A1 (en) * 2008-03-26 2009-10-01 Wu Zhou Code Instrumentation Method and Code Instrumentation Apparatus
CN107967216A (en) * 2017-12-18 2018-04-27 网易(杭州)网络有限公司 Code detection method and device, equipment, computer-readable recording medium
CN109491907A (en) * 2018-11-05 2019-03-19 网易(杭州)网络有限公司 A kind of Caton detection method, device, electronic equipment and storage medium
CN112199261A (en) * 2019-07-08 2021-01-08 腾讯科技(深圳)有限公司 Application program performance analysis method and device and electronic equipment
CN115587046A (en) * 2022-11-08 2023-01-10 平安付科技服务有限公司 Code exception processing method and device, storage medium and computer equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
董雪燕: "《Web全栈开发 从入门到实战》", 中国铁道出版社, article 含蓄不含蓄, pages: 95 - 98 *

Similar Documents

Publication Publication Date Title
EP4160421A1 (en) Method and apparatus for obtaining browser running data, and storage medium
CN113220705A (en) Slow query identification method and device
CN115981985A (en) Code block monitoring method and device, electronic equipment and readable storage medium
CN114816393A (en) Information generation method, device, equipment and storage medium
CN115617800A (en) Data reading method and device, electronic equipment and storage medium
CN113139891B (en) Image processing method, device, electronic equipment and storage medium
CN115061921A (en) Automatic test method, device, electronic equipment and readable storage medium
CN114579191A (en) Instruction transmitting method and device, electronic equipment and storage medium
CN114238335A (en) Buried point data generation method and related equipment thereof
CN114564149A (en) Data storage method, device, equipment and storage medium
CN113778849A (en) Method, apparatus, device and storage medium for testing code
CN112988105A (en) Playing state control method and device, electronic equipment and storage medium
CN115563015B (en) Code heat statistics method, device, equipment and storage medium
CN113641544B (en) Method, apparatus, device, medium and product for detecting application state
CN113225228B (en) Data processing method and device
CN113962191B (en) Sequence randomization method and device, electronic equipment and storage medium
CN115455060A (en) Data processing method, device, equipment and medium
CN117453747A (en) Data quality detection method and device, electronic equipment and storage medium
CN117453628A (en) Application file management method, device equipment and storage medium
CN115983222A (en) EasyExcel-based file data reading method, device, equipment and medium
CN115794555A (en) Service log processing method, device, equipment and storage medium
CN116974940A (en) Interface testing method, device, equipment and storage medium
CN114328224A (en) Method and device for reproducing exception request, electronic equipment and storage medium
CN115718771A (en) Method, device and equipment for extracting drive code and storage medium
CN113901451A (en) Link detection method and device, electronic equipment and storage medium

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