Software program runtime delay monitoring method, device, storage medium and equipment
By building an analysis area of the main analyzer and timing function in the autonomous driving system, the problem of difficulty in quantifying the evaluation of the running delay of software programs in the prior art is solved, and accurate monitoring and evaluation of the running delay of code blocks in multi-threaded and high-concurrency environments is achieved.
Patent Information
- Application Number
- CN202210814888.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-12
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2042-07-12
AI Technical Summary
The prior art lacks an effective method that can quantify the operation delay of software programs, especially in complex environments with multi-threading, high concurrency.
By building the main analyzer in the code file of the software program and creating an analysis area with timing function for the code blocks of the specified area, the runtime delay of the code blocks of the specified area is obtained.
It realizes the accurate monitoring and quantification of the run-time delay of any code block in the software program without significantly affecting the system performance, improving the accuracy and efficiency of the evaluation.
Smart Images

Figure CN115033460B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of autonomous driving technology, and in particular to a method, device, storage medium and computer equipment for monitoring software program runtime delay. Background Art
[0002] At present, the autonomous driving system, especially the L4 autonomous driving system, is a huge system-level application that runs multi-threaded, highly concurrent complex programs inside. This makes the autonomous driving system extremely sensitive to runtime delays. When the system is running, any runtime delay that exceeds the threshold may cause serious consequences.
[0003] Therefore, it is necessary to design a monitoring method for software program runtime delay in order to quantitatively evaluate the runtime delay of the software program. Summary of the invention
[0004] The purpose of the present application is to solve at least one of the above-mentioned technical deficiencies, especially the technical defect that the prior art lacks a software program runtime delay monitoring method that can quantitatively evaluate the runtime delay of the software program.
[0005] The present application provides a method for monitoring software program runtime delay, the method comprising:
[0006] Building a main analyzer in a code file of a software program whose runtime delay is to be monitored, wherein the main analyzer is a global static variable;
[0007] Using the main analyzer to create an analysis area for a code block in a designated area of the code file, the analysis area has a timing function, and the designated area is an area corresponding to the code block concerned by the user in the code file;
[0008] The software program is executed, and during the running of the software program, the running delay of the code block in the designated area is obtained through the timing function of the analysis area.
[0009] Optionally, the software program includes a main function and at least one sub-function;
[0010] The step of using the main analyzer to create an analysis area for a code block in a specified area of the code file includes:
[0011] Determine a code block in a specified area of the code file and a function corresponding to the code block;
[0012] The main analyzer is used to create an analysis area for the code blocks in the specified area in the code file according to the functions corresponding to the code blocks in the specified area in the code file and the calling relationship between the main function and at least one sub-function in the software program.
[0013] Optionally, the method further comprises:
[0014] Obtaining a creation request for creating an analysis area for a code block in a specified area of the code file, wherein the creation request includes a function corresponding to the code block for which creation of the analysis area is requested;
[0015] By polling the mapping relationship between the function corresponding to the pre-created code block and the zone name of the analysis zone corresponding to the code block without locking the HashMap, it is determined whether the function corresponding to the code block requesting to create the analysis zone has the zone name of the analysis zone corresponding to the code block;
[0016] If it exists, the name of the analysis area corresponding to the code block will be used as the name of the analysis area to be created.
[0017] Optionally, the timing function includes a start timing function and a stop timing function;
[0018] The obtaining the runtime delay of the code block in the designated area through the timing function of the analysis area includes:
[0019] When the software program runs to the code block in the designated area, the start running time of the code block is counted by the start timing function in the analysis area to obtain a first statistical result;
[0020] And, the termination running time of the code block is counted through the termination timing function or the function exit time in the analysis area to obtain a second statistical result;
[0021] The runtime delay of the code block in the designated area is determined according to the first statistical result and the second statistical result.
[0022] Optionally, the method further comprises:
[0023] By using the timing function of the analysis area, the acquired runtime delay of the code block in the designated area is stored according to a pre-configured timing storage mode;
[0024] The timing storage mode is configured according to the number of processes of the target program.
[0025] Optionally, the analysis area also has an aggregation function, and the method further comprises:
[0026] Through the aggregation function of the analysis area, the running delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period is discretely stored according to a preset discrete strategy.
[0027] Optionally, when the preset discrete strategy is a linear strategy, the aggregation function of the analysis area is used to discretely store the running delay of the code block of the designated area stored in the analysis area each time the software program is executed according to the preset discrete strategy, including:
[0028] Counting the running delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period to obtain a statistical result;
[0029] Determine, according to the statistical results, a plurality of linear growth intervals for discretely storing each runtime delay in a linear growth manner;
[0030] The runtime delay of the code block in the designated area stored in the analysis area when the software program is executed each time within a preset time period is divided according to each linear growth interval, and the divided runtime delay is discretely stored.
[0031] Optionally, when the preset discrete strategy is an exponential strategy, the aggregation function of the analysis area is used to discretely store the runtime delay of the code block of the designated area stored in the analysis area each time the software program is executed according to the preset discrete strategy, including:
[0032] Counting the running delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period to obtain a statistical result;
[0033] Determine, according to the statistical results, a plurality of exponential growth intervals for discretely storing each runtime delay in an exponential growth manner;
[0034] The runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period is divided according to each exponential growth interval, and the divided runtime delay is discretely stored.
[0035] Optionally, when the preset discrete strategy is an interpolation-exponential strategy, the aggregation function of the analysis area is used to discretely store the runtime delay of the code block of the designated area stored in the analysis area each time the software program is executed according to the preset discrete strategy, including:
[0036] Counting the running delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period to obtain a statistical result;
[0037] Determine, according to the statistical results, a plurality of interpolation-exponential growth intervals for discretely storing each runtime delay in an interpolation-exponential growth manner;
[0038] The runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period is divided according to each interpolation-exponential growth interval, and the divided runtime delay is discretely stored.
[0039] Optionally, the method further comprises:
[0040] The running delay of the code block in the designated area stored discretely each time the software program is executed is written into the target file according to the preset acquisition frequency.
[0041] The present application provides a monitoring device for software program runtime delay, comprising:
[0042] A main analyzer construction module, used to construct a main analyzer in a code file of a software program whose runtime delay is to be monitored, wherein the main analyzer is a global static variable;
[0043] An analysis area creation module, used to create an analysis area for a code block in a specified area of the code file using the main analyzer, wherein the analysis area has a timing function, and the specified area is an area corresponding to a code block concerned by a user in the code file;
[0044] The runtime delay monitoring module is used to execute the software program and obtain the runtime delay of the code block in the designated area through the timing function of the analysis area during the running of the software program.
[0045] Optionally, the software program includes a main function and at least one sub-function;
[0046] The analysis area creation module includes:
[0047] A function determination module, used to determine a code block in a specified area of the code file and a function corresponding to the code block;
[0048] A creation module is used to use the main analyzer to create an analysis area for the code blocks in the specified area in the code file according to the functions corresponding to the code blocks in the specified area in the code file and the calling relationship between the main function and at least one sub-function in the software program.
[0049] Optionally, the timing function includes a start timing function and a stop timing function;
[0050] The runtime delay monitoring module includes:
[0051] A first statistical module is used for, when the software program runs to the code block in the designated area, to count the start running time of the code block through the start timing function in the analysis area to obtain a first statistical result;
[0052] A second statistical module is used to count the termination running time of the code block through the termination timing function in the analysis area or the function exit time to obtain a second statistical result;
[0053] A timing module is used to determine the runtime delay of the code block in the designated area according to the first statistical result and the second statistical result.
[0054] Optionally, the device further comprises:
[0055] A storage module, configured to store the acquired runtime delay of the code block of the designated area according to a pre-configured timing storage mode through the timing function of the analysis area;
[0056] Wherein, the timing storage mode is configured according to the number of processes of the software program.
[0057] Optionally, the analysis area also has a polymerization function, and the device further comprises:
[0058] The aggregation module is used to discretely store the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period according to a preset discrete strategy through the aggregation function of the analysis area.
[0059] Optionally, the device further comprises:
[0060] The disk writing module is used to write the code blocks of the designated area in discrete storage into a target file according to a preset acquisition frequency during each execution of the software program.
[0061] The present application also provides a storage medium, including: the storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the method for monitoring the runtime delay of a software program as described in any of the above embodiments.
[0062] The present application also provides a computer device, comprising: one or more processors, and a memory;
[0063] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the method for monitoring the runtime delay of a software program as described in any one of the above embodiments are performed.
[0064] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0065] The present application provides a method, device, storage medium and computer equipment for monitoring the runtime delay of a software program. When quantitatively evaluating the runtime delay of a software program, a main analyzer can be first constructed in the code file of the software program whose runtime delay is to be monitored. The main analyzer is a global static variable, which not only ensures that its life cycle is earlier and longer than the software program, but also ensures that when multiple code files of the software program construct the main analyzer, each code file obtains the same main analyzer, thereby making the main analyzer unique in the software program; then, the present application can use the main analyzer to create an analysis area for the code block in the specified area in the code file, and after the creation The analysis area has a timing function, so that during the execution of the software program, the timing function of the analysis area can be used to obtain the runtime delay of the code block in the specified area, thereby achieving the effect of quantitative evaluation; in addition, when creating the analysis area, the present application mainly creates the analysis area in the area corresponding to the code block that the user is concerned about in the code file, and does not configure the entire software program, so that the software program has a lower demand for computing resources of the computing platform during the execution process, and then the runtime delay of any code block in a multi-threaded, high-concurrency complex application can be monitored without significantly affecting the system performance, thereby effectively improving the accuracy and efficiency of the quantitative evaluation of the runtime delay of the software program. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0067] Figure 1 A flow chart of a method for monitoring software program runtime delay provided in an embodiment of the present application;
[0068] Figure 2 A schematic diagram of the structure of a device for monitoring software program runtime delay provided in an embodiment of the present application;
[0069] Figure 3 A schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0070] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0071] At present, the autonomous driving system, especially the L4 autonomous driving system, is a huge system-level application that runs multi-threaded, highly concurrent complex programs inside. This makes the autonomous driving system extremely sensitive to runtime delays. When the system is running, any runtime delay that exceeds the threshold may cause serious consequences.
[0072] Therefore, it is necessary to design a software program runtime delay monitoring method to quantitatively evaluate the software program runtime delay. For details, see below:
[0073] In one embodiment, Figure 1 As shown, Figure 1 A flow chart of a method for monitoring software program runtime delay provided in an embodiment of the present application; the present application provides a method for monitoring software program runtime delay, the method may include:
[0074] S110: Building a main analyzer in a code file of a software program whose runtime delay is to be monitored.
[0075] In this step, when it is necessary to record the runtime delay of a software program, the software program can be used as the software program whose runtime delay is to be monitored, and a main analyzer can be built in the code file of the software program. The main analyzer is used to record and count the runtime delay of the code blocks that the user is concerned about in the code file, and save it in various files in various forms.
[0076] Specifically, after obtaining at least one code file of the software program, the main analyzer can be constructed and obtained by calling the main analyzer acquisition function. The main analyzer acquisition function can construct and return a static singleton of the main analyzer based on various configuration parameters with default values. The configuration parameters can be parameters used when configuring the timing function, parameters used when configuring the storage strategy, and other parameters used to configure the runtime delay of the software program. There is no limitation here.
[0077] Furthermore, the present application can construct the main analyzer as a global variable within the code file, so that the life cycle of the returned singleton is earlier and longer than that of the original program; at the same time, the present application can also construct the internal structure of the main analyzer acquisition function as a static variable, so as to ensure that when multiple code files of a software program obtain the main analyzer by calling the main analyzer acquisition function, each code file obtains an identical singleton of the main analyzer, thereby making the main analyzer unique in the software program, so as to facilitate the construction of the analysis area.
[0078] It should be noted that the runtime delay here refers to the time spent by the processor in the process of executing the software program. The longer the processor spends executing the software program, the longer the response time of the current system. Relative to the user, it means that the current system has a certain delay.
[0079] The code file here can be the source file of the software program. For a software program, the code file generally includes header files and source files. The header file contains function declarations, macro definitions, structure definitions, etc., and the source file contains function implementations, variable definitions, etc. Since a software program may contain multiple functions, such as the main function, sub-functions at different levels, etc., a software program may contain multiple source files.
[0080] In addition, the software program in the present application can be a single-process application or a multi-threaded, high-concurrency application. The application can be an autonomous driving application, a life and entertainment application, or an instant messaging application, and there is no limitation here.
[0081] S120: Using the main analyzer to create an analysis area for the code block in the specified area in the code file.
[0082] In this step, before monitoring the runtime delay of the software program, the main analyzer can be used to create an analysis area for the code block in the specified area in the code file of the software program. Since the analysis area is created through the main analysis area, the created analysis area can inherit some or all of the functions of the main analyzer. For example, the analysis area in the present application has a timing function after being created, and the timing function can be used to count the running time of the software program. Of course, the analysis area in the present application can also have other functions after being created, such as aggregation function, storage function, etc., which are not limited here.
[0083] It can be understood that the designated area here is the area corresponding to the code block that the user is concerned about in the code file of the software program. For example, when it is necessary to monitor the runtime delay of a few lines of code fragments in a function of a software program, the area corresponding to the code block composed of the few lines of code fragments can be used as the designated area, and the folder where the sub-function corresponding to the code block is located can be used as the code file; when there are multiple code blocks that the user is concerned about, and the multiple code blocks are located in multiple source files, the present application can create corresponding analysis areas for the code blocks in the designated area of each source file respectively, and monitor the runtime delay of the corresponding code block through the timing function of each analysis area, so as to achieve the purpose of quantitative evaluation.
[0084] The timing function here can include both corresponding timing strategies, such as where to start timing and where to end timing in the software program, and corresponding timing sources. The timing source can select CPU TSC as a timing reference and provide multiple timing storage modes, such as sixteen-bit atomic quantity mode, eight-bit atomic quantity mode and single-threaded mode. Among them, sixteen-bit atomic quantity and eight-bit atomic quantity can ensure that time is stored in a lock-free manner under high concurrency of multiple threads, and the mode can be selected according to actual accuracy and performance requirements; for single-process software programs, single-threaded mode can be used to reduce system overhead and simplify program operation logic. In addition, the timing function in this application can also include the function of converting the accumulated TSC value into real time through std::chrono.
[0085] Furthermore, considering the various needs of current users, software programs are mostly developed in a multi-threaded, high-concurrency mode to meet the different needs of users. When the software program in this application is a multi-threaded, high-concurrency application, in order to trace the code blocks at different locations in different code files and achieve accurate and efficient performance statistics and analysis of the entire software system, this application can create a multi-level analysis area for the code blocks corresponding to the specified areas in the code files of the software program, so that when tracing the code blocks, it can be directly traced based on the analysis area, which is concise and efficient.
[0086] S130: executing the software program, and obtaining the runtime delay of the code block in the designated area by analyzing the timing function of the area during the running of the software program.
[0087] In this step, after creating an analysis area for the code block in the specified area of the code file of the software program using the main analyzer through S120, the software program can be executed, and during the running of the software program, the running delay of the code block in the specified area is obtained through the timing function configured in the analysis area.
[0088] Specifically, in the present application, before executing the software program, an analysis area is created for the code blocks in the specified area in the code file of the software program, and the analysis area has a timing function. In this way, after the software program is compiled, linked and executed, the corresponding analysis area can obtain the runtime delay of the code blocks in the specified area through the timing function, and the developer can perform statistics and analysis on the runtime delay to improve the overall performance of the system.
[0089] It can be understood that when the present application constructs a main analyzer in the code file of a software program and uses the main analyzer to create an analysis area for the code block in the specified area in the code file, the present application can use a compiler to compile the source code in the code file after the analysis area is created, and after converting it into machine language, a linker can be used to combine the various modules generated by the compiler in the source code, and then necessary code modules are added from the program library provided by the program language to form an executable file, so that the software program can be executed and the runtime delay generated during the running of the software program can be obtained.
[0090] In the above embodiment, when the runtime delay of the software program is quantitatively evaluated, a main analyzer can be first constructed in the code file of the software program whose runtime delay is to be monitored. The main analyzer is a global static variable, which can not only ensure that its life cycle is earlier and longer than the software program, but also ensure that when multiple code files of the software program construct the main analyzer, each code file obtains the same main analyzer, so that the main analyzer is unique in the software program; then, the present application can use the main analyzer to create an analysis area for the code block in the specified area in the code file, and the created analysis area has a timing function, so that in the process of executing the software program, the runtime delay of the code block in the specified area can be obtained through the timing function of the analysis area, thereby achieving the effect of quantitative evaluation; in addition, when creating the analysis area, the present application mainly creates the analysis area in the area corresponding to the code block that the user is concerned about in the code file, and does not configure the entire software program, so that the software program has a lower demand for computing resources of the computing platform during the execution process, and then the runtime delay of any code block in a multi-threaded, high-concurrency complex application can be monitored without significantly affecting the system performance, thereby effectively improving the accuracy and efficiency of the quantitative evaluation of the runtime delay of the software program.
[0091] In one embodiment, the software program includes a main function and at least one sub-function; using the main analyzer to create an analysis area for a code block in a specified area of the code file in S120 may include:
[0092] S121: Determine a code block in a specified area of the code file and a function corresponding to the code block.
[0093] S122: Using the main analyzer to create an analysis area for the code blocks in the specified area in the code file according to the functions corresponding to the code blocks in the specified area in the code file and the calling relationship between the main function and at least one sub-function in the software program.
[0094] In this embodiment, after the main analyzer is built in the code file, the application can first determine the area corresponding to the code block of the user's interest in the code file, and use the area as the designated area in the code file. Next, the application can determine the function corresponding to the code block in the designated area, and then use the main analyzer to create an analysis area corresponding to the designated area based on the function corresponding to the code block in the designated area and the calling relationship between the main function and at least one sub-function in the software program.
[0095] Specifically, the present application can use the main analyzer to construct analysis areas in designated areas in the code file. Each analysis area can be configured with a corresponding monitoring function separately, or with the same monitoring function. The monitoring function can be a timing function, an aggregation function, or other functions that can realize runtime delay monitoring. In addition, all analysis areas in the present application are constructed inside the main analyzer and owned by it. The constructed location can be a global location outside the function, that is, the global location of the code file, or it can be inside the specific function that needs to be measured, that is, the location of the code block. When the analysis area is constructed at the global location of the code file, it indicates that the monitoring function configured in the analysis area is valid for the entire code file, and when the analysis area is constructed at the location of the code block, it indicates that the monitoring function configured in the analysis area is only valid for the code block.
[0096] In a specific implementation, when the main analyzer is used to construct the analysis area corresponding to the specified area, it can be constructed according to the function call relationship between the main function and at least one sub-function in the software program, and the function corresponding to the code block of the specified area. For example, when a general software program is running, its main function and the sub-functions of each level form a tree structure, the main function is the root node of the tree structure, and the sub-functions of each level are the branch nodes of the tree structure; and when the application monitors the runtime delay of the software program, the main analyzer is constructed as a global static variable to make it unique in the software program, and then when the analysis area is constructed according to the function call relationship between the main function and at least one sub-function in the software program, and the function corresponding to the code block of the specified area, the main analyzer can be used as the root node, and the different functions in each code file can be used as branch nodes to construct the analysis area.
[0097] For example, when the main function of a software program calls functions a() and b() in sequence, and function b() calls functions b1() and b2() in sequence, the present application can construct the following three analysis areas in the global position of the code file:
[0098] section a=MainProfiler()->Section("a");
[0099] section b1=MainProfiler()->Section(“b”)->Section(“b1”);
[0100] section b2=MainProfiler()->Section(“b”)->Section(“b2”);
[0101] Among them, MainProfiler() is the root node, that is, the main analyzer in this application. There are two branch nodes under this root node, namely a and b, and there are two branch nodes under node b1 and b2. When a code file contains the specific implementation of one or more functions, and the code blocks corresponding to one or more functions need to monitor the runtime delay, this application can construct the corresponding analysis area according to the function corresponding to the code file where the code block is located and the calling relationship of the function in the software program.
[0102] In one embodiment, the method may further include:
[0103] S123: Obtain a creation request for creating an analysis area for a code block in a specified area in the code file, wherein the creation request includes a function corresponding to the code block for requesting to create the analysis area.
[0104] S124: Determine whether the function corresponding to the code block requested to create the analysis area has the area name of the analysis area corresponding to the code block by polling the mapping relationship between the function corresponding to the pre-created code block and the area name of the analysis area corresponding to the code block without locking the HashMap.
[0105] S125: If it exists, the name of the analysis area corresponding to the code block is used as the name of the analysis area to be created.
[0106] In this embodiment, since the analysis area may be created inside a function when the application creates the analysis area, when the analysis area is created inside a function and the original program is a multi-threaded high-concurrency application, there may be multiple requests to create a certain analysis area at the same time, which may cause data competition problems.
[0107] Therefore, the present application can obtain a creation request when creating an analysis area for a code block in a specified area in a code file, and the creation request includes a function corresponding to the code block requesting the creation of the analysis area. Then, the present application can poll the mapping relationship between the function corresponding to the pre-created code block and the area name of the analysis area corresponding to the code block without locking through a HashMap, so as to determine whether the function corresponding to the code block requesting the creation of the analysis area has the area name of the analysis area corresponding to the code block. If so, the area name of the analysis area corresponding to the code block will be used as the area name of the analysis area to be created.
[0108] For example, when function b1() is called multiple times simultaneously, there will be multiple requests to create section b1 at the same time. Therefore, in order to ensure that the program efficiently creates only one section b1 in the global static variable, and then returns the unique b1 to all creation requests, the present application can use HashMap to poll the mapping relationship between the area name of the pre-created analysis area and the function corresponding to the code block of the analysis area without locking, and determine whether the function corresponding to the code block of the current request to create the analysis area has the corresponding area name of the analysis area. If so, the area name of the analysis area is directly used as the area name of the analysis area to be created by the code block of the current request to create the analysis area, so as to ensure the uniqueness of the construction. At the same time, there is no use of mutex locks, which ensures the efficiency of creation and acquisition at runtime.
[0109] In one embodiment, the timing function may include a start timing function and a stop timing function.
[0110] In S130, obtaining the runtime delay of the code block in the designated area by using the timing function of the analysis area may include:
[0111] S131: When the software program runs to the code block in the designated area, statistics are collected on the start running time of the code block through the start timing function in the analysis area to obtain a first statistical result.
[0112] S132: Counting the termination running time of the code block through the termination timing function in the analysis area or the function exit time to obtain a second statistical result.
[0113] S133: Determine the runtime delay of the code block in the designated area according to the first statistical result and the second statistical result.
[0114] In this embodiment, during the execution of the software program, the present application may use the timing function configured in the analysis area to obtain the runtime delay of the code block in the specified area.
[0115] Among them, the timing function in the present application may include a start timing function BeginTiming() and an end timing function EndTiming(). When the software program runs to the code block in the specified area, the BeginTiming() function of the corresponding analysis area can be called to start timing the running time of the code block and obtain a first statistical result. When the function exits or displays the call to the EndTiming() function, the timing is terminated to obtain a second statistical result. Then, the present application can determine the running delay of the code block in the specified area based on the first statistical result and the second statistical result.
[0116] It is understandable that the BeginTiming() function and the EndTiming() function accumulate time by constructing and destroying the timing module inside the time zone. When a timing module is constructed, it automatically starts timing. When a timing module is destroyed, it automatically stops timing and reports the accumulated time. In addition, as the basis for monitoring the running delay of the software program, the timing module needs to have the ability to read various time sources. The time given by the time source will be used to calculate the program execution time. The time source in this application can select the CPU TSC as the timing reference. TSC (Time Stamp Counter) is a register located in the CPU, and its value increases by one for each CPU clock cycle.
[0117] Furthermore, after obtaining the first statistical result and the second statistical result, the present application can calculate the absolute value of the difference between the first statistical result and the second statistical result to count the runtime delay of this code block. Of course, the present application can also select the middle value, maximum value, or average value between the first statistical result and the second statistical result as the runtime delay of this code block, which is not limited here.
[0118] In one embodiment, the method may further include:
[0119] Optionally, the method further comprises:
[0120] S140: Using the timing function of the analysis area, the acquired runtime delay of the code block in the designated area is stored according to a pre-configured timing storage mode.
[0121] The timing storage mode is configured according to the number of processes of the target program.
[0122] In this embodiment, after the runtime delay of the code block in the specified area is obtained, the runtime delay can be stored according to a preconfigured timing storage mode through the timing function of the analysis area. The timing storage mode can be configured according to the number of processes of the target program.
[0123] For example, this application can use the 16-bit atomic quantity mode, the 8-bit atomic quantity mode or the single-thread mode to store the runtime delay of the code block in the specified area. Among them, the 16-bit atomic quantity and the 8-bit atomic quantity can ensure that the time is stored in a lock-free manner under multi-threaded high concurrency, and the mode can be selected according to the actual accuracy and performance requirements; for single-process applications, the single-thread mode can be simply used to reduce system overhead and simplify program operation logic.
[0124] Furthermore, if the present application selects CPU TSC as the timing reference, when obtaining the runtime delay corresponding to the code block in the specified area, the analysis area can also use the timing function to convert the accumulated TSC value into real time through std::chrono, so as to facilitate user viewing.
[0125] In one embodiment, the analysis area further has an aggregation function, and the method may further include:
[0126] S150: by using the aggregation function of the analysis area, discretely storing the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period according to a preset discrete strategy.
[0127] In this embodiment, the analysis area constructed using the main analyzer can also have an aggregation function, which can be used to discretely store the runtime delay of the code block in the specified area stored in the analysis area each time the software program is executed within a preset time period according to a preset discrete strategy.
[0128] Specifically, the real time converted by the timing function of the analysis area can be aggregated by the aggregation function of the analysis area. Aggregating data can reduce statistical noise and improve the convenience of analyzing time data. The aggregation function is responsible for discretely storing the runtime delays stored in the analysis area according to a certain strategy, so that users can obtain specific time distribution information.
[0129] Furthermore, the aggregation function of the present application can support multiple discrete strategies, such as linear, exponential and interpolation-exponential. Among them, the linear strategy can discretely store the runtime delay of the code block from the start of the original program to the current moment according to a linear time interval; the exponential strategy can discretely store the runtime delay of the code block from the start of the software program to the current moment according to an exponential time interval; the interpolation-exponential strategy can discretely store the runtime delay of the code block from the start of the software program to the current moment according to an interpolation-exponential time interval. After the data is discretely stored, its probability distribution and number of occurrences can be obtained at any time, which is convenient for subsequent statistics and analysis.
[0130] In one embodiment, when the preset discrete strategy is a linear strategy, S150 uses the aggregation function of the analysis area to discretely store the running delay of the code block of the designated area stored in the analysis area each time the software program is executed according to the preset discrete strategy, which may include:
[0131] S151: Counting the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period to obtain a statistical result.
[0132] S152: Determine, according to the statistical result, a plurality of linear growth intervals for discretely storing each running delay in a linear growth manner.
[0133] S153: dividing the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period according to each linear growth interval, and discretely storing the divided runtime delay.
[0134] In this embodiment, when the preset discrete strategy is a linear strategy, it means that the runtime delays stored in the analysis area each time the software program is executed can be arranged in a linear growth manner, and the runtime delays in each linear growth interval are discretely stored.
[0135] Specifically, the present application can statistically analyze the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period, and determine, based on the statistical results, multiple linear growth intervals for discretely storing each runtime delay in a linear growth manner. Then, the present application can divide the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period according to each linear growth interval, and discretely store the divided runtime delay.
[0136] For example, the runtime delay of the code block in the designated area stored in the statistical analysis area of the present application each time the software program is executed within a preset time period can be sorted in a linear growth manner such as 1ms, 2ms, 3ms..., and the runtime delays in the linear growth intervals of 1ms~2ms, 2ms~3ms, etc. can be discretely stored. In this way, the number of runtime delays counted in each linear growth interval can be intuitively understood, thereby obtaining the probability distribution and occurrence frequency of the runtime delays in the preset time period for subsequent statistics and analysis.
[0137] In one embodiment, when the preset discrete strategy is an exponential strategy, S150 uses the aggregation function of the analysis area to discretely store the running delay of the code block of the designated area stored in the analysis area each time the software program is executed according to the preset discrete strategy, which may include:
[0138] S501: Counting the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period to obtain a statistical result.
[0139] S502: Determine, according to the statistical result, a plurality of exponential growth intervals for discretely storing each runtime delay in an exponential growth manner.
[0140] S503: dividing the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period according to each exponential growth interval, and discretely storing the divided runtime delay.
[0141] In this embodiment, when the preset discrete strategy is the exponential strategy, it means that the runtime delays stored in the analysis area each time the software program is executed can be arranged in an exponential growth manner, and the runtime delays in each exponential growth interval are discretely stored.
[0142] Specifically, the present application can statistically analyze the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period, and determine, based on the statistical results, multiple exponential growth intervals for discretely storing each runtime delay in an exponential growth manner. Then, the present application can divide the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period according to each exponential growth interval, and discretely store the divided runtime delay.
[0143] For example, the runtime delay of the code block in the designated area stored in the statistical analysis area of the present application each time the software program is executed within a preset time period can be sorted in an exponential growth manner such as 1ms, 1.5ms, 2.25ms..., and the runtime delays in the exponential growth ranges of 1ms~1.5ms, 1.5ms~2.25ms, etc. can be discretely stored. In this way, the number of runtime delays counted in each exponential growth interval can be intuitively understood, thereby obtaining the probability distribution and occurrence frequency of the runtime delays in the preset time period for subsequent statistics and analysis.
[0144] In one embodiment, when the preset discrete strategy is the interpolation-exponential strategy, S150 uses the aggregation function of the analysis area to discretely store the running delay of the code block of the designated area stored in the analysis area each time the software program is executed according to the preset discrete strategy, which may include:
[0145] S511: Counting the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period to obtain a statistical result.
[0146] S512: Determine, according to the statistical result, a plurality of interpolation-exponential growth intervals for discretely storing each running delay in an interpolation-exponential growth manner.
[0147] S513: dividing the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period according to each interpolation-exponential growth interval, and discretely storing the divided runtime delay.
[0148] In this embodiment, when the preset discrete strategy is the interpolation-exponential strategy, it means that the runtime delay stored in the analysis area each time the software program is executed can be arranged in an interpolation-exponential growth manner, and the runtime delay in each interpolation-exponential growth interval can be discretely stored.
[0149] Specifically, the present application can statistically analyze the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period, and determine, based on the statistical results, multiple interpolation-exponential growth intervals for discretely storing each runtime delay by means of interpolation-exponential growth. Then, the present application can divide the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period according to each interpolation-exponential growth interval, and discretely store the divided runtime delay.
[0150] For example, the runtime delay of the code block in the designated area stored in the statistical analysis area of the present application each time the software program is executed within a preset time period can be set to a base of 1 and a factor of 4, such as 1ms, 1.25ms, 1.5ms, 1.75ms, 2ms, 2.5ms, 3ms, 3.5ms, 4ms... Such an interpolation-exponential growth method sorts the runtime delays and discretely stores the runtime delays in the interpolation-exponential growth intervals of 1ms to 1.25ms, 1.25ms to 1.5ms, etc., so that the number of runtime delays counted in each interpolation-exponential growth interval can be intuitively understood, thereby obtaining the probability distribution and occurrence frequency of the runtime delays in the preset time period for subsequent statistics and analysis.
[0151] In one embodiment, the method may further include:
[0152] The running delay of the code block in the designated area stored discretely each time the target program is executed is written into the target file according to the preset acquisition frequency.
[0153] In this embodiment, when the software program starts to run, a separate thread will run in the main analyzer, which is responsible for writing all collected data into the target file at a certain collection frequency and resetting it after writing.
[0154] Specifically, all the data here refers to the runtime delay of the code block in the specified area each time the software program is executed; the target file here refers to the file that stores the runtime delay collected during runtime, such as text logs, binary logs, etc. The runtime delay is written to the disk through the target file, which makes it convenient to observe the distribution of data with the naked eye, and can also standardize the automatic data capture process and optimize disk reading and writing.
[0155] The following describes a software program runtime delay monitoring device provided in an embodiment of the present application. The software program runtime delay monitoring device described below and the software program runtime delay monitoring method described above can correspond to each other.
[0156] In one embodiment, Figure 2 As shown, Figure 2 A schematic diagram of a software program runtime delay monitoring device provided in an embodiment of the present application; the present application also provides a software program runtime delay monitoring device, which may include a main analyzer construction module 210, an analysis area creation module 220 and a runtime delay monitoring module 230, specifically including the following:
[0157] The main analyzer construction module 210 is used to construct a main analyzer in the code file of the software program whose runtime delay is to be monitored, and the main analyzer is a global static variable.
[0158] The analysis area creation module 220 is used to use the main analyzer to create an analysis area for the code block in the specified area of the code file, the analysis area has a timing function, and the specified area is the area corresponding to the code block that the user is concerned about in the code file.
[0159] The runtime delay monitoring module 230 is used to execute the software program and obtain the runtime delay of the code block in the designated area through the timing function of the analysis area during the running of the software program.
[0160] In the above embodiment, when the runtime delay of the software program is quantitatively evaluated, a main analyzer can be first constructed in the code file of the software program whose runtime delay is to be monitored. The main analyzer is a global static variable, which can not only ensure that its life cycle is earlier and longer than the software program, but also ensure that when multiple code files of the software program construct the main analyzer, each code file obtains the same main analyzer, so that the main analyzer is unique in the software program; then, the present application can use the main analyzer to create an analysis area for the code block in the specified area in the code file, and the created analysis area has a timing function, so that in the process of executing the software program, the runtime delay of the code block in the specified area can be obtained through the timing function of the analysis area, thereby achieving the effect of quantitative evaluation; in addition, when creating the analysis area, the present application mainly creates the analysis area in the area corresponding to the code block that the user is concerned about in the code file, and does not configure the entire software program, so that the software program has a lower demand for computing resources of the computing platform during the execution process, and then the runtime delay of any code block in a multi-threaded, high-concurrency complex application can be monitored without significantly affecting the system performance, thereby effectively improving the accuracy and efficiency of the quantitative evaluation of the runtime delay of the software program.
[0161] In one embodiment, the software program includes a main function and at least one sub-function.
[0162] The analysis area creation module may include:
[0163] The function determination module is used to determine the code block in the specified area of the code file and the function corresponding to the code block.
[0164] A creation module is used to use the main analyzer to create an analysis area for the code blocks in the specified area in the code file according to the functions corresponding to the code blocks in the specified area in the code file and the calling relationship between the main function and at least one sub-function in the software program.
[0165] In one embodiment, the device may further include:
[0166] The creation request acquisition module is used to acquire a creation request when creating an analysis area for a code block in a specified area in the code file, wherein the creation request includes a function corresponding to the code block requesting the creation of the analysis area.
[0167] The polling module is used to poll the mapping relationship between the function corresponding to the pre-created code block and the zone name of the analysis zone corresponding to the code block without locking through HashMap, and determine whether the function corresponding to the code block requesting to create the analysis zone has the zone name of the analysis zone corresponding to the code block.
[0168] The area name determination module is used to use the area name of the analysis area corresponding to the code block as the area name of the analysis area to be created if it exists.
[0169] In one embodiment, the timing function includes a start timing function and a stop timing function.
[0170] The runtime delay monitoring module may include:
[0171] The first statistical module is used to count the start running time of the code block through the start timing function in the analysis area when the software program runs to the code block in the designated area, so as to obtain a first statistical result.
[0172] The second statistical module is used to count the termination running time of the code block through the termination timing function in the analysis area or the function exit time to obtain a second statistical result.
[0173] A timing module is used to determine the runtime delay of the code block in the designated area according to the first statistical result and the second statistical result.
[0174] In one embodiment, the device may further include:
[0175] The storage module is used to store the acquired runtime delay of the code block in the designated area according to a pre-configured timing storage mode through the timing function of the analysis area.
[0176] Wherein, the timing storage mode is configured according to the number of processes of the software program.
[0177] In one embodiment, the analysis area also has a polymerization function, and the device may further include:
[0178] The aggregation module is used to discretely store the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period according to a preset discrete strategy through the aggregation function of the analysis area.
[0179] In one embodiment, when the preset discrete strategy is a linear strategy, the aggregation module may include:
[0180] The first statistical module is used to count the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period to obtain a statistical result.
[0181] The first determining module is used to determine, according to the statistical result, a plurality of linear growth intervals when discretely storing each running delay in a linear growth manner.
[0182] The first division module is used to divide the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period according to each linear growth interval, and discretely store the divided runtime delay.
[0183] In one embodiment, when the preset discrete strategy is an exponential strategy, the aggregation module may include:
[0184] The second statistical module is used to count the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period to obtain a statistical result.
[0185] The second determining module is used to determine, according to the statistical result, a plurality of exponential growth intervals when each runtime delay is discretely stored in an exponential growth manner.
[0186] The second division module is used to divide the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period according to each exponential growth interval, and discretely store the divided runtime delay.
[0187] In one embodiment, when the preset discrete strategy is an interpolation-exponential strategy, the aggregation module may include:
[0188] The third statistical module is used to count the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period to obtain a statistical result.
[0189] The third determination module is used to determine, according to the statistical result, a plurality of interpolation-exponential growth intervals when each running delay is discretely stored in an interpolation-exponential growth manner.
[0190] The third division module is used to divide the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period according to each interpolation-exponential growth interval, and discretely store the divided runtime delay.
[0191] In one embodiment, the device may further include:
[0192] The disk writing module is used to write the code blocks of the designated area in discrete storage into a target file according to a preset acquisition frequency during each execution of the software program.
[0193] In one embodiment, the present application also provides a storage medium, including: computer-readable instructions are stored in the storage medium, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the method for monitoring the runtime delay of the software program as described in any of the above embodiments.
[0194] In one embodiment, the present application also provides a computer device, including: one or more processors, and a memory.
[0195] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the method for monitoring the runtime delay of a software program as described in any one of the above embodiments are performed.
[0196] Indicatively, Figure 3 As shown, Figure 3 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. The computer device 300 may be provided as a server. Figure 3 The computer device 300 includes a processing component 302, which further includes one or more processors, and a memory resource represented by a memory 301, for storing instructions executable by the processing component 302, such as an application. The application stored in the memory 301 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 302 is configured to execute instructions to perform the method for monitoring the runtime delay of a software program in any of the above embodiments.
[0197] The computer device 300 may further include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate based on an operating system stored in the memory 301, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, Free BSD TM, or the like.
[0198] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0199] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0200] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can refer to each other.
[0201] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for monitoring software program runtime delay, characterized in that: The method comprises: Constructing a main analyzer in a code file of a software program whose runtime delay is to be monitored, wherein the main analyzer is a global static variable; the software program includes a main function and at least one sub-function; Using the main analyzer to create an analysis area for a code block in a designated area of the code file, the analysis area has a timing function, and the designated area is an area corresponding to the code block concerned by the user in the code file; Executing the software program, and during the running of the software program, obtaining the running delay of the code block in the designated area through the timing function of the analysis area; The step of using the main analyzer to create an analysis area for a code block in a specified area of the code file includes: Determine a code block in a specified area of the code file and a function corresponding to the code block; Using the main analyzer, based on the functions corresponding to the code blocks in the designated area in the code file and the calling relationship between the main function and at least one sub-function in the software program, an analysis area is created for the code blocks in the designated area in the code file; Obtaining a creation request for creating an analysis area for a code block in a specified area of the code file, wherein the creation request includes a function corresponding to the code block for which creation of the analysis area is requested; By polling the mapping relationship between the function corresponding to the pre-created code block and the zone name of the analysis zone corresponding to the code block without locking the HashMap, it is determined whether the function corresponding to the code block requesting to create the analysis zone has the zone name of the analysis zone corresponding to the code block; If it exists, the name of the analysis area corresponding to the code block will be used as the name of the analysis area to be created.
2. The method according to claim 1, characterized in that The timing function includes a start timing function and a stop timing function; The obtaining the runtime delay of the code block in the designated area through the timing function of the analysis area includes: When the software program runs to the code block in the designated area, the start running time of the code block is counted by the start timing function in the analysis area to obtain a first statistical result; And, the termination running time of the code block is counted through the termination timing function or the function exit time in the analysis area to obtain a second statistical result; The runtime delay of the code block in the designated area is determined according to the first statistical result and the second statistical result.
3. The method according to claim 1, characterized in that The method further comprises: By using the timing function of the analysis area, the acquired runtime delay of the code block in the designated area is stored according to a pre-configured timing storage mode; Wherein, the timing storage mode is configured according to the number of processes of the software program.
4. The method according to claim 3, characterized in that The analysis area also has an aggregation function, and the method further comprises: Through the aggregation function of the analysis area, the running delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period is discretely stored according to a preset discrete strategy.
5. The method according to claim 4, characterized in that When the preset discrete strategy is a linear strategy, the aggregation function of the analysis area is used to discretely store the running delay of the code block of the designated area stored in the analysis area each time the software program is executed according to the preset discrete strategy, including: Counting the running delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period to obtain a statistical result; Determine, according to the statistical results, a plurality of linear growth intervals for discretely storing each runtime delay in a linear growth manner; The runtime delay of the code block in the designated area stored in the analysis area when the software program is executed each time within a preset time period is divided according to each linear growth interval, and the divided runtime delay is discretely stored.
6. The method according to claim 4, characterized in that When the preset discrete strategy is an exponential strategy, the aggregation function of the analysis area is used to discretely store the running delay of the code block of the designated area stored in the analysis area each time the software program is executed according to the preset discrete strategy, including: Counting the running delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period to obtain a statistical result; Determine, according to the statistical results, a plurality of exponential growth intervals for discretely storing each runtime delay in an exponential growth manner; The runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period is divided according to each exponential growth interval, and the divided runtime delay is discretely stored.
7. The method according to claim 4, characterized in that When the preset discrete strategy is the interpolation-exponential strategy, the aggregation function of the analysis area is used to discretely store the running delay of the code block of the designated area stored in the analysis area each time the software program is executed according to the preset discrete strategy, including: Counting the running delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period to obtain a statistical result; Determine, according to the statistical results, a plurality of interpolation-exponential growth intervals for discretely storing each runtime delay in an interpolation-exponential growth manner; The runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period is divided according to each interpolation-exponential growth interval, and the divided runtime delay is discretely stored.
8. The method according to claim 4, characterized in that The method further comprises: The running delay of the code block in the designated area stored discretely each time the software program is executed is written into the target file according to the preset acquisition frequency.
9. A monitoring device for software program runtime delay, characterized in that: include: A main analyzer construction module, used to construct a main analyzer in a code file of a software program whose runtime delay is to be monitored, wherein the main analyzer is a global static variable; The software program includes a main function and at least one sub-function; An analysis area creation module, used to create an analysis area for a code block in a specified area of the code file using the main analyzer, wherein the analysis area has a timing function, and the specified area is an area corresponding to a code block concerned by a user in the code file; A runtime delay monitoring module, used for executing the software program and obtaining the runtime delay of the code block in the designated area through the timing function of the analysis area during the running of the software program; The analysis area creation module includes: A function determination module, used to determine a code block in a specified area of the code file and a function corresponding to the code block; a creation module, configured to create an analysis area for the code block in the specified area in the code file by using the main analyzer according to the function corresponding to the code block in the specified area in the code file and the calling relationship between the main function and at least one sub-function in the software program; A creation request acquisition module, used to acquire a creation request when creating an analysis area for a code block in a specified area in the code file, wherein the creation request includes a function corresponding to the code block requesting the creation of the analysis area; A polling module is used to poll the mapping relationship between the function corresponding to the pre-created code block and the zone name of the analysis zone corresponding to the code block without locking through HashMap, to determine whether the function corresponding to the code block requesting to create the analysis zone has the zone name of the analysis zone corresponding to the code block; The area name determination module is used to use the area name of the analysis area corresponding to the code block as the area name of the analysis area to be created if it exists.
10. The device according to claim 9, characterized in that The timing function includes a start timing function and a stop timing function; The runtime delay monitoring module includes: A first statistical module is used for, when the software program runs to the code block in the designated area, to count the start running time of the code block through the start timing function in the analysis area to obtain a first statistical result; A second statistical module is used to count the termination running time of the code block through the termination timing function in the analysis area or the function exit time to obtain a second statistical result; A timing module is used to determine the runtime delay of the code block in the designated area according to the first statistical result and the second statistical result.
11. The device according to claim 9, characterized in that The device also includes: A storage module, configured to store the acquired runtime delay of the code block of the designated area according to a pre-configured timing storage mode through the timing function of the analysis area; Wherein, the timing storage mode is configured according to the number of processes of the software program.
12. The device according to claim 11, characterized in that The analysis area also has a polymerization function, and the device also includes: The aggregation module is used to discretely store the runtime delay of the code block in the designated area stored in the analysis area each time the software program is executed within a preset time period according to a preset discrete strategy through the aggregation function of the analysis area.
13. The device according to claim 12, characterized in that The device also includes: The disk writing module is used to write the code blocks of the designated area in discrete storage into a target file according to a preset acquisition frequency during each execution of the software program.
14. A storage medium, characterized in that: include: The storage medium stores computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to execute the steps of the method for monitoring the runtime delay of a software program as claimed in any one of claims 1 to 9.
15. A computer device, characterized in that: include: one or more processors, and memory; The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the method for monitoring the runtime delay of a software program as claimed in any one of claims 1 to 9 are performed.
Citation Information
Patent Citations
Method and system for testing code running time
CN107480043A