WO2021104027A1 - Code performance testing method, apparatus and device, and storage medium - Google Patents

Code performance testing method, apparatus and device, and storage medium Download PDF

Info

Publication number
WO2021104027A1
WO2021104027A1 PCT/CN2020/128337 CN2020128337W WO2021104027A1 WO 2021104027 A1 WO2021104027 A1 WO 2021104027A1 CN 2020128337 W CN2020128337 W CN 2020128337W WO 2021104027 A1 WO2021104027 A1 WO 2021104027A1
Authority
WO
WIPO (PCT)
Prior art keywords
code
function
target
performance
sentence
Prior art date
Application number
PCT/CN2020/128337
Other languages
French (fr)
Chinese (zh)
Inventor
林全昌
卢道和
林挺
Original Assignee
深圳前海微众银行股份有限公司
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 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2021104027A1 publication Critical patent/WO2021104027A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/366Software debugging using diagnostics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3628Software debugging of optimised code

Definitions

  • This application relates to the technical field of financial technology (Fintech), in particular to code performance testing methods, devices, equipment, and computer-readable storage media.
  • the first implementation scheme is only suitable for large and complex project codes, and the performance statistics data of the functions in the detected code are obtained, so it can only reflect the performance pros and cons of the detected code at the function level; while the second implementation scheme Because it is designed for small code snippets, it cannot be applied to the performance testing of large or medium-sized program codes.
  • the second implementation scheme can only compare the performance of the code snippets tested, and users can only qualitatively pass the test results. Determine whether the performance of the multiple code fragments detected is good or bad. From the above two implementation schemes, it is impossible to know the specific reasons for the poor performance of the code fragments, which leads to the low accuracy of the existing code performance detection results. problem.
  • the main purpose of this application is to propose a code performance detection method, device, equipment, and computer-readable storage medium, which aims to solve the technical problem of low accuracy of existing code performance detection results.
  • the present application provides a code performance detection method, the code performance detection method includes:
  • Execute the target code and obtain the first performance data of the target function and the second performance data of the target sentence block respectively based on the execution statistics code and the line count statistics code in the performance statistics code;
  • a function to be optimized in the objective function and a sentence to be optimized in the function to be optimized are determined.
  • the present application also provides a code performance detection device, the code performance detection device including:
  • the function sentence determination module is used to obtain the source code to be tested and the preset performance statistics code when the performance test instruction is received, and to determine the target function in the source code to be tested and the target sentence block in the target function;
  • the performance code injection module is used to inject the performance statistics code into the target injection position in the source code to be tested based on the target function and target sentence block target location information in the source code to be tested, and the injected The source code to be tested is used as the target code;
  • the performance data acquisition module is configured to execute the target code, and obtain the first performance data of the target function and the first performance data of the target sentence block based on the execution statistics code and the line count statistics code in the performance statistics code.
  • the optimized sentence determination module is configured to determine the function to be optimized in the objective function and the sentence to be optimized in the function to be optimized according to the first performance data and the second performance data.
  • the present application also provides a code performance testing device, the code performance testing device includes: a memory, a processor, and code performance testing stored on the memory and running on the processor A program that implements the steps of the code performance detection method as described above when the code performance detection program is executed by the processor.
  • the present application also provides a computer-readable storage medium having a code performance detection program stored on the computer-readable storage medium, and when the code performance detection program is executed by a processor, the above-mentioned The steps of the code performance detection method.
  • This application enables users to obtain more accurate optimization targets than the entire function. Especially for inexperienced programmers, it is more difficult to analyze the determinants of target code performance through existing code performance test results.
  • This application can directly obtain the execution status of the target sentence block, and then quickly analyze the specific reasons leading to poor code performance, improve the accuracy of the code performance test results, and solve the problem of the existing code performance test results. Technical problems with low accuracy.
  • FIG. 1 is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the present application;
  • FIG. 2 is a schematic flowchart of the first embodiment of the code performance detection method of this application.
  • FIG. 1 is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the present application.
  • the code performance detection device of the embodiment of the present application may be a PC or a server device, on which a Java virtual machine runs.
  • the code performance detection device may include: a processor 1001, such as a CPU, a network interface 1004, a programmer interface 1003, a memory 1005, and a communication bus 1002.
  • the communication bus 1002 is used to implement connection and communication between these components.
  • the programmer interface 1003 may include a display screen (Display) and an input unit such as a keyboard (Keyboard), and the optional programmer interface 1003 may also include a standard wired interface and a wireless interface.
  • the network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
  • the memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a magnetic disk memory.
  • the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
  • FIG. 1 does not constitute a limitation on the device, and may include more or fewer components than those shown in the figure, or a combination of certain components, or different component arrangements.
  • the memory 1005 as a computer storage medium may include an operating system, a network communication module, a programmer interface module, and a code performance testing program.
  • the network interface 1004 is mainly used to connect to the back-end server and communicate with the back-end server; the programmer interface 1003 is mainly used to connect to the client (programmer's side) and communicate with the client; and
  • the processor 1001 may be used to call a code performance detection program stored in the memory 1005, and perform operations in the following code performance detection method.
  • FIG. 2 is a schematic flowchart of a first embodiment of a code performance detection method according to this application.
  • the code performance detection method includes:
  • Step S10 when receiving the performance testing instruction, obtain the source code to be tested and the preset performance statistical code, and determine the target function in the source code to be tested and the target sentence block in the target function;
  • the second implementation scheme can only compare the performance of the code snippets tested, and users can only qualitatively pass the test results. It is judged whether the performance of the multiple code fragments detected is good or bad, and there is no way to know the specific reasons for the poor performance of the code fragments, which leads to the problem of low accuracy of the existing code performance detection results.
  • the current source code to be tested is a medium-sized program code that contains a function that couples multiple functions. If you use v8-profiler to analyze the performance of this source code, it will take a long time to get this The execution statistics of the source code. Among the execution statistics, the CPU occupancy rate and other data are not helpful to the performance analysis of the small and medium-sized program codes.
  • the execution data of the functions in the program can only qualitatively determine the function.
  • the pros and cons of performance At this time, the programmer knows that the performance of this large function is poor according to the test results, which seriously affects the performance of the entire program, but more detailed information cannot be obtained from the test results to determine the specific cause of the poor performance, the programmer It takes a long time to analyze which key statements in this large function can be changed.
  • this application provides a code performance detection method, that is, this application obtains a preset performance statistical code that can detect the performance of the target sentence block, so that the object of the code performance detection is refined.
  • a code performance detection method that is, this application obtains a preset performance statistical code that can detect the performance of the target sentence block, so that the object of the code performance detection is refined.
  • Part of the sentences in the source code to be tested has broken through the limitation in the prior art that only functions in the code to be tested can be used as the smallest refinement object; by injecting the preset performance statistics code into the source code to be tested, the The performance of the target sentence block can be tested through the preset performance statistics code; according to the first and second performance statistics obtained, the user can understand the execution of the function in the target code, and perform the target code according to this execution.
  • the code performance detection method is applied to a terminal equipped with Node.js (a JavaScript runtime environment based on the Chrome V8 engine).
  • the performance testing instruction can be initiated by the programmer importing the source code to be tested and the preset performance statistics code, or it can be initiated automatically by the terminal according to the preset instruction.
  • the preset performance statistics code includes line count statistics code, execution statistics code, and related regular expressions, which are used to match the target sentence block and target function in the source code to be tested and detect their performance. They are pre-written and commonly used for most The performance statistics code of the code; for a small part of the more complex source code, the preset performance statistics code can be optimized before use.
  • the target sentence block includes but is not limited to key sentences such as loop sentences, selection sentences, judgment sentences, and return sentences.
  • the target function is all the functions that need to be executed in the source code to be tested.
  • the user initiates a code performance test instruction to a computer equipped with Node.js by importing a current medium-sized program code as the source code to be tested, and a general performance statistics code.
  • the computer receives the code performance test instruction, and obtains the source code to be tested and the preset performance statistics code in the performance test instruction.
  • the computer obtains the regular expression from the preset performance statistics code, and matches the source code to be tested line by line through the regular expression, thereby determining the target function in the source code to be tested and the key sentence in the target function.
  • Step S20 based on the target position information of the target function and the target sentence block in the source code to be tested, inject the performance statistics code into the target injection location in the source code to be tested, and use the injected source code to be tested as Target code
  • the target location information includes the first location information of the target function in the source code to be detected and the second location information of the target sentence block in the source code to be detected.
  • the target injection location includes a first injection location corresponding to the execution statistics code in the source code to be detected and a second injection location corresponding to the line count statistics code in the source code to be detected.
  • the terminal equipped with Node.js injects the above-mentioned performance statistics code into the corresponding position of the source code to be checked.
  • the performance statistics code includes row count statistics code and execution statistics code.
  • the line count statistics code injects a global object count in the execution context, uses the statement type type + source line number line + source code column number column as the key of the object, and the number of executions is used as the value to record the number of executions of the statement.
  • the statement types include key statements such as if, else if, else, for, while, and return.
  • the key-value pair is initialized to 1 when the first count is performed, and then it continues to overlap.
  • the execution statistics code obtains the start time and end time of the system time before and after the function is executed by injecting performance.now() statements before and after the function.
  • the execution time of the corresponding function can be obtained by subtracting two values, and each time the execution time of a function is obtained, it means that it is executed once. Then you can get the function execution time and execution times. After obtaining the execution time and execution times, record the function execution times and execution time through the global variable profile.
  • the computer encapsulates the line count statistics code into the lineCounter function, and receives three parameters type (statement type), line (source line number), column (source code column number), this function returns undefined (undefined) parameters; it will also execute
  • the statistical code is encapsulated into the functionProfiler function, which receives two parameters: functionName (function name) and time (function execution time). It should be noted that in order to prevent naming conflicts, JavaScript built-in functions will add the corresponding object name. For example, Math.sqrt will be converted to Math_sqrt, and _selfExecution will be used instead for anonymous functions.
  • the computer injects the line count statistics code into the corresponding positions of key sentences such as loop statements, judgment statements, and return statements in the source code to be tested, and injects the execution statistics code into the corresponding locations before and after the function is executed in the source code to be tested.
  • the way of injecting the preset performance statistics code may also be to analyze the source code to be detected as an abstract syntax tree, and then inject the corresponding target sentence block into the preset performance statistics code, and finally generate the target code; or One function sinks to the JavaScript parsing engine, and the JavaScript parsing engine outputs the corresponding row count result.
  • the parsing process of the abstract syntax tree requires manpower and material resources, and the cost is high, and the JavaScript parsing engine needs to embed the target code into the engine and analyze the code online, which may affect the performance of the code.
  • Step S30 execute the target code, and obtain the first performance data of the target function and the second performance data of the target sentence block respectively based on the execution statistics code and the line count statistics code in the performance statistics code;
  • the execution statistics code is used to count the first performance data of the target function in the source code to be tested, and the row count statistics code is used to count the second performance data of the target sentence block in the target function.
  • the first performance data may be the execution times and execution time of the target sentence block.
  • the second performance data includes, but is not limited to, the number of executions of the objective function, the total execution time, and the average execution time.
  • the terminal executes the target code based on the operating environment of Node.js, and obtains performance statistics in the execution result.
  • the computer reads the data of the global object count in the target code, and parses out the number of executions, the number of rows, and the number of columns of the target sentence block, that is, the value and the line and column in the key, and Write the number of executions in front of the line corresponding to the target code. Then read the data of the global object profile in the target code, analyze the total execution time and execution times of the corresponding function, and obtain the average execution time corresponding to the function through the total execution time and execution times.
  • this application only performs performance testing on the entire function and the target statement block, that is, the key statement, and does not perform performance testing on all statements in the function.
  • Step S40 Determine the function to be optimized in the objective function and the sentence to be optimized in the function to be optimized according to the first performance data and the second performance data.
  • the function to be optimized and the sentence to be optimized can be determined by the terminal after analyzing the first performance data and the second performance data, or can be determined by the user after the first performance data and the second performance data are displayed to the user. to make sure.
  • the computer analyzes the first performance data, determines the function corresponding to the data that meets the preset conditions as the function to be optimized, obtains the data corresponding to the function to be optimized in the second performance data, and performs the data corresponding to the function to be optimized Analyze and determine the sentence corresponding to the data in the target sentence block that exceeds the preset threshold as the sentence to be optimized.
  • This application obtains preset performance statistics codes that can locate specific sentences in the code, and then detect the performance of the target sentence block, so that the object of code performance testing is refined to some sentences in the source code to be tested, which breaks through the prior art. Only the functions in the code to be tested can be used as the limit of the minimum refinement object; by injecting the preset performance statistics code into the source code to be tested, the performance of the target sentence block in the source code to be tested can be tested by the preset performance statistics code ;According to the acquisition of the first and second performance statistics, the user can understand the internal execution of the function in the target code, and perform a more detailed performance analysis of the target code based on this execution than the existing scheme; by determining The statement to be optimized in the function to be optimized enables users to obtain more accurate optimization goals than the entire function, especially for programmers with inexperience, through the existing code performance test results on the performance of the target code It is difficult to analyze the determinants, and through this application, the execution status of the target sentence block can be directly obtained, and then the specific
  • step S10 specifically includes:
  • Step a Obtain a first regular expression related to the target function and a second regular expression corresponding to the target sentence block from the performance statistics code, and combine the first regular expression with the second regular expression The regular expression matches the source code to be detected line by line;
  • the programmer analyzes the semantic environment of the target sentence block, writes the first regular expression corresponding to the function execution code in the source code to be tested, and the second regular expression corresponding to the key sentence, and Enter the above regular expression into the terminal.
  • the terminal obtains the foregoing first and second regular expressions, and in the process of executing the target code, matches each line of code line by line through the foregoing first and second regular expressions.
  • take the selection statement if as an example.
  • the if statement has two manifestations in the code, one is if() ⁇ and the other is if () ⁇ .
  • the programmer writes the corresponding if statement
  • Step b When there is a first part of code matching the first regular expression in the source code to be detected, determine that the first part of code is the execution sentence of the target function, and determine the execution sentence according to the execution sentence.
  • the objective function
  • the terminal can determine that the first part of code is the execution statement of the function in the source code to be detected .
  • the matching result shows that there are six codes matching the first regular expression in the source code to be tested, it is determined that these six codes are all execution statements of the function, that is, there are six codes in the source code to be tested.
  • the function to be executed if the matching process ends and the result shows that there is a first part of code matching the first regular expression in the source code to be detected, the terminal can determine that the first part of code is the execution statement of the function in the source code to be detected . Specifically, if the matching result shows that there are six codes matching the first regular expression in the source code to be tested, it is determined that these six codes are all execution statements of the function, that is, there are six codes in the source code to be tested. The function to be executed.
  • Step c When there is a second part of code matching the second regular expression in the source code to be detected, it is determined that the second part of code is the target sentence block.
  • the terminal can determine that the second part of code is the target sentence block to be found.
  • the computer uses /$ ⁇ s+if ⁇ s+? ⁇ (*. ⁇ )/ to match the source code to be tested line by line, and the matching result shows that there are five codes that match this regular expression in the source code to be tested, then It can be determined that these five codes are the codes of the judgment statement if.
  • step c it further includes:
  • Step d Obtain the first position information of the execution sentence and the second position information of the target sentence block, and use the first position information and the second position information as the target position information;
  • the terminal obtains the first position information corresponding to the target sentence block in the source code to be detected, where the first position information is usually the number of rows and columns of the function execution sentence. And obtain the second position information of the target sentence block in the source code to be detected, the second position information is usually the number of rows and columns of the target sentence block.
  • Step e Based on the target position information, determine a first injection position and a second injection position respectively corresponding to the execution statistics code and the row count statistics code, and use the first injection position and the second injection position as the target Injection position
  • the first injection position has different positions in different types of key statements
  • the second injection position is the position before and after the execution statement of the function.
  • the terminal determines the first injection position of the line count statistical code in the source code to be detected and the second injection position of the execution statistical code according to the above-mentioned first position information and the second position information.
  • the position before and after the function execution code is the above-mentioned first injection position.
  • the computer obtains the number of rows and columns of a judgment statement if(), and according to this number of rows and columns, replaces the first "in the if() statement with the lineCounter function (", this position is the second injection position, and the injected code is written into the js_profile_code.js file.
  • the judgment statement else if, loop statement for, and while all have "()"
  • the injection method is consistent with the injection method of the above if statement.
  • the computer directly inserts the lineCounter function before the return statement determined by the match to complete the injection.
  • Step f Inject the performance statistics code into the target injection location, and use the injected source code to be detected as the target code.
  • the terminal injects the execution statistics code into the determined first injection position, and injects the row count statistics code into the determined second injection position. After the injection operation is completed, the terminal uses the source code to be tested that has been injected with the execution statistics code and the line count statistics code as the target code to be run.
  • step d it also includes:
  • Step g judging whether there is a specific sentence in the target sentence block
  • the terminal determines whether there is a specific sentence in each code determined as the target sentence block through detection and matching.
  • the specific sentence is the sentence included in the " ⁇ " of the else sentence in the key sentence.
  • Step h if the specific sentence exists in the target sentence block, use the position where the specific sentence is located as the first injection position, and inject the line count statistics code into the first injection position;
  • the line count statistics code is injected into the first injection position where the specific sentence is located. Specifically, if it is determined that there is a sentence included in " ⁇ " in this else sentence, the computer injects the lineCounter function into this sentence, and this position is the aforementioned first injection position.
  • Step i if the specific sentence does not exist in the target sentence block, add the specific sentence to the target sentence block, and repeat the steps: use the position of the specific sentence as the first injection Position, and inject the row count statistics code into the first injection position.
  • the terminal determines that there is no specific sentence in the current target sentence block, the specific sentence is added to the target sentence block, and the line count statistics code is injected into the first injection position where the specific sentence is located. Specifically, if it is determined that the sentence included in " ⁇ " does not exist in this else sentence, the computer adds this particular sentence to this else sentence, and then injects the line count statistics code into the first sentence where this particular sentence is located. Injection position.
  • the present application provides a code performance detection method, which further matches the execution sentence and target sentence block of the function in the source code to be tested through regular expressions, thereby improving the efficiency and accuracy of identifying functions and target sentence blocks in the code ; Inject the line count statistics code and execution statistics code into the corresponding positions of the source code to be tested, so that the line count statistics code and execution statistics code can run normally, and the performance data of the target statement block and function are counted, and more detailed code is realized Performance testing: By identifying specific statements, it is possible to accurately determine the injection position of the line count statistics code in the else statement, which improves the accuracy of code injection.
  • step S40 specifically includes:
  • Step j Obtain the number of function execution times and the function execution time in the first performance data, and determine whether the number of function execution times and the function execution time exceed a preset first threshold and a preset second threshold, respectively;
  • the function execution time includes the total function execution time and the average function execution time.
  • the preset first threshold value is a value that defines the number of times the function is executed
  • the preset second threshold value is a time value that defines the function's execution time.
  • the preset second threshold can be set to a preset average execution time.
  • the threshold and the preset total execution time threshold are two different values. The above three thresholds can be flexibly set according to specific conditions, which are not specifically limited in this embodiment.
  • the terminal injects the execution statistics code into the corresponding position in the source code to be detected, by running the target code, it obtains the execution times and the total execution time of all the functions executed in the source code to be detected, and calculates each function The average execution time.
  • the data is compared with the preset first threshold, the preset average execution time threshold, and the preset total execution time threshold.
  • the computer obtains and displays the second performance data as follows: the number of executions of the main function is 1, the total execution time is 18.17299ms, and the average execution time is 18.17299ms; the number of executions of the prime function is 999, and the total execution time is 14.78644ms.
  • the average execution time is 0.01480ms; the number of executions of the Math_sqrt function is 999, the total execution time is 0.41335ms, and the average execution time is 0.00041ms.
  • the preset average execution time threshold value of 1 ms, the preset first threshold value of 500, and the preset total execution time threshold value of 10 ms it is determined whether the above data exceeds the threshold value.
  • Step k if the number of executions of the function exceeds the first threshold and the execution time of the function exceeds the second threshold, it is determined that the function corresponding to the data exceeding the first threshold and the second threshold is the function to be optimized ;
  • the main function is a function to be optimized
  • the number of executions of the function in the prime function and the total time of the function exceed the threshold, and the average execution time does not exceed the threshold, the prime function is determined to be a function to be optimized; in the Math_sqrt function, only the number of executions of the function exceeds the threshold, and the execution time of the function is the average of the function If the execution time does not exceed the threshold, it is determined that the Math_sqrt function does not need to be optimized.
  • Step 1 Obtain the execution times of the target sentence block corresponding to the function to be optimized in the second performance data, and determine whether the execution times of the target sentence block exceeds a preset third threshold;
  • the preset third threshold is a value for determining the number of executions of the sentence to be optimized, and is flexibly set according to specific conditions.
  • the terminal obtains the execution times of the key sentence corresponding to each function to be optimized according to the function to be optimized determined in the objective function.
  • the terminal compares the preset third threshold with the number of executions of the key sentence. Specifically, following the above-mentioned embodiment, it is assumed that the current computer obtains that in the main function, the if statement is executed 300 times, the for statement is executed 50 times, and the return statement is executed 50 times; in the prime function, the for statement is executed 200 times. The return statement was executed 30 times; in the Math_sqrt function, the if statement was executed 20 times, and the return statement was executed 30 times.
  • the preset third threshold is set to 100, and the computer determines whether the above data exceeds the preset third threshold.
  • Step m If the number of executions of the target sentence block exceeds the third threshold, it is determined that the sentence corresponding to the data exceeding the third threshold is a sentence to be optimized.
  • the terminal determines the sentence corresponding to the data that exceeds the preset third threshold among the execution times of the target sentence block as a sentence to be optimized. Specifically, using the data of the above specific embodiment, it can be determined that the number of executions of the if statement 300 in the main function exceeds the preset third threshold 100, so it is determined that the if statement in the main function is the key statement to be optimized; in the prime function The number of executions of the for statement 200 exceeds the preset third threshold of 100, so it is determined that the for statement in the prime function is a key statement to be optimized.
  • step S10 specifically includes:
  • Step n When receiving the performance test instruction, obtain the original code in the performance test instruction, and determine whether there is a function to be executed in the original code;
  • the user initiates a performance test instruction by importing an original code.
  • the terminal receives the performance test instruction, obtains the original code in the performance test instruction, and uses the function to recognize characters or sentences to determine whether the original code is in the original code. Whether there is a function to be executed. It should be noted that most program codes have functions to be executed, and only some small code fragments may consist of only a few statements, and there are no functions to be executed.
  • Step o If the function to be executed exists in the original code, determine that the original code is the source code to be tested, and obtain the performance statistics code;
  • the terminal determines that there is a function to be executed in the original code after identification, it will use this original code as the source code to be tested, and use the solution in this application to perform performance testing on this original code. If there is no function to be executed in the original code, it can be explained that the original code is a small code fragment composed of several statements.
  • Step p Determine the target function and target sentence block according to the performance statistics code.
  • the terminal obtains the first regular expression and the second regular expression from the preset performance statistics code, and matches the source code to be tested with the first and second regular expressions line by line, and determines the source code to be tested The objective function and objective sentence block.
  • step S40 the method further includes:
  • Step q generating a performance reference value of each objective function according to the preset weight, the number of executions of the function of the objective function, and the execution time of the function, wherein the number of executions of the function and the execution time of the function are the second performance data;
  • the preset weight includes a first weight corresponding to the number of executions of the function and a second weight corresponding to the total execution time of the function.
  • the first weight and the second weight can be flexibly set according to specific conditions.
  • the terminal sorts the product of the first weight and the execution times of each function in descending order, obtains the first sequence number of each objective function, uses the first sequence number as the numerator, and sets the objective function As the denominator, the first weight score corresponding to each objective function is obtained.
  • the terminal sorts the product of the second weight and the total execution time of each function in descending order, obtains the second sequence number of each objective function, uses the second sequence number as the numerator, and the number of the objective function as the numerator, and obtains The second weight score corresponding to each objective function.
  • the terminal uses the sum of the first weight score and the second weight score as the performance reference value of each objective function.
  • Step r displaying the name of the target function and the corresponding function execution times and function execution time according to the performance reference value from high to low;
  • the terminal displays the function name of the function to be optimized and the corresponding total execution time of all current execution functions in order from high to low according to the performance pros and cons weight of each objective function generated after the determination. Number of executions and average execution time.
  • the user analyzes the performance of the objective function through the above display results, and determines the function to be optimized in the objective function.
  • step s the target sentence block names and the corresponding target sentence block execution times are sequentially displayed in descending order of the target sentence block execution times, and the target sentence block execution times are the first performance data.
  • the terminal sorts the target sentence blocks corresponding to each function according to the numerical value, and preferentially displays the target sentence blocks with the most execution times in each function and the execution times of each target sentence block.
  • the user analyzes each target sentence block and determines the sentence to be optimized in the target sentence block. Specifically, if the number of executions of the if statement in the main function is 300, the number of executions of the else statement is 250, the number of executions of the for statement is 200, and the number of executions of the return statement is 400, then the terminal follows the return statement, main The order of statement, if statement, else statement, and for statement is displayed. The user can analyze the performance of the target sentence based on the data displayed above.
  • code performance detection method further includes:
  • Step t obtaining the tool function in the target code and the performance statistical function in the performance statistical code, and use the tool function and the performance statistical function as the statistical tool function;
  • the tool function is a method of processing the statistical data
  • the performance statistics function is the row count function and the execution statistics function.
  • the terminal separately obtains the tool function in the target code, and the row count function and execution statistics function in the performance statistics code, and uses the above tool function, row count function, and execution statistics function as the statistics tool function.
  • Step u Write the statistical tool function into a designated file to perform performance data statistics on the next code to be tested based on the statistical tool function in the designated file.
  • the terminal writes the above-mentioned statistical tool function into a file named js_profile_code.js, so that when the function and target sentence block in the code are tested again in the future, the above-mentioned function can be called directly from the file js_profile_code.js.
  • Statistical tool function
  • the present application provides a code performance detection method.
  • the code performance detection method further directly obtains the execution times of the target sentence block in the function to be optimized, and accurately locates several sentences that reduce the performance of the function to be optimized, so that the code performance is improved.
  • Analysis efficiency saves code performance analysis time; by judging whether the original code is a code with functions to be executed, an optimal scope of application is determined; by giving priority to displaying low-performance functions and target sentence blocks, programmers can Obtain more intuitively the information about the relevant code that takes the longest time and the most execution times, so as to quickly locate the specific function that causes the poor performance of the code, and then locate the target statement block in the function to be optimized, and further improve the code Performance optimization efficiency, while improving user experience; by summarizing statistical tool functions and writing them into specific files, it can be directly called from specific files when relevant functions are needed later, which improves the efficiency of computer performance testing of code.
  • This application also provides a code performance detection device, including:
  • the function sentence determination module is used to obtain the source code to be tested and the preset performance statistics code when the performance test instruction is received, and to determine the target function in the source code to be tested and the target sentence block in the target function;
  • the performance code injection module is used to inject the performance statistics code into the target injection position in the source code to be tested based on the target function and target sentence block target location information in the source code to be tested, and the injected The source code to be tested is used as the target code;
  • the performance data acquisition module is configured to execute the target code, and obtain the first performance data of the target function and the first performance data of the target sentence block based on the execution statistics code and the line count statistics code in the performance statistics code.
  • the optimized sentence determination module is configured to determine the function to be optimized in the objective function and the sentence to be optimized in the function to be optimized according to the first performance data and the second performance data.
  • the code performance detection device further includes:
  • the regular acquisition and matching module is used to acquire a first regular expression related to the target function and a second regular expression corresponding to the target sentence block from the performance statistics code, and express the first regular expression
  • the formula matches the source code to be detected line by line with the second regular expression
  • the first regular matching module is used to determine that the first part of the code is the execution sentence of the target function when there is a first part of the code matching the first regular expression in the source code to be detected, and according to the The execution sentence determines the objective function;
  • the second regular matching module is configured to determine that the second part of the code is the target sentence block when there is a second part of the code that matches the second regular expression in the source code to be detected.
  • the performance code injection module specifically includes:
  • a location information acquiring unit configured to acquire first location information of the execution sentence and second location information of the target sentence block, and use the first location information and the second location information as the target location information;
  • the injection position determining unit is configured to determine, based on the target position information, a first injection position and a second injection position corresponding to the execution statistics code and the line count statistics code, respectively, and compare the first injection position and the second injection position As the target injection position;
  • the performance code injection unit is configured to inject the performance statistics code into the target injection location, and use the injected source code to be detected as the target code.
  • the code performance detection device further includes:
  • the specific sentence judgment module is used to judge whether there is a specific sentence in the target sentence block
  • the direct code injection module is configured to, if the specific sentence exists in the target sentence block, use the position of the specific sentence as the second injection position, and inject the line count statistics code into the second Injection position
  • the code indirect injection module is used to add the specific sentence to the target sentence block if the specific sentence does not exist in the target sentence block, and repeat the steps: take the location of the specific sentence as the target sentence block.
  • the second injection position, and the row count statistical code is injected into the second injection position.
  • the performance data acquisition module specifically includes:
  • the function data judgment unit is configured to obtain the number of function execution times and the function execution time in the first performance data, and determine whether the number of function execution times and the function execution time exceed a preset first threshold and a preset second threshold, respectively;
  • An optimized function determining unit configured to determine the function corresponding to the data exceeding the first threshold and the second threshold if the number of executions of the function exceeds the first threshold and the execution time of the function exceeds the second threshold Is the function to be optimized;
  • a sentence data judgment unit configured to obtain the execution times of the target sentence block corresponding to the function to be optimized in the second performance data, and judge whether the execution times of the target sentence block exceeds a preset third threshold
  • the optimized sentence determining unit is configured to determine that the sentence corresponding to the data exceeding the third threshold is a sentence to be optimized if the number of executions of the target sentence block exceeds the third threshold.
  • This application also provides a code performance testing device.
  • the code performance testing device includes a processor, a memory, and a code performance testing program that is stored on the memory and can run on the processor, where the code performance testing program is executed by the processor to achieve the above The steps of the code performance detection method.
  • the application also provides a computer-readable storage medium.
  • the computer-readable storage medium of the present application stores a code performance detection program, and when the code performance detection program is executed by a processor, the steps of the code performance detection method described above are implemented.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

A code performance testing method, apparatus and device, and a storage medium. The method comprises: when a performance testing instruction is received, acquiring a source code to be tested and a preset performance statistical code, and determining target functions in the source code to be tested and target statement blocks in the target functions (S10); on the basis of target position information of the target functions and target statement blocks in the source code to be tested, injecting the performance statistical code into a target injection position in the source code to be tested, and taking the source code to be tested, which is subjected to the injection, as a target code (S20); executing the target code, and on the basis of an execution statistical code and line counting statistical code in the performance statistical code, respectively acquiring first performance data of the target functions and second performance data of the target statement blocks (S30); and according to the first performance data and the second performance data, determining a function to be optimized in the target functions, and a sentence to be optimized in the function to be optimized (S40).

Description

代码性能检测方法、装置、设备及存储介质Code performance detection method, device, equipment and storage medium
本申请要求于2019年11月28日申请的、申请号为201911190460.4、名称为“代码性能检测方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on November 28, 2019, the application number is 201911190460.4, and the title is "Code performance detection method, device, equipment and storage medium", the entire content of which is incorporated into this application by reference in.
技术领域Technical field
本申请涉及金融科技(Fintech)技术领域,尤其涉及代码性能检测方法、装置、设备及计算机可读存储介质。This application relates to the technical field of financial technology (Fintech), in particular to code performance testing methods, devices, equipment, and computer-readable storage media.
背景技术Background technique
随着计算机技术的发展,越来越多的技术应用在金融领域,传统金融业正在逐步向金融科技(Fintech)转变,但由于金融行业的安全性、实时性要求,也对技术提出了更高的要求。对于银行的前端系统,前端开发通常运用JavaScript进行代码编写,为提高代码运行效率,就需要对运用JavaScript编写的代码进行性能检测,并通过检测结果对代码的性能优劣进行分析,进而对性能不佳的代码进行优化。由于JavaScript是解析型语言,要想收集运行时的信息来进行动态程序分析,现有技术中有两种实现方案:一种是通过JavaScript引擎内部提供的收集运行数据的接口,实现一段时间内JavaScript代码运行数据的导出;另一种对编译后的源码注入运行数据收集代码来收集运行数据。但第一种实现方案仅适用于大型的复杂项目代码,且得到的是所检测代码中函数的性能统计数据,故仅能体现出所检测代码的函数层面的性能优劣;而第二种实现方案因专为小型代码片段而设计,故无法运用于大型或中型程序代码的性能检测,且运用第二种实现方案仅能比较所检测代码片段的性能优劣,用户通过检测结果也仅能定性地判断出所检测的多个代码片段的性能优劣与否,从上述两种实现方案中均无从得知造成代码片段性能不佳的具体原因,从而导致了现有代码性能检测结果的精确度低的问题。With the development of computer technology, more and more technologies are applied in the financial field. The traditional financial industry is gradually transforming to Fintech. However, due to the security and real-time requirements of the financial industry, higher technology is also proposed. Requirements. For the bank’s front-end system, the front-end development usually uses JavaScript to write code. In order to improve the efficiency of code operation, it is necessary to perform performance testing on the code written with JavaScript, and analyze the performance of the code through the test results, and then analyze the performance. The best code is optimized. Since JavaScript is an analytical language, if you want to collect runtime information for dynamic program analysis, there are two implementation schemes in the prior art: one is to use the interface for collecting running data provided by the JavaScript engine to implement JavaScript within a period of time. Export of code running data; the other is to inject running data collection code into compiled source code to collect running data. However, the first implementation scheme is only suitable for large and complex project codes, and the performance statistics data of the functions in the detected code are obtained, so it can only reflect the performance pros and cons of the detected code at the function level; while the second implementation scheme Because it is designed for small code snippets, it cannot be applied to the performance testing of large or medium-sized program codes. The second implementation scheme can only compare the performance of the code snippets tested, and users can only qualitatively pass the test results. Determine whether the performance of the multiple code fragments detected is good or bad. From the above two implementation schemes, it is impossible to know the specific reasons for the poor performance of the code fragments, which leads to the low accuracy of the existing code performance detection results. problem.
技术解决方案Technical solutions
本申请的主要目的在于提出一种代码性能检测方法、装置、设备及计算机可读存储介质,旨在解决了现有代码性能检测结果的精确度低的技术问题。The main purpose of this application is to propose a code performance detection method, device, equipment, and computer-readable storage medium, which aims to solve the technical problem of low accuracy of existing code performance detection results.
为实现上述目的,本申请提供一种代码性能检测方法,所述代码性能检测方法包括:To achieve the above objective, the present application provides a code performance detection method, the code performance detection method includes:
在接收到性能检测指令时,获取待检测源码与预设性能统计代码,并确定所述待检测源码中的目标函数以及所述目标函数中的目标语句块;When receiving the performance detection instruction, obtain the source code to be tested and the preset performance statistics code, and determine the target function in the source code to be tested and the target sentence block in the target function;
基于所述目标函数与目标语句块在所述待检测源码中的目标位置信息,将所述性能统计代码注入所述待检测源码中的目标注入位置,将已注入的待检测源码作为目标代码;Based on the target function and target location information of the target sentence block in the source code to be tested, inject the performance statistics code into the target injection location in the source code to be tested, and use the injected source code to be tested as the target code;
执行所述目标代码,并基于所述性能统计代码中的执行统计代码与行计数统计代码,分别获取所述目标函数的第一性能数据与所述目标语句块的第二性能数据;Execute the target code, and obtain the first performance data of the target function and the second performance data of the target sentence block respectively based on the execution statistics code and the line count statistics code in the performance statistics code;
根据所述第一性能数据与第二性能数据,确定所述目标函数中的待优化函数以及所述待优化函数中的待优化语句。According to the first performance data and the second performance data, a function to be optimized in the objective function and a sentence to be optimized in the function to be optimized are determined.
此外,为实现上述目的,本申请还提供一种代码性能检测装置,所述代码性能检测装置包括:In addition, in order to achieve the above objective, the present application also provides a code performance detection device, the code performance detection device including:
函数语句确定模块,用于在接收到性能检测指令时,获取待检测源码与预设性能统计代码,并确定所述待检测源码中的目标函数以及所述目标函数中的目标语句块;The function sentence determination module is used to obtain the source code to be tested and the preset performance statistics code when the performance test instruction is received, and to determine the target function in the source code to be tested and the target sentence block in the target function;
性能代码注入模块,用于基于所述目标函数与目标语句块在所述待检测源码中的目标位置信息,将所述性能统计代码注入所述待检测源码中的目标注入位置,将已注入的待检测源码作为目标代码;The performance code injection module is used to inject the performance statistics code into the target injection position in the source code to be tested based on the target function and target sentence block target location information in the source code to be tested, and the injected The source code to be tested is used as the target code;
性能数据获取模块,用于执行所述目标代码,并基于所述性能统计代码中的执行统计代码与行计数统计代码,分别获取所述目标函数的第一性能数据与所述目标语句块的第二性能数据;The performance data acquisition module is configured to execute the target code, and obtain the first performance data of the target function and the first performance data of the target sentence block based on the execution statistics code and the line count statistics code in the performance statistics code. 2. Performance data;
优化语句确定模块,用于根据所述第一性能数据与第二性能数据,确定所述目标函数中的待优化函数以及所述待优化函数中的待优化语句。The optimized sentence determination module is configured to determine the function to be optimized in the objective function and the sentence to be optimized in the function to be optimized according to the first performance data and the second performance data.
此外,为实现上述目的,本申请还提供一种代码性能检测设备,所述代码性能检测设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的代码性能检测程序,所述代码性能检测程序被所述处理器执行时实现如上所述的代码性能检测方法的步骤。In addition, in order to achieve the above objective, the present application also provides a code performance testing device, the code performance testing device includes: a memory, a processor, and code performance testing stored on the memory and running on the processor A program that implements the steps of the code performance detection method as described above when the code performance detection program is executed by the processor.
此外,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有代码性能检测程序,所述代码性能检测程序被处理器执行时实现如上所述的代码性能检测方法的步骤。In addition, in order to achieve the above-mentioned object, the present application also provides a computer-readable storage medium having a code performance detection program stored on the computer-readable storage medium, and when the code performance detection program is executed by a processor, the above-mentioned The steps of the code performance detection method.
本申请使得用户能够得到比起整个函数更为精确的优化目标,尤其是对于经验不足的程序员而言,通过现有的代码性能检测结果对目标代码性能优劣的决定因素进行分析的难度较大,而通过本申请能够直接获取到目标语句块的执行情况,进而快速分析出导致代码性能不佳的具体原因,提高了代码性能检测结果的精确度,从而解决了现有代码性能检测结果的精确度低的技术问题。This application enables users to obtain more accurate optimization targets than the entire function. Especially for inexperienced programmers, it is more difficult to analyze the determinants of target code performance through existing code performance test results. This application can directly obtain the execution status of the target sentence block, and then quickly analyze the specific reasons leading to poor code performance, improve the accuracy of the code performance test results, and solve the problem of the existing code performance test results. Technical problems with low accuracy.
附图说明Description of the drawings
图1是本申请实施例方案涉及的硬件运行环境的设备结构示意图;FIG. 1 is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the present application;
图2为本申请代码性能检测方法第一实施例的流程示意图。FIG. 2 is a schematic flowchart of the first embodiment of the code performance detection method of this application.
本发明的实施方式Embodiments of the present invention
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。It should be understood that the specific embodiments described here are only used to explain the present application, and are not used to limit the present application.
如图1所示,图1是本申请实施例方案涉及的硬件运行环境的设备结构示意图。As shown in FIG. 1, FIG. 1 is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the present application.
本申请实施例代码性能检测装置可以是PC机或服务器设备,其上运行有Java虚拟机。The code performance detection device of the embodiment of the present application may be a PC or a server device, on which a Java virtual machine runs.
如图1所示,该代码性能检测装置可以包括:处理器1001,例如CPU,网络接口1004,程序员接口1003,存储器1005,通信总线1002。其中,通信总线1002用于实现这些组件之间的连接通信。程序员接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选程序员接口1003还可以包括标准的有线接口、无线接口。网络接口1004可选的可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。As shown in FIG. 1, the code performance detection device may include: a processor 1001, such as a CPU, a network interface 1004, a programmer interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to implement connection and communication between these components. The programmer interface 1003 may include a display screen (Display) and an input unit such as a keyboard (Keyboard), and the optional programmer interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a magnetic disk memory. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
本领域技术人员可以理解,图1中示出的设备结构并不构成对设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Those skilled in the art can understand that the structure of the device shown in FIG. 1 does not constitute a limitation on the device, and may include more or fewer components than those shown in the figure, or a combination of certain components, or different component arrangements.
如图1所示,作为一种计算机存储介质的存储器1005中可以包括操作系统、网络通信模块、程序员接口模块以及代码性能检测程序。As shown in FIG. 1, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a programmer interface module, and a code performance testing program.
在图1所示的设备中,网络接口1004主要用于连接后台服务器,与后台服务器进行数据通信;程序员接口1003主要用于连接客户端(程序员端),与客户端进行数据通信;而处理器1001可以用于调用存储器1005中存储的代码性能检测程序,并执行下述代码性能检测方法中的操作。In the device shown in Figure 1, the network interface 1004 is mainly used to connect to the back-end server and communicate with the back-end server; the programmer interface 1003 is mainly used to connect to the client (programmer's side) and communicate with the client; and The processor 1001 may be used to call a code performance detection program stored in the memory 1005, and perform operations in the following code performance detection method.
基于上述硬件结构,提出本申请代码性能检测方法实施例。Based on the above hardware structure, an embodiment of the code performance detection method of the present application is proposed.
参照图2,图2为本申请代码性能检测方法第一实施例的流程示意图,所述代码性能检测方法包括:Referring to FIG. 2, FIG. 2 is a schematic flowchart of a first embodiment of a code performance detection method according to this application. The code performance detection method includes:
步骤S10,在接收到性能检测指令时,获取待检测源码与预设性能统计代码,并确定所述待检测源码中的目标函数以及所述目标函数中的目标语句块;Step S10, when receiving the performance testing instruction, obtain the source code to be tested and the preset performance statistical code, and determine the target function in the source code to be tested and the target sentence block in the target function;
目前,对于JavaScript编写的代码,要想收集运行时信息来进行动态程序分析,现有技术中有两种实现方案:一种是通过JavaScript引擎内部提供的收集运行数据的接口,实现一段时间内JavaScript代码运行数据的导出;另一种对编译后的源码注入运行数据收集代码来收集运行数据。但第一种实现方案仅适用于大型的复杂项目代码,且得到的是所检测代码中函数的性能统计数据,故仅能体现出所检测代码的函数层面的性能优劣;而第二种实现方案因专为小型代码片段而设计,故无法运用于大型或中型程序代码的性能检测,且运用第二种实现方案仅能比较所检测代码片段的性能优劣,用户通过检测结果也仅能定性地判断出所检测的多个代码片段的性能优劣与否,而无从得知造成代码片段性能不佳的具体原因,从而导致了现有代码性能检测结果的精确度低的问题。例如,当前待检测的源代码为一个包含有耦合了多个功能的搭函数的中型程序代码,若运用v8-profiler来对这一源代码进行性能分析,会耗费较长的时间才能得到这一源代码的执行统计数据,而执行统计数据当中,CPU占用率等数据对中小型程序代码的性能分析并无帮助,且执行统计数据当中关于程序中函数的执行数据也仅能定性地判断出函数的性能优劣。此时程序员根据检测结果得知这一大函数的性能不佳,严重影响了整个程序的性能,但从检测结果当中无法获取到更加详细的信息来确定导致性能不佳的具体原因,程序员就需要花费较长时间才能分析出这一大函数中哪些关键语句可以更改。At present, for code written in JavaScript, if you want to collect runtime information for dynamic program analysis, there are two implementation schemes in the prior art: one is to use the interface for collecting running data provided inside the JavaScript engine to implement JavaScript within a period of time. Export of code running data; the other is to inject running data collection code into compiled source code to collect running data. However, the first implementation scheme is only suitable for large and complex project codes, and the performance statistics data of the functions in the detected code are obtained, so it can only reflect the performance pros and cons of the detected code at the function level; while the second implementation scheme Because it is designed for small code snippets, it cannot be applied to the performance testing of large or medium-sized program codes. The second implementation scheme can only compare the performance of the code snippets tested, and users can only qualitatively pass the test results. It is judged whether the performance of the multiple code fragments detected is good or bad, and there is no way to know the specific reasons for the poor performance of the code fragments, which leads to the problem of low accuracy of the existing code performance detection results. For example, the current source code to be tested is a medium-sized program code that contains a function that couples multiple functions. If you use v8-profiler to analyze the performance of this source code, it will take a long time to get this The execution statistics of the source code. Among the execution statistics, the CPU occupancy rate and other data are not helpful to the performance analysis of the small and medium-sized program codes. In the execution statistics, the execution data of the functions in the program can only qualitatively determine the function. The pros and cons of performance. At this time, the programmer knows that the performance of this large function is poor according to the test results, which seriously affects the performance of the entire program, but more detailed information cannot be obtained from the test results to determine the specific cause of the poor performance, the programmer It takes a long time to analyze which key statements in this large function can be changed.
在本实施例中,为解决上述问题,本申请提供一种代码性能检测方法,即本申请通过获取包含有能够检测到目标语句块性能的预设性能统计代码,使得代码性能检测的对象细化到了待检测源码中的部分语句,突破了现有技术中仅能将待检测代码中的函数作为最小细化对象的限制;通过将预设性能统计代码注入待检测源码,使得待检测源码中的目标语句块的性能能够通过预设性能统计代码进行检测;根据获取第一、第二性能统计数据,使得用户能够了解到目标代码中函数内部的执行情况,并根据这一执行情况对目标代码进行较之现有方案更为细致的性能分析;通过确定待优化函数中的待优化语句,使得用户能够得到比起整个函数更为精确的优化目标,尤其是对于经验不足的程序员而言,通过现有的代码性能检测结果对目标代码性能优劣的决定因素进行分析的难度较大,而通过本申请能够直接获取到目标语句块的执行情况,进而快速分析出导致代码性能不佳的具体原因,提高了代码性能检测结果的精确度,从而解决了现有代码性能检测结果的精确度低的技术问题。所述代码性能检测方法应用于装有Node.js(一种基于Chrome V8引擎的JavaScript运行环境)的终端。In this embodiment, in order to solve the above problems, this application provides a code performance detection method, that is, this application obtains a preset performance statistical code that can detect the performance of the target sentence block, so that the object of the code performance detection is refined. Part of the sentences in the source code to be tested has broken through the limitation in the prior art that only functions in the code to be tested can be used as the smallest refinement object; by injecting the preset performance statistics code into the source code to be tested, the The performance of the target sentence block can be tested through the preset performance statistics code; according to the first and second performance statistics obtained, the user can understand the execution of the function in the target code, and perform the target code according to this execution. More detailed performance analysis than the existing solution; by determining the sentence to be optimized in the function to be optimized, users can get more accurate optimization goals than the entire function, especially for programmers with inexperience. Existing code performance testing results are more difficult to analyze the determinants of the performance of the target code. However, through this application, the execution status of the target sentence block can be directly obtained, and the specific reasons leading to the poor performance of the code can be quickly analyzed. , Improve the accuracy of the code performance detection results, thereby solving the technical problem of low accuracy of the existing code performance detection results. The code performance detection method is applied to a terminal equipped with Node.js (a JavaScript runtime environment based on the Chrome V8 engine).
性能检测指令可以是程序员导入待检测源码与预设性能统计代码所发起的,也可以由终端根据预置指令自动发起。预设性能统计代码包括行计数统计代码、执行统计代码和相关正则表达式,用于匹配所述待检测源码中的目标语句块和目标函数并检测其性能,是事先编写完成的通用于大部分代码的性能统计代码;对于小部分较为复杂的源代码,可事先对预设性能统计代码进行优化后再使用。目标语句块包括但不限于循环语句、选择语句、判断语句、返回语句等关键语句。目标函数为待检测源码中需要执行的所有函数。具体地,用户通过导入当前的一个中型程序代码作为待检测源码,与通用的性能统计代码,向装有Node.js的计算机发起一个代码性能检测指令。计算机接收到代码性能检测指令,获取这一性能检测指令中的待检测源码与预设性能统计代码。计算机从预设性能统计代码中获取正则表达式,并通过上述正则表达式逐行匹配这一待检测源码,从而确定这一待检测源码中的目标函数以及目标函数中的关键语句。The performance testing instruction can be initiated by the programmer importing the source code to be tested and the preset performance statistics code, or it can be initiated automatically by the terminal according to the preset instruction. The preset performance statistics code includes line count statistics code, execution statistics code, and related regular expressions, which are used to match the target sentence block and target function in the source code to be tested and detect their performance. They are pre-written and commonly used for most The performance statistics code of the code; for a small part of the more complex source code, the preset performance statistics code can be optimized before use. The target sentence block includes but is not limited to key sentences such as loop sentences, selection sentences, judgment sentences, and return sentences. The target function is all the functions that need to be executed in the source code to be tested. Specifically, the user initiates a code performance test instruction to a computer equipped with Node.js by importing a current medium-sized program code as the source code to be tested, and a general performance statistics code. The computer receives the code performance test instruction, and obtains the source code to be tested and the preset performance statistics code in the performance test instruction. The computer obtains the regular expression from the preset performance statistics code, and matches the source code to be tested line by line through the regular expression, thereby determining the target function in the source code to be tested and the key sentence in the target function.
步骤S20,基于所述目标函数与目标语句块在所述待检测源码中的目标位置信息,将所述性能统计代码注入所述待检测源码中的目标注入位置,将已注入的待检测源码作为目标代码;Step S20, based on the target position information of the target function and the target sentence block in the source code to be tested, inject the performance statistics code into the target injection location in the source code to be tested, and use the injected source code to be tested as Target code
目标位置信息包括目标函数在待检测源码中的第一位置信息与目标语句块在待检测源码中的第二位置信息。目标注入位置包括执行统计代码对应在待检测源码中的第一注入位置与行计数统计代码对应在待检测源码中的第二注入位置。The target location information includes the first location information of the target function in the source code to be detected and the second location information of the target sentence block in the source code to be detected. The target injection location includes a first injection location corresponding to the execution statistics code in the source code to be detected and a second injection location corresponding to the line count statistics code in the source code to be detected.
在本实施例中,装有Node.js的终端将上述的性能统计代码注入待检测源码的相应位置。需要说明的是,性能统计代码注入前后待检测源码的语意不会发生改变。具体地,性能统计代码包括行计数统计代码与执行统计代码。行计数统计代码通过在执行上下文注入一个全局对象count,以语句类型type+源码行数line+源码列数column作为对象的键key,执行次数作为值value记录语句执行次数。语句类型有if、else if、else、for、while、return等关键语句。首次进行计数时初始化键值对为1,后续不断叠加。执行统计代码通过在函数前后注入performance.now()语句,获取函数执行前后的系统时间开始时间和结束时间。两个数值相减即可得出对应函数的执行时间,且每得出一个函数执行时间,则表明执行一次。即可获取函数执行时间与执行次数。获取到执行时间和执行次数后,通过全局变量profile记录函数执行次数和执行时间。计算机将行计数统计代码封装成lineCounter函数,并接收三个参数type(语句类型)、line(源码行数)、column(源码列数),这一函数返回undefined(未定义)参数;也将执行统计代码封装成functionProfiler函数,接收两个参数:functionName(函数名字)、time(函数执行时间)。需要说明的是,为了防止命名冲突,JavaScript内置的函数将会加上对应的对象名字。例如Math.sqrt会转化为Math_sqrt,对于匿名函数会统一用_selfExecution代替。计算机将行计数统计代码注入待检测源码中的循环语句、判断语句、返回语句等关键语句的相应位置,并将执行统计代码注入待检测源码中执行函数前后的对应位置。In this embodiment, the terminal equipped with Node.js injects the above-mentioned performance statistics code into the corresponding position of the source code to be checked. It should be noted that the semantics of the source code to be tested before and after the performance statistics code is injected will not change. Specifically, the performance statistics code includes row count statistics code and execution statistics code. The line count statistics code injects a global object count in the execution context, uses the statement type type + source line number line + source code column number column as the key of the object, and the number of executions is used as the value to record the number of executions of the statement. The statement types include key statements such as if, else if, else, for, while, and return. The key-value pair is initialized to 1 when the first count is performed, and then it continues to overlap. The execution statistics code obtains the start time and end time of the system time before and after the function is executed by injecting performance.now() statements before and after the function. The execution time of the corresponding function can be obtained by subtracting two values, and each time the execution time of a function is obtained, it means that it is executed once. Then you can get the function execution time and execution times. After obtaining the execution time and execution times, record the function execution times and execution time through the global variable profile. The computer encapsulates the line count statistics code into the lineCounter function, and receives three parameters type (statement type), line (source line number), column (source code column number), this function returns undefined (undefined) parameters; it will also execute The statistical code is encapsulated into the functionProfiler function, which receives two parameters: functionName (function name) and time (function execution time). It should be noted that in order to prevent naming conflicts, JavaScript built-in functions will add the corresponding object name. For example, Math.sqrt will be converted to Math_sqrt, and _selfExecution will be used instead for anonymous functions. The computer injects the line count statistics code into the corresponding positions of key sentences such as loop statements, judgment statements, and return statements in the source code to be tested, and injects the execution statistics code into the corresponding locations before and after the function is executed in the source code to be tested.
在一些实施例中,预设性能统计代码的注入方式还可为将待检测源码分析为抽象语法树,再将相应的目标语句块注入预设性能统计代码,最后生成目标代码;或者可将这一功能下沉到JavaScript解析引擎,由JavaScript解析引擎输出对应的行计数结果。但抽象语法树的解析过程需要花费人力物力,成本较高,而JavaScript解析引擎需要将目标代码嵌入引擎,在线分析代码,可能影响到代码的性能。In some embodiments, the way of injecting the preset performance statistics code may also be to analyze the source code to be detected as an abstract syntax tree, and then inject the corresponding target sentence block into the preset performance statistics code, and finally generate the target code; or One function sinks to the JavaScript parsing engine, and the JavaScript parsing engine outputs the corresponding row count result. However, the parsing process of the abstract syntax tree requires manpower and material resources, and the cost is high, and the JavaScript parsing engine needs to embed the target code into the engine and analyze the code online, which may affect the performance of the code.
步骤S30,执行所述目标代码,并基于所述性能统计代码中的执行统计代码与行计数统计代码,分别获取所述目标函数的第一性能数据与所述目标语句块的第二性能数据;Step S30, execute the target code, and obtain the first performance data of the target function and the second performance data of the target sentence block respectively based on the execution statistics code and the line count statistics code in the performance statistics code;
执行统计代码用于统计待检测源码中目标函数的第一性能数据,行计数统计代码用于统计目标函数中目标语句块的第二性能数据。第一性能数据可为目标语句块的执行次数与执行时间。第二性能数据包括但不限于目标函数的执行次数、总执行时间以及平均执行时间。The execution statistics code is used to count the first performance data of the target function in the source code to be tested, and the row count statistics code is used to count the second performance data of the target sentence block in the target function. The first performance data may be the execution times and execution time of the target sentence block. The second performance data includes, but is not limited to, the number of executions of the objective function, the total execution time, and the average execution time.
在本实施例中,终端基于Node.js这一运行环境执行目标代码,并获取执行结果中的性能统计数据。具体地,在目标代码执行过程中,计算机读取目标代码中全局对象count的数据,解析出目标语句块的执行次数、行数和列数,即值value和键key中的line和column,并在目标代码对应的行前面写入执行次数。接着读取目标代码中全局对象profile的数据,解析出对应函数的总执行时间与执行次数,并通过总执行时间与执行次数得到函数对应的平均执行时间。需要说明的是,本申请中仅对整个函数以及目标语句块也即是关键语句进行性能检测,而不对函数中的全部语句进行性能检测,一是因为对全部语句进行检测耗时较长,二是因为对全部语句进行检测所得到的检测数据大部分对问题的分析并无帮助,且还有可能会对问题的分析产生干扰。In this embodiment, the terminal executes the target code based on the operating environment of Node.js, and obtains performance statistics in the execution result. Specifically, during the execution of the target code, the computer reads the data of the global object count in the target code, and parses out the number of executions, the number of rows, and the number of columns of the target sentence block, that is, the value and the line and column in the key, and Write the number of executions in front of the line corresponding to the target code. Then read the data of the global object profile in the target code, analyze the total execution time and execution times of the corresponding function, and obtain the average execution time corresponding to the function through the total execution time and execution times. It should be noted that this application only performs performance testing on the entire function and the target statement block, that is, the key statement, and does not perform performance testing on all statements in the function. First, it takes a long time to detect all statements. This is because most of the detection data obtained by testing all sentences is not helpful to the analysis of the problem, and may also interfere with the analysis of the problem.
步骤S40,根据所述第一性能数据与第二性能数据,确定所述目标函数中的待优化函数以及所述待优化函数中的待优化语句。Step S40: Determine the function to be optimized in the objective function and the sentence to be optimized in the function to be optimized according to the first performance data and the second performance data.
在本实施例中,待优化函数以及待优化语句可以是终端对第一性能数据与第二性能数据进行分析后确定,也可通过将第一性能数据与第二性能数据显示给用户后由用户来确定。具体地,计算机对第一性能数据进行分析,将满足预设条件的数据对应的函数确定为待优化函数后,获取第二性能数据中待优化函数对应的数据,并对待优化函数对应的数据进行分析,将目标语句块中超出预设阈值的数据对应的语句确定为待优化语句。In this embodiment, the function to be optimized and the sentence to be optimized can be determined by the terminal after analyzing the first performance data and the second performance data, or can be determined by the user after the first performance data and the second performance data are displayed to the user. to make sure. Specifically, the computer analyzes the first performance data, determines the function corresponding to the data that meets the preset conditions as the function to be optimized, obtains the data corresponding to the function to be optimized in the second performance data, and performs the data corresponding to the function to be optimized Analyze and determine the sentence corresponding to the data in the target sentence block that exceeds the preset threshold as the sentence to be optimized.
本申请通过获取包含有能够定位到代码中具体语句,进而检测到目标语句块性能的预设性能统计代码,使得代码性能检测的对象细化到了待检测源码中的部分语句,突破了现有技术中仅能将待检测代码中的函数作为最小细化对象的限制;通过将预设性能统计代码注入待检测源码,使得待检测源码中的目标语句块的性能能够通过预设性能统计代码进行检测;根据获取第一、第二性能统计数据,使得用户能够了解到目标代码中函数内部的执行情况,并根据这一执行情况对目标代码进行较之现有方案更为细致的性能分析;通过确定待优化函数中的待优化语句,使得用户能够得到比起整个函数更为精确的优化目标,尤其是对于经验不足的程序员而言,通过现有的代码性能检测结果对目标代码性能优劣的决定因素进行分析的难度较大,而通过本申请能够直接获取到目标语句块的执行情况,进而快速分析出导致代码性能不佳的具体原因,提高了代码性能检测结果的精确度,从而解决了现有代码性能检测结果的精确度低的技术问题。This application obtains preset performance statistics codes that can locate specific sentences in the code, and then detect the performance of the target sentence block, so that the object of code performance testing is refined to some sentences in the source code to be tested, which breaks through the prior art. Only the functions in the code to be tested can be used as the limit of the minimum refinement object; by injecting the preset performance statistics code into the source code to be tested, the performance of the target sentence block in the source code to be tested can be tested by the preset performance statistics code ;According to the acquisition of the first and second performance statistics, the user can understand the internal execution of the function in the target code, and perform a more detailed performance analysis of the target code based on this execution than the existing scheme; by determining The statement to be optimized in the function to be optimized enables users to obtain more accurate optimization goals than the entire function, especially for programmers with inexperience, through the existing code performance test results on the performance of the target code It is difficult to analyze the determinants, and through this application, the execution status of the target sentence block can be directly obtained, and then the specific reasons leading to poor code performance can be quickly analyzed, and the accuracy of the code performance detection results is improved, thereby solving The existing technical problem of low accuracy of code performance detection results.
基于上述图2所示的第一实施例,提出本申请代码性能检测方法的第二实施例。Based on the first embodiment shown in FIG. 2 above, a second embodiment of the code performance detection method of the present application is proposed.
在本实施例中,在步骤S10具体包括:In this embodiment, step S10 specifically includes:
步骤a,从所述性能统计代码中获取与所述目标函数相关的第一正则表达式以及与所述目标语句块对应的第二正则表达式,并将所述第一正则表达式与第二正则表达式逐行匹配所述待检测源码;Step a: Obtain a first regular expression related to the target function and a second regular expression corresponding to the target sentence block from the performance statistics code, and combine the first regular expression with the second regular expression The regular expression matches the source code to be detected line by line;
在本实施例中,程序员通过分析目标语句块所处的语意环境,写出与待检测源码中函数执行代码对应的第一正则表达式,以及与关键语句对应的第二正则表达式,并将上述正则表达式输入终端。终端获取到上述第一、第二正则表达式,在执行目标代码的过程中,通过上述第一、第二正则表达式逐行匹配每一行代码。具体地,以选择语句if为例,if语句在代码中有两种表现形式,一种是if() {},另一种是if () {},程序员则编写出与if语句对应的正则表达式/$\s+if\s+?\(*.\)/,计算机用这一正则表达式逐行匹配,以寻找待检测源码中的if语句。In this embodiment, the programmer analyzes the semantic environment of the target sentence block, writes the first regular expression corresponding to the function execution code in the source code to be tested, and the second regular expression corresponding to the key sentence, and Enter the above regular expression into the terminal. The terminal obtains the foregoing first and second regular expressions, and in the process of executing the target code, matches each line of code line by line through the foregoing first and second regular expressions. Specifically, take the selection statement if as an example. The if statement has two manifestations in the code, one is if() {} and the other is if () {}. The programmer writes the corresponding if statement The regular expression /$\s+if\s+?\(*.\)/, the computer uses this regular expression to match line by line to find the if statement in the source code to be tested.
步骤b,在所述待检测源码中存在与所述第一正则表达式相匹配的第一部分代码时,判定所述第一部分代码为所述目标函数的执行语句,并根据所述执行语句确定所述目标函数;Step b: When there is a first part of code matching the first regular expression in the source code to be detected, determine that the first part of code is the execution sentence of the target function, and determine the execution sentence according to the execution sentence. The objective function;
在本实施例中,若匹配过程结束,结果显示待检测源码中存在与上述第一正则表达式相匹配的第一部分代码,则终端可判定上述第一部分代码即为待检测源码中函数的执行语句。具体地,若匹配结果显示待检测源码中存在六处与所述第一正则表达式相匹配的代码,则判定这六处代码均为函数的执行语句,也即为待检测源码中存在六个需要执行的函数。In this embodiment, if the matching process ends and the result shows that there is a first part of code matching the first regular expression in the source code to be detected, the terminal can determine that the first part of code is the execution statement of the function in the source code to be detected . Specifically, if the matching result shows that there are six codes matching the first regular expression in the source code to be tested, it is determined that these six codes are all execution statements of the function, that is, there are six codes in the source code to be tested. The function to be executed.
步骤c,在所述待检测源码中存在与所述第二正则表达式相匹配的第二部分代码时,判定所述第二部分代码为所述目标语句块。Step c: When there is a second part of code matching the second regular expression in the source code to be detected, it is determined that the second part of code is the target sentence block.
在本实施例中,若匹配过程结束,结果显示待检测源码中存在与上述正则表达式相匹配的第二部分代码,则终端可判定上述第二部分代码即为所要寻找的目标语句块。具体地,计算机用/$\s+if\s+?\(*.\)/逐行匹配待检测源码,匹配结果显示待检测源码中存在五处与这一正则表达式匹配的代码,则即可判定这五处代码均为判断语句if的代码。In this embodiment, if the matching process ends and the result shows that there is a second part of code matching the regular expression in the source code to be detected, the terminal can determine that the second part of code is the target sentence block to be found. Specifically, the computer uses /$\s+if\s+?\(*.\)/ to match the source code to be tested line by line, and the matching result shows that there are five codes that match this regular expression in the source code to be tested, then It can be determined that these five codes are the codes of the judgment statement if.
进一步地,在本实施例中,步骤c之后,还包括:Further, in this embodiment, after step c, it further includes:
步骤d,获取所述执行语句的第一位置信息以及所述目标语句块的第二位置信息,将所述第一位置信息与第二位置信息作为所述目标位置信息;Step d: Obtain the first position information of the execution sentence and the second position information of the target sentence block, and use the first position information and the second position information as the target position information;
在本实施例中,终端获取目标语句块对应在待检测源码中的第一位置信息,其中,第一位置信息通常为函数执行语句的行数与列数。并获取待检测源码中目标语句块的第二位置信息,第二位置信息通常为目标语句块的行数与列数。In this embodiment, the terminal obtains the first position information corresponding to the target sentence block in the source code to be detected, where the first position information is usually the number of rows and columns of the function execution sentence. And obtain the second position information of the target sentence block in the source code to be detected, the second position information is usually the number of rows and columns of the target sentence block.
步骤e,基于所述目标位置信息,确定所述执行统计代码与行计数统计代码分别对应的第一注入位置与第二注入位置,将所述第一注入位置与第二注入位置作为所述目标注入位置;Step e: Based on the target position information, determine a first injection position and a second injection position respectively corresponding to the execution statistics code and the row count statistics code, and use the first injection position and the second injection position as the target Injection position
其中,第一注入位置在不同类型关键语句中的位置不同,第二注入位置为函数的执行语句前后的位置。Among them, the first injection position has different positions in different types of key statements, and the second injection position is the position before and after the execution statement of the function.
在本实施例中,终端根据上述第一位置信息与第二位置信息,确定行计数统计代码在待检测源码中的第一注入位置,以及执行统计代码中的第二注入位置。具体地,计算机用第一正则表达式逐行匹配待检测源码,将匹配成功的语句判定为上述函数对应的函数执行代码,并在函数执行代码前注入const __start = performance.now();语句,并在函数执行代码后注入const __end = performance.now();语句。函数执行代码前后位置即为上述第一注入位置。以目标语句块为判断语句if为例,计算机获取一判断语句if()的行数与列数,并根据这一行数和列数,用lineCounter函数替换这一if()语句中最前面的“(”,这一位置即为上述第二注入位置,并将注入完成的代码写入js_profile_code.js文件中。更多实施例中,判断语句else if、循环语句for、while 均有“()”判断语句是否执行,则注入方式与上述if语句的注入方式一致。对于返回语句return,计算机直接在匹配判定出的return语句前插入lineCounter函数即可完成注入。In this embodiment, the terminal determines the first injection position of the line count statistical code in the source code to be detected and the second injection position of the execution statistical code according to the above-mentioned first position information and the second position information. Specifically, the computer uses the first regular expression to match the source code to be tested line by line, judges the successfully matched statement as the function execution code corresponding to the above function, and injects the const __start = performance.now(); statement before the function execution code, And inject the const __end = performance.now(); statement after the function executes the code. The position before and after the function execution code is the above-mentioned first injection position. Taking the target sentence block as the judgment statement if as an example, the computer obtains the number of rows and columns of a judgment statement if(), and according to this number of rows and columns, replaces the first "in the if() statement with the lineCounter function (", this position is the second injection position, and the injected code is written into the js_profile_code.js file. In more embodiments, the judgment statement else if, loop statement for, and while all have "()" To determine whether the statement is executed, the injection method is consistent with the injection method of the above if statement. For the return statement return, the computer directly inserts the lineCounter function before the return statement determined by the match to complete the injection.
步骤f,将所述性能统计代码注入所述目标注入位置,将已注入待检测源码作为所述目标代码。Step f: Inject the performance statistics code into the target injection location, and use the injected source code to be detected as the target code.
在本实施例中,终端将执行统计代码注入已确定的第一注入位置,将行计数统计代码注入已确定的第二注入位置。完成注入操作后,终端将已注入有执行统计代码与行计数统计代码的待检测源码作为即将运行的目标代码。In this embodiment, the terminal injects the execution statistics code into the determined first injection position, and injects the row count statistics code into the determined second injection position. After the injection operation is completed, the terminal uses the source code to be tested that has been injected with the execution statistics code and the line count statistics code as the target code to be run.
进一步地,步骤d之后,还包括:Further, after step d, it also includes:
步骤g,判断所述目标语句块中是否存在特定语句;Step g, judging whether there is a specific sentence in the target sentence block;
在本实施例中,终端通过检测并匹配,判断每个判定为目标语句块的代码中是否存在特定语句。其中,特定语句为关键语句中else语句的“{}”包括的语句。In this embodiment, the terminal determines whether there is a specific sentence in each code determined as the target sentence block through detection and matching. Among them, the specific sentence is the sentence included in the "{}" of the else sentence in the key sentence.
步骤h,若所述目标语句块中存在所述特定语句,则将所述特定语句所在的位置作为所述第一注入位置,并将所述行计数统计代码注入所述第一注入位置;Step h, if the specific sentence exists in the target sentence block, use the position where the specific sentence is located as the first injection position, and inject the line count statistics code into the first injection position;
在本实施例中,若终端判定当前这一目标语句块中存在特定语句,则将行计数统计代码注入特定语句所在的第一注入位置。具体地,若经判定这一else语句中存在“{}”包括的语句,则计算机将lineCounter函数注入这一语句当中,这一位置即为上述第一注入位置。In this embodiment, if the terminal determines that a specific sentence exists in the current target sentence block, the line count statistics code is injected into the first injection position where the specific sentence is located. Specifically, if it is determined that there is a sentence included in "{}" in this else sentence, the computer injects the lineCounter function into this sentence, and this position is the aforementioned first injection position.
步骤i,若所述目标语句块中不存在所述特定语句,则在所述目标语句块中添加所述特定语句,并重复执行步骤:将所述特定语句所在的位置作为所述第一注入位置,并将所述行计数统计代码注入所述第一注入位置。Step i, if the specific sentence does not exist in the target sentence block, add the specific sentence to the target sentence block, and repeat the steps: use the position of the specific sentence as the first injection Position, and inject the row count statistics code into the first injection position.
在本实施例中,若终端判定当前这一目标语句块中不存在特定语句,则将特定语句添加进这一目标语句块,再将行计数统计代码注入特定语句所在的第一注入位置。具体地,若经判定这一else语句中不存在“{}”包括的语句,则计算机在这一else语句中添加这一特定语句,再将行计数统计代码注入这一特定语句所在的第一注入位置。In this embodiment, if the terminal determines that there is no specific sentence in the current target sentence block, the specific sentence is added to the target sentence block, and the line count statistics code is injected into the first injection position where the specific sentence is located. Specifically, if it is determined that the sentence included in "{}" does not exist in this else sentence, the computer adds this particular sentence to this else sentence, and then injects the line count statistics code into the first sentence where this particular sentence is located. Injection position.
本申请提供一种代码性能检测方法,所述代码性能检测方法进一步通过正则表达式匹配待检测源码中函数的执行语句以及目标语句块,提高了识别代码中函数与目标语句块的效率与准确度;将行计数统计代码与执行统计代码注入待检测源码的对应位置,使得行计数统计代码与执行统计代码能够正常运行并统计出目标语句块与函数的性能数据,实现了更为细化的代码性能检测;通过识别特定语句,使得能够精准地确定行计数统计代码在else语句中的注入位置,提高了代码注入的准确度。The present application provides a code performance detection method, which further matches the execution sentence and target sentence block of the function in the source code to be tested through regular expressions, thereby improving the efficiency and accuracy of identifying functions and target sentence blocks in the code ; Inject the line count statistics code and execution statistics code into the corresponding positions of the source code to be tested, so that the line count statistics code and execution statistics code can run normally, and the performance data of the target statement block and function are counted, and more detailed code is realized Performance testing: By identifying specific statements, it is possible to accurately determine the injection position of the line count statistics code in the else statement, which improves the accuracy of code injection.
基于上述图2所示的第一实施例,提出本申请代码性能检测方法的第三实施例。Based on the first embodiment shown in FIG. 2 above, a third embodiment of the code performance detection method of the present application is proposed.
在本实施例中,在步骤S40具体包括:In this embodiment, step S40 specifically includes:
步骤j,获取所述第一性能数据中的函数执行次数与函数执行时间,并判断所述函数执行次数与函数执行时间是否分别超出预设第一阈值与预设第二阈值;Step j: Obtain the number of function execution times and the function execution time in the first performance data, and determine whether the number of function execution times and the function execution time exceed a preset first threshold and a preset second threshold, respectively;
函数执行时间包括函数执行总时间与函数平均执行时间。预设第一阈值为界定函数执行次数优劣的数值,预设第二阈值为界定函数执行时间优劣的时间值,且在本实施例中预设第二阈值可设置为预设平均执行时间阈值与预设执行总时间阈值两种不同的值,上述三种阈值均可根据具体情况灵活设定,本实施例对其不做具体限定。The function execution time includes the total function execution time and the average function execution time. The preset first threshold value is a value that defines the number of times the function is executed, and the preset second threshold value is a time value that defines the function's execution time. In this embodiment, the preset second threshold can be set to a preset average execution time. The threshold and the preset total execution time threshold are two different values. The above three thresholds can be flexibly set according to specific conditions, which are not specifically limited in this embodiment.
在本实施例中,终端将执行统计代码注入待检测源码中的对应位置后,通过运行目标代码,获取待检测源码中所有执行的函数的执行次数以及执行行总时间,并计算出每一函数的平均执行时间。并将这些数据与预设第一阈值、预设平均执行时间阈值、预设执行总时间阈值比较。具体地,计算机获取并显示出第二性能数据为:main函数的执行次数为1,执行总时间为18.17299ms,平均执行时间为18.17299ms;prime函数的执行次数为999,执行总时间为14.78644ms,平均执行时间为0.01480ms;Math_sqrt函数的执行次数为999,执行总时间为0.41335ms,平均执行时间为0.00041ms。以预设平均执行时间阈值为1ms,预设第一阈值为500,预设执行总时间阈值为10ms为例,判断上述数据是否超出阈值。In this embodiment, after the terminal injects the execution statistics code into the corresponding position in the source code to be detected, by running the target code, it obtains the execution times and the total execution time of all the functions executed in the source code to be detected, and calculates each function The average execution time. The data is compared with the preset first threshold, the preset average execution time threshold, and the preset total execution time threshold. Specifically, the computer obtains and displays the second performance data as follows: the number of executions of the main function is 1, the total execution time is 18.17299ms, and the average execution time is 18.17299ms; the number of executions of the prime function is 999, and the total execution time is 14.78644ms. , The average execution time is 0.01480ms; the number of executions of the Math_sqrt function is 999, the total execution time is 0.41335ms, and the average execution time is 0.00041ms. Taking the preset average execution time threshold value of 1 ms, the preset first threshold value of 500, and the preset total execution time threshold value of 10 ms as an example, it is determined whether the above data exceeds the threshold value.
步骤k,若所述函数执行次数超出所述第一阈值且所述函数执行时间超出所述第二阈值,则判定超出所述第一阈值和第二阈值的数据所对应的函数为待优化函数;Step k, if the number of executions of the function exceeds the first threshold and the execution time of the function exceeds the second threshold, it is determined that the function corresponding to the data exceeding the first threshold and the second threshold is the function to be optimized ;
在本实施例中,沿用上述具体实施例中的数据,从上述数据中可知main函数中的函数执行次数、函数执行总时间以及函数平均执行时间均超出阈值,则判定main函数为待优化函数;prime函数中的函数执行次数与函数总时间超出阈值,而平均执行时间未超出阈值,则判定prime函数为待优化函数;Math_sqrt函数中仅有函数执行次数超出阈值,而函数执行中时间与函数平均执行时间均未超出阈值,则判定Math_sqrt函数不需要优化。In this embodiment, using the data in the above specific embodiment, it can be seen from the above data that the number of executions of the function in the main function, the total execution time of the function, and the average execution time of the function all exceed the threshold, then it is determined that the main function is a function to be optimized; The number of executions of the function in the prime function and the total time of the function exceed the threshold, and the average execution time does not exceed the threshold, the prime function is determined to be a function to be optimized; in the Math_sqrt function, only the number of executions of the function exceeds the threshold, and the execution time of the function is the average of the function If the execution time does not exceed the threshold, it is determined that the Math_sqrt function does not need to be optimized.
步骤l,获取所述第二性能数据中与所述待优化函数对应的目标语句块执行次数,并判断所述目标语句块执行次数是否超出预设第三阈值;Step 1. Obtain the execution times of the target sentence block corresponding to the function to be optimized in the second performance data, and determine whether the execution times of the target sentence block exceeds a preset third threshold;
预设第三阈值为判定待优化语句的执行次数的值,并根据具体情况灵活设定。The preset third threshold is a value for determining the number of executions of the sentence to be optimized, and is flexibly set according to specific conditions.
在本实施例中,终端根据在目标函数中确定的待优化函数,获取每一待优化函数对应的关键语句的执行次数。终端将预设第三阈值与关键语句的执行次数进行比较。具体地,沿用上述实施例,设定当前计算机获取到在main函数中,if语句执行了300次,for语句执行了50次,return语句执行了50次;在prime函数中,for语句执行了200次,return语句执行了30次;在Math_sqrt函数中,if语句执行了20次,return语句执行了30次。设定预设第三阈值为100,计算机判断上述数据是否超出这一预设第三阈值。In this embodiment, the terminal obtains the execution times of the key sentence corresponding to each function to be optimized according to the function to be optimized determined in the objective function. The terminal compares the preset third threshold with the number of executions of the key sentence. Specifically, following the above-mentioned embodiment, it is assumed that the current computer obtains that in the main function, the if statement is executed 300 times, the for statement is executed 50 times, and the return statement is executed 50 times; in the prime function, the for statement is executed 200 times. The return statement was executed 30 times; in the Math_sqrt function, the if statement was executed 20 times, and the return statement was executed 30 times. The preset third threshold is set to 100, and the computer determines whether the above data exceeds the preset third threshold.
步骤m,若所述目标语句块执行次数超出所述第三阈值,则判定超出所述第三阈值的数据对应的语句为待优化语句。Step m: If the number of executions of the target sentence block exceeds the third threshold, it is determined that the sentence corresponding to the data exceeding the third threshold is a sentence to be optimized.
在本实施例中,终端将目标语句块执行次数中超出预设第三阈值的数据所对应的语句判定为待优化语句。具体地,沿用上述具体实施例的数据,上可判定在main函数中if语句的执行次数300超出预设第三阈值100,故判定main函数中的if语句为待优化的关键语句;在prime函数中for语句的执行次数200超出预设第三阈值100,故判定prime函数中的for语句为待优化的关键语句。In this embodiment, the terminal determines the sentence corresponding to the data that exceeds the preset third threshold among the execution times of the target sentence block as a sentence to be optimized. Specifically, using the data of the above specific embodiment, it can be determined that the number of executions of the if statement 300 in the main function exceeds the preset third threshold 100, so it is determined that the if statement in the main function is the key statement to be optimized; in the prime function The number of executions of the for statement 200 exceeds the preset third threshold of 100, so it is determined that the for statement in the prime function is a key statement to be optimized.
进一步地,在本实施例中,步骤S10具体包括:Further, in this embodiment, step S10 specifically includes:
步骤n,在接收到所述性能检测指令时,获取所述性能检测指令中的原始代码,并判断所述原始代码中是否存在待执行函数;Step n: When receiving the performance test instruction, obtain the original code in the performance test instruction, and determine whether there is a function to be executed in the original code;
在本实施例中,用户通过导入一原始代码发起性能检测指令,终端接收到这一性能检测指令,获取这一性能检测指令中的上述原始代码,并通过函数识别字符或语句判断上述原始代码中是否存在待执行的函数。需要说明的是,大部分程序代码均存在待执行函数,只有一些小型代码片段可能仅由若干语句组成,而不存在待执行函数。In this embodiment, the user initiates a performance test instruction by importing an original code. The terminal receives the performance test instruction, obtains the original code in the performance test instruction, and uses the function to recognize characters or sentences to determine whether the original code is in the original code. Whether there is a function to be executed. It should be noted that most program codes have functions to be executed, and only some small code fragments may consist of only a few statements, and there are no functions to be executed.
步骤o,若所述原始代码中存在所述待执行函数,则判定所述原始代码为所述待检测源码,并获取所述性能统计代码;Step o: If the function to be executed exists in the original code, determine that the original code is the source code to be tested, and obtain the performance statistics code;
在本实施例中,若终端经识别判断出这一原始代码中存在待执行函数,则将这一原始代码作为待检测源码,并用本申请中的方案对这一原始代码进行性能检测。若这一原始代码中不存在待执行函数,则可说明这一原始代码为若干语句组成的小型代码片段。In this embodiment, if the terminal determines that there is a function to be executed in the original code after identification, it will use this original code as the source code to be tested, and use the solution in this application to perform performance testing on this original code. If there is no function to be executed in the original code, it can be explained that the original code is a small code fragment composed of several statements.
步骤p,根据所述性能统计代码,确定所述目标函数与目标语句块。Step p: Determine the target function and target sentence block according to the performance statistics code.
在本实施例中,终端从预设性能统计代码获取第一正则表达式与第二正则表达式,并逐行将待检测源码与第一、第二正则表达式进行匹配,确定出待检测源码中的目标函数与目标语句块。In this embodiment, the terminal obtains the first regular expression and the second regular expression from the preset performance statistics code, and matches the source code to be tested with the first and second regular expressions line by line, and determines the source code to be tested The objective function and objective sentence block.
进一步地,在本实施例中,步骤S40之前还包括:Further, in this embodiment, before step S40, the method further includes:
步骤q,根据预设权重、所述目标函数的函数执行次数与函数执行时间,生成每一目标函数的性能参考值,其中,所述函数执行次数与函数执行时间为所述第二性能数据;Step q, generating a performance reference value of each objective function according to the preset weight, the number of executions of the function of the objective function, and the execution time of the function, wherein the number of executions of the function and the execution time of the function are the second performance data;
预设权重包括函数执行次数对应的第一权重与函数执行总时间对应的第二权重。第一权重与第二权重可根据具体情况灵活设定。The preset weight includes a first weight corresponding to the number of executions of the function and a second weight corresponding to the total execution time of the function. The first weight and the second weight can be flexibly set according to specific conditions.
在本实施例中,终端将第一权重与每一函数执行次数的乘积按从大到小的顺序依次排序,获取每一目标函数的第一序号,将第一序号作为分子,并将目标函数的个数作为分母,得到每一目标函数对应的第一权重分数。终端将第二权重与每一函数执行总时间的乘积按从大到小的顺序依次排序,获取每一目标函数的第二序号,将第二序号作为分子,目标函数的个数作为分子,得到每一目标函数对应的第二权重分数。终端将第一权重分数与第二权重分数的和作为每一目标函数的性能参考值。In this embodiment, the terminal sorts the product of the first weight and the execution times of each function in descending order, obtains the first sequence number of each objective function, uses the first sequence number as the numerator, and sets the objective function As the denominator, the first weight score corresponding to each objective function is obtained. The terminal sorts the product of the second weight and the total execution time of each function in descending order, obtains the second sequence number of each objective function, uses the second sequence number as the numerator, and the number of the objective function as the numerator, and obtains The second weight score corresponding to each objective function. The terminal uses the sum of the first weight score and the second weight score as the performance reference value of each objective function.
步骤r,按照所述性能参考值从高到低显示目标函数名称以及对应的函数执行次数与函数执行时间;Step r, displaying the name of the target function and the corresponding function execution times and function execution time according to the performance reference value from high to low;
在本实施例中,终端根据判定后所生成的每一目标函数的性能优劣权重,按照从高到低的顺序显示当前所有执行函数中的待优化函数的函数名称以及对应的执行总时间、执行次数与平均执行时间。用户通过上述的显示结果,分析目标函数的性能,并确定目标函数中的待优化函数。In this embodiment, the terminal displays the function name of the function to be optimized and the corresponding total execution time of all current execution functions in order from high to low according to the performance pros and cons weight of each objective function generated after the determination. Number of executions and average execution time. The user analyzes the performance of the objective function through the above display results, and determines the function to be optimized in the objective function.
步骤s,按照目标语句块执行次数从大到小的顺序依次显示目标语句块名称以及对应的目标语句块执行次数,所述目标语句块执行次数为所述第一性能数据。In step s, the target sentence block names and the corresponding target sentence block execution times are sequentially displayed in descending order of the target sentence block execution times, and the target sentence block execution times are the first performance data.
在本实施例中,终端按照数值大小分别为每一函数所对应的目标语句块进行排序,优先显示每一函数中执行次数多的目标语句块以及每一目标语句块执行次数。用户获取到上述显示结果后,对各个目标语句块进行分析,并确定目标语句块中的待优化语句。具体地,若main函数中if语句的执行次数为300次,else语句的执行次数为250次,for语句的执行次数为200次,return语句的执行次数为400次,则终端按照return语句、main语句、if语句、else语句和for语句的顺序显示。用户可根据上述显示的数据对目标语句的性能进行分析。In this embodiment, the terminal sorts the target sentence blocks corresponding to each function according to the numerical value, and preferentially displays the target sentence blocks with the most execution times in each function and the execution times of each target sentence block. After obtaining the above display results, the user analyzes each target sentence block and determines the sentence to be optimized in the target sentence block. Specifically, if the number of executions of the if statement in the main function is 300, the number of executions of the else statement is 250, the number of executions of the for statement is 200, and the number of executions of the return statement is 400, then the terminal follows the return statement, main The order of statement, if statement, else statement, and for statement is displayed. The user can analyze the performance of the target sentence based on the data displayed above.
进一步地,所述代码性能检测方法还包括:Further, the code performance detection method further includes:
步骤t,获取所述目标代码中的工具函数与所述性能统计代码中的性能统计函数,并将所述工具函数与性能统计函数作为统计工具函数;Step t, obtaining the tool function in the target code and the performance statistical function in the performance statistical code, and use the tool function and the performance statistical function as the statistical tool function;
工具函数为处理统计后的数据的方法,性能统计函数为行计数函数与执行统计函数。The tool function is a method of processing the statistical data, and the performance statistics function is the row count function and the execution statistics function.
在本实施例中,终端分别获取目标代码中的工具函数,以及性能统计代码中的行计数函数与执行统计函数,并将上述工具函数、行计数函数与执行统计函数作为统计工具函数。In this embodiment, the terminal separately obtains the tool function in the target code, and the row count function and execution statistics function in the performance statistics code, and uses the above tool function, row count function, and execution statistics function as the statistics tool function.
步骤u,将所述统计工具函数写入指定文件,以基于所述指定文件中的所述统计工具函数对下一待检测的代码进行性能数据统计。Step u: Write the statistical tool function into a designated file to perform performance data statistics on the next code to be tested based on the statistical tool function in the designated file.
在本实施例中,终端将上述统计工具函数写入名为js_profile_code.js的文件中,方便后续再次对代码中的函数与目标语句块进行性能检测时能够直接从js_profile_code.js的文件中调用上述统计工具函数。In this embodiment, the terminal writes the above-mentioned statistical tool function into a file named js_profile_code.js, so that when the function and target sentence block in the code are tested again in the future, the above-mentioned function can be called directly from the file js_profile_code.js. Statistical tool function.
本申请提供一种代码性能检测方法,所述代码性能检测方法进一步通过直接获取待优化函数中的目标语句块的执行次数,精确地定位到降低待优化函数性能的若干语句,使得提高了代码性能分析效率,节省了代码性能分析时间;通过判断原始代码是否为存在待执行函数的代码,使得确定本申请的一个最佳适用范围;通过优先显示性能低的函数与目标语句块,使得程序员能够更加直观地获取到耗时最久、执行次数最多的相关代码的信息,从而更加快速地定位到导致代码性能不佳的具体函数,进而定位到待优化函数中的目标语句块,进一步提高了代码性能优化效率,同时提升了用户体验;通过将统计工具函数汇总并写入特定文件,使得后续需要使用到相关函数时可以直接从特定文件中调用,提高了计算机对代码进行性能检测的工作效率。The present application provides a code performance detection method. The code performance detection method further directly obtains the execution times of the target sentence block in the function to be optimized, and accurately locates several sentences that reduce the performance of the function to be optimized, so that the code performance is improved. Analysis efficiency saves code performance analysis time; by judging whether the original code is a code with functions to be executed, an optimal scope of application is determined; by giving priority to displaying low-performance functions and target sentence blocks, programmers can Obtain more intuitively the information about the relevant code that takes the longest time and the most execution times, so as to quickly locate the specific function that causes the poor performance of the code, and then locate the target statement block in the function to be optimized, and further improve the code Performance optimization efficiency, while improving user experience; by summarizing statistical tool functions and writing them into specific files, it can be directly called from specific files when relevant functions are needed later, which improves the efficiency of computer performance testing of code.
本申请还提供一种代码性能检测装置,包括:This application also provides a code performance detection device, including:
函数语句确定模块,用于在接收到性能检测指令时,获取待检测源码与预设性能统计代码,并确定所述待检测源码中的目标函数以及所述目标函数中的目标语句块;The function sentence determination module is used to obtain the source code to be tested and the preset performance statistics code when the performance test instruction is received, and to determine the target function in the source code to be tested and the target sentence block in the target function;
性能代码注入模块,用于基于所述目标函数与目标语句块在所述待检测源码中的目标位置信息,将所述性能统计代码注入所述待检测源码中的目标注入位置,将已注入的待检测源码作为目标代码;The performance code injection module is used to inject the performance statistics code into the target injection position in the source code to be tested based on the target function and target sentence block target location information in the source code to be tested, and the injected The source code to be tested is used as the target code;
性能数据获取模块,用于执行所述目标代码,并基于所述性能统计代码中的执行统计代码与行计数统计代码,分别获取所述目标函数的第一性能数据与所述目标语句块的第二性能数据;The performance data acquisition module is configured to execute the target code, and obtain the first performance data of the target function and the first performance data of the target sentence block based on the execution statistics code and the line count statistics code in the performance statistics code. 2. Performance data;
优化语句确定模块,用于根据所述第一性能数据与第二性能数据,确定所述目标函数中的待优化函数以及所述待优化函数中的待优化语句。The optimized sentence determination module is configured to determine the function to be optimized in the objective function and the sentence to be optimized in the function to be optimized according to the first performance data and the second performance data.
所述代码性能检测装置还包括:The code performance detection device further includes:
正则获取匹配模块,用于从所述性能统计代码中获取与所述目标函数相关的第一正则表达式以及与所述目标语句块对应的第二正则表达式,并将所述第一正则表达式与第二正则表达式逐行匹配所述待检测源码;The regular acquisition and matching module is used to acquire a first regular expression related to the target function and a second regular expression corresponding to the target sentence block from the performance statistics code, and express the first regular expression The formula matches the source code to be detected line by line with the second regular expression;
第一正则匹配模块,用于在所述待检测源码中存在与所述第一正则表达式相匹配的第一部分代码时,判定所述第一部分代码为所述目标函数的执行语句,并根据所述执行语句确定所述目标函数;The first regular matching module is used to determine that the first part of the code is the execution sentence of the target function when there is a first part of the code matching the first regular expression in the source code to be detected, and according to the The execution sentence determines the objective function;
第二正则匹配模块,用于在所述待检测源码中存在与所述第二正则表达式相匹配的第二部分代码时,判定所述第二部分代码为所述目标语句块。The second regular matching module is configured to determine that the second part of the code is the target sentence block when there is a second part of the code that matches the second regular expression in the source code to be detected.
所述性能代码注入模块具体包括:The performance code injection module specifically includes:
位置信息获取单元,用于获取所述执行语句的第一位置信息以及所述目标语句块的第二位置信息,将所述第一位置信息与第二位置信息作为所述目标位置信息;A location information acquiring unit, configured to acquire first location information of the execution sentence and second location information of the target sentence block, and use the first location information and the second location information as the target location information;
注入位置确定单元,用于基于所述目标位置信息,确定所述执行统计代码与行计数统计代码分别对应的第一注入位置与第二注入位置,将所述第一注入位置与第二注入位置作为所述目标注入位置;The injection position determining unit is configured to determine, based on the target position information, a first injection position and a second injection position corresponding to the execution statistics code and the line count statistics code, respectively, and compare the first injection position and the second injection position As the target injection position;
性能代码注入单元,用于将所述性能统计代码注入所述目标注入位置,将已注入待检测源码作为所述目标代码。The performance code injection unit is configured to inject the performance statistics code into the target injection location, and use the injected source code to be detected as the target code.
所述代码性能检测装置还包括:The code performance detection device further includes:
特定语句判断模块,用于判断所述目标语句块中是否存在特定语句;The specific sentence judgment module is used to judge whether there is a specific sentence in the target sentence block;
代码直接注入模块,用于若所述目标语句块中存在所述特定语句,则将所述特定语句所在的位置作为所述第二注入位置,并将所述行计数统计代码注入所述第二注入位置;The direct code injection module is configured to, if the specific sentence exists in the target sentence block, use the position of the specific sentence as the second injection position, and inject the line count statistics code into the second Injection position
代码间接注入模块,用于若所述目标语句块中不存在所述特定语句,则在所述目标语句块中添加所述特定语句,并重复执行步骤:将所述特定语句所在的位置作为所述第二注入位置,并将所述行计数统计代码注入所述第二注入位置。The code indirect injection module is used to add the specific sentence to the target sentence block if the specific sentence does not exist in the target sentence block, and repeat the steps: take the location of the specific sentence as the target sentence block. The second injection position, and the row count statistical code is injected into the second injection position.
所述性能数据获取模块具体包括:The performance data acquisition module specifically includes:
函数数据判断单元,用于获取所述第一性能数据中的函数执行次数与函数执行时间,并判断所述函数执行次数与函数执行时间是否分别超出预设第一阈值与预设第二阈值;The function data judgment unit is configured to obtain the number of function execution times and the function execution time in the first performance data, and determine whether the number of function execution times and the function execution time exceed a preset first threshold and a preset second threshold, respectively;
优化函数确定单元,用于若所述函数执行次数超出所述第一阈值且所述函数执行时间超出所述第二阈值,则判定超出所述第一阈值和第二阈值的数据所对应的函数为待优化函数;An optimized function determining unit, configured to determine the function corresponding to the data exceeding the first threshold and the second threshold if the number of executions of the function exceeds the first threshold and the execution time of the function exceeds the second threshold Is the function to be optimized;
语句数据判断单元,用于获取所述第二性能数据中与所述待优化函数对应的目标语句块执行次数,并判断所述目标语句块执行次数是否超出预设第三阈值;A sentence data judgment unit, configured to obtain the execution times of the target sentence block corresponding to the function to be optimized in the second performance data, and judge whether the execution times of the target sentence block exceeds a preset third threshold;
优化语句确定单元,用于若所述目标语句块执行次数超出所述第三阈值,则判定超出所述第三阈值的数据对应的语句为待优化语句。The optimized sentence determining unit is configured to determine that the sentence corresponding to the data exceeding the third threshold is a sentence to be optimized if the number of executions of the target sentence block exceeds the third threshold.
上述各程序模块所执行的方法可参照本申请代码性能检测方法各个实施例,此处不再赘述。For the method executed by the above-mentioned program modules, please refer to the various embodiments of the code performance detection method of the present application, which will not be repeated here.
本申请还提供一种代码性能检测设备。This application also provides a code performance testing device.
所述代码性能检测设备包括处理器、存储器及存储在所述存储器上并可在所述处理器上运行的代码性能检测程序,其中所述代码性能检测程序被所述处理器执行时,实现如上所述的代码性能检测方法的步骤。The code performance testing device includes a processor, a memory, and a code performance testing program that is stored on the memory and can run on the processor, where the code performance testing program is executed by the processor to achieve the above The steps of the code performance detection method.
所述代码性能检测程序被执行时所实现的方法可参照本申请代码性能检测方法的各个实施例,此处不再赘述。For the method implemented when the code performance detection program is executed, reference may be made to the various embodiments of the code performance detection method of the present application, which will not be repeated here.
本申请还提供一种计算机可读存储介质。The application also provides a computer-readable storage medium.
本申请计算机可读存储介质上存储有代码性能检测程序,所述代码性能检测程序被处理器执行时实现如上所述的代码性能检测方法的步骤。The computer-readable storage medium of the present application stores a code performance detection program, and when the code performance detection program is executed by a processor, the steps of the code performance detection method described above are implemented.
所述代码性能检测程序被执行时所实现的方法可参照本申请代码性能检测方法各个实施例,此处不再赘述。For the method implemented when the code performance detection program is executed, reference may be made to each embodiment of the code performance detection method of this application, which will not be repeated here.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。It should be noted that in this article, the terms "include", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements not only includes those elements, It also includes other elements that are not explicitly listed, or elements inherent to the process, method, article, or system. If there are no more restrictions, the element defined by the sentence "including a..." does not exclude the existence of other identical elements in the process, method, article, or system that includes the element.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the foregoing embodiments of the present application are for description only, and do not represent the superiority or inferiority of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the method of the above embodiments can be implemented by means of software plus the necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is better.的实施方式。 Based on this understanding, the technical solution of this application essentially or the part that contributes to the existing technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium (such as ROM/RAM) as described above. , Magnetic disks, optical disks), including several instructions to make a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) execute the methods described in the various embodiments of the present application.
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above are only the preferred embodiments of this application, and do not limit the scope of this application. Any equivalent structure or equivalent process transformation made using the content of the description and drawings of this application, or directly or indirectly used in other related technical fields , The same reason is included in the scope of patent protection of this application.

Claims (15)

  1. 一种代码性能检测方法,其中,所述代码性能检测方法包括:A code performance detection method, wherein the code performance detection method includes:
    在接收到性能检测指令时,获取待检测源码与预设性能统计代码,并确定所述待检测源码中的目标函数以及所述目标函数中的目标语句块;When receiving the performance detection instruction, obtain the source code to be tested and the preset performance statistics code, and determine the target function in the source code to be tested and the target sentence block in the target function;
    基于所述目标函数与目标语句块在所述待检测源码中的目标位置信息,将所述性能统计代码注入所述待检测源码中的目标注入位置,将已注入的待检测源码作为目标代码;Based on the target function and target location information of the target sentence block in the source code to be tested, inject the performance statistics code into the target injection location in the source code to be tested, and use the injected source code to be tested as the target code;
    执行所述目标代码,并基于所述性能统计代码中的执行统计代码与行计数统计代码,分别获取所述目标函数的第一性能数据与所述目标语句块的第二性能数据;Execute the target code, and obtain the first performance data of the target function and the second performance data of the target sentence block respectively based on the execution statistics code and the line count statistics code in the performance statistics code;
    根据所述第一性能数据与第二性能数据,确定所述目标函数中的待优化函数以及所述待优化函数中的待优化语句。According to the first performance data and the second performance data, a function to be optimized in the objective function and a sentence to be optimized in the function to be optimized are determined.
  2. 如权利要求1所述的代码性能检测方法,其中,所述确定所述待检测源码中的目标函数以及所述目标函数中的目标语句块的步骤具体包括:3. The code performance detection method according to claim 1, wherein the step of determining the target function in the source code to be tested and the target sentence block in the target function specifically comprises:
    从所述性能统计代码中获取与所述目标函数相关的第一正则表达式以及与所述目标语句块对应的第二正则表达式,并将所述第一正则表达式与第二正则表达式逐行匹配所述待检测源码;Obtain a first regular expression related to the target function and a second regular expression corresponding to the target sentence block from the performance statistics code, and combine the first regular expression with the second regular expression Match the source code to be detected line by line;
    在所述待检测源码中存在与所述第一正则表达式相匹配的第一部分代码时,判定所述第一部分代码为所述目标函数的执行语句,并根据所述执行语句确定所述目标函数;When there is a first part of code matching the first regular expression in the source code to be detected, it is determined that the first part of code is the execution sentence of the target function, and the target function is determined according to the execution sentence ;
    在所述待检测源码中存在与所述第二正则表达式相匹配的第二部分代码时,判定所述第二部分代码为所述目标语句块。When there is a second part of code matching the second regular expression in the source code to be detected, it is determined that the second part of code is the target sentence block.
  3. 如权利要求2所述的代码性能检测方法,其中,所述基于所述目标函数与目标语句块在所述待检测源码中的目标位置信息,将所述性能统计代码注入所述待检测源码中的目标注入位置,将已注入的待检测源码作为目标代码的步骤具体包括:The code performance detection method according to claim 2, wherein the performance statistics code is injected into the source code to be checked based on the target position information of the target function and the target sentence block in the source code to be checked The target injection position of the target code, the steps to use the injected source code to be detected as the target code specifically include:
    获取所述执行语句的第一位置信息以及所述目标语句块的第二位置信息,将所述第一位置信息与第二位置信息作为所述目标位置信息;Acquiring first position information of the execution sentence and second position information of the target sentence block, and using the first position information and the second position information as the target position information;
    基于所述目标位置信息,确定所述执行统计代码与行计数统计代码分别对应的第一注入位置与第二注入位置,将所述第一注入位置与第二注入位置作为所述目标注入位置;Based on the target position information, determine a first injection position and a second injection position respectively corresponding to the execution statistics code and the line count statistics code, and use the first injection position and the second injection position as the target injection positions;
    将所述性能统计代码注入所述目标注入位置,将已注入待检测源码作为所述目标代码。Inject the performance statistics code into the target injection location, and use the injected source code to be detected as the target code.
  4. 如权利要求3所述的代码性能检测方法,其中,所述获取所述执行语句的第一位置信息以及所述目标语句块的第二位置信息,将所述第一位置信息与第二位置信息作为所述目标位置信息的步骤之后,还包括:The code performance detection method according to claim 3, wherein the first position information of the execution sentence and the second position information of the target sentence block are obtained, and the first position information and the second position information are combined After the step of serving as the target location information, it further includes:
    判断所述目标语句块中是否存在特定语句;Judging whether there is a specific sentence in the target sentence block;
    若所述目标语句块中存在所述特定语句,则将所述特定语句所在的位置作为所述第二注入位置,并将所述行计数统计代码注入所述第二注入位置;If the specific sentence exists in the target sentence block, use the position where the specific sentence is located as the second injection position, and inject the line count statistics code into the second injection position;
    若所述目标语句块中不存在所述特定语句,则在所述目标语句块中添加所述特定语句,并重复执行步骤:将所述特定语句所在的位置作为所述第二注入位置,并将所述行计数统计代码注入所述第二注入位置。If the specific sentence does not exist in the target sentence block, add the specific sentence to the target sentence block, and repeat the steps: use the position of the specific sentence as the second injection position, and The row count statistics code is injected into the second injection position.
  5. 如权利要求1所述的代码性能检测方法,其中,所述根据所述第一性能数据与第二性能数据,确定所述目标函数中的待优化函数以及所述待优化函数中的待优化语句的步骤具体包括:The code performance detection method of claim 1, wherein the function to be optimized in the objective function and the sentence to be optimized in the function to be optimized are determined according to the first performance data and the second performance data The specific steps include:
    获取所述第一性能数据中的函数执行次数与函数执行时间,并判断所述函数执行次数与函数执行时间是否分别超出预设第一阈值与预设第二阈值;Acquiring the number of function execution times and the function execution time in the first performance data, and determining whether the number of function execution times and the function execution time exceed a preset first threshold and a preset second threshold, respectively;
    若所述函数执行次数超出所述第一阈值且所述函数执行时间超出所述第二阈值,则判定超出所述第一阈值和第二阈值的数据所对应的函数为待优化函数;If the number of executions of the function exceeds the first threshold and the execution time of the function exceeds the second threshold, determining that the function corresponding to the data exceeding the first threshold and the second threshold is a function to be optimized;
    获取所述第二性能数据中与所述待优化函数对应的目标语句块执行次数,并判断所述目标语句块执行次数是否超出预设第三阈值;Acquiring the execution times of the target sentence block corresponding to the function to be optimized in the second performance data, and determining whether the execution times of the target sentence block exceeds a preset third threshold;
    若所述目标语句块执行次数超出所述第三阈值,则判定超出所述第三阈值的数据对应的语句为待优化语句。If the number of executions of the target sentence block exceeds the third threshold, it is determined that the sentence corresponding to the data exceeding the third threshold is a sentence to be optimized.
  6. 如权利要求1所述的代码性能检测方法,其中,所述在接收到性能检测指令时,获取待检测源码与预设性能统计代码,并确定所述待检测源码中的目标函数以及所述目标函数中的目标语句块的步骤具体包括:The code performance detection method according to claim 1, wherein when the performance detection instruction is received, the source code to be checked and the preset performance statistics code are obtained, and the target function and the target in the source code to be checked are determined The steps of the target sentence block in the function specifically include:
    在接收到所述性能检测指令时,获取所述性能检测指令中的原始代码,并判断所述原始代码中是否存在待执行函数;When receiving the performance detection instruction, obtain the original code in the performance detection instruction, and determine whether there is a function to be executed in the original code;
    若所述原始代码中存在所述待执行函数,则判定所述原始代码为所述待检测源码,并获取所述性能统计代码;If the function to be executed exists in the original code, determine that the original code is the source code to be tested, and obtain the performance statistics code;
    根据所述性能统计代码,确定所述目标函数与目标语句块。According to the performance statistics code, the target function and the target sentence block are determined.
  7. 如权利要求1所述的代码性能检测方法,其中,所述根据所述第一性能数据与第二性能数据,确定所述目标函数中的待优化函数以及所述待优化函数中的待优化语句的步骤之前,还包括:The code performance detection method of claim 1, wherein the function to be optimized in the objective function and the sentence to be optimized in the function to be optimized are determined according to the first performance data and the second performance data Before the steps, it also includes:
    根据预设权重、所述目标函数的函数执行次数与函数执行时间,生成每一目标函数的性能参考值,其中,所述函数执行次数与函数执行时间为所述第二性能数据;Generating a performance reference value for each objective function according to a preset weight, the number of executions of the function of the objective function, and the execution time of the function, wherein the number of executions of the function and the execution time of the function are the second performance data;
    按照所述性能参考值从高到低显示目标函数名称以及对应的函数执行次数与函数执行时间;Display the target function name and the corresponding function execution times and function execution time according to the performance reference value from high to low;
    按照目标语句块执行次数从大到小的顺序依次显示目标语句块名称以及对应的目标语句块执行次数,其中,所述目标语句块执行次数为所述第一性能数据。The target sentence block names and the corresponding target sentence block execution times are sequentially displayed in descending order of the target sentence block execution times, wherein the target sentence block execution times are the first performance data.
  8. 如权利要求1-7中任意一项所述的代码性能检测方法,其中,所述代码性能检测方法还包括:7. The code performance detection method according to any one of claims 1-7, wherein the code performance detection method further comprises:
    获取所述目标代码中的工具函数与所述性能统计代码中的性能统计函数,并将所述工具函数与性能统计函数作为统计工具函数;Acquiring the tool function in the target code and the performance statistical function in the performance statistical code, and use the tool function and the performance statistical function as the statistical tool function;
    将所述统计工具函数写入指定文件,以基于所述指定文件中的所述统计工具函数对下一待检测的代码进行性能数据统计。Write the statistical tool function into a designated file to perform performance data statistics on the next code to be tested based on the statistical tool function in the designated file.
  9. 一种代码性能检测装置,其中,所述代码性能检测装置包括:A code performance detection device, wherein the code performance detection device includes:
    函数语句确定模块,用于在接收到性能检测指令时,获取待检测源码与预设性能统计代码,并确定所述待检测源码中的目标函数以及所述目标函数中的目标语句块;The function sentence determination module is used to obtain the source code to be tested and the preset performance statistics code when the performance test instruction is received, and to determine the target function in the source code to be tested and the target sentence block in the target function;
    性能代码注入模块,用于基于所述目标函数与目标语句块在所述待检测源码中的目标位置信息,将所述性能统计代码注入所述待检测源码中的目标注入位置,将已注入的待检测源码作为目标代码;The performance code injection module is used to inject the performance statistics code into the target injection position in the source code to be tested based on the target function and target sentence block target location information in the source code to be tested, and the injected The source code to be tested is used as the target code;
    性能数据获取模块,用于执行所述目标代码,并基于所述性能统计代码中的执行统计代码与行计数统计代码,分别获取所述目标函数的第一性能数据与所述目标语句块的第二性能数据;The performance data acquisition module is configured to execute the target code, and obtain the first performance data of the target function and the first performance data of the target sentence block based on the execution statistics code and the line count statistics code in the performance statistics code. 2. Performance data;
    优化语句确定模块,用于根据所述第一性能数据与第二性能数据,确定所述目标函数中的待优化函数以及所述待优化函数中的待优化语句。The optimized sentence determination module is configured to determine the function to be optimized in the objective function and the sentence to be optimized in the function to be optimized according to the first performance data and the second performance data.
  10. 如权利要求9所述的代码性能检测装置,其中,所述代码性能检测装置还包括:9. The code performance detection device according to claim 9, wherein the code performance detection device further comprises:
    正则获取匹配模块,用于从所述性能统计代码中获取与所述目标函数相关的第一正则表达式以及与所述目标语句块对应的第二正则表达式,并将所述第一正则表达式与第二正则表达式逐行匹配所述待检测源码;The regular acquisition and matching module is used to acquire a first regular expression related to the target function and a second regular expression corresponding to the target sentence block from the performance statistics code, and express the first regular expression The formula matches the source code to be detected line by line with the second regular expression;
    第一正则匹配模块,用于在所述待检测源码中存在与所述第一正则表达式相匹配的第一部分代码时,判定所述第一部分代码为所述目标函数的执行语句,并根据所述执行语句确定所述目标函数;The first regular matching module is used to determine that the first part of the code is the execution sentence of the target function when there is a first part of the code matching the first regular expression in the source code to be detected, and according to the The execution sentence determines the objective function;
    第二正则匹配模块,用于在所述待检测源码中存在与所述第二正则表达式相匹配的第二部分代码时,判定所述第二部分代码为所述目标语句块。The second regular matching module is configured to determine that the second part of the code is the target sentence block when there is a second part of the code that matches the second regular expression in the source code to be detected.
  11. 如权利要求9所述的代码性能检测装置,其中,所述性能代码注入模块具体包括:9. The code performance detection device according to claim 9, wherein the performance code injection module specifically comprises:
    位置信息获取单元,用于获取所述执行语句的第一位置信息以及所述目标语句块的第二位置信息,将所述第一位置信息与第二位置信息作为所述目标位置信息;A location information acquiring unit, configured to acquire first location information of the execution sentence and second location information of the target sentence block, and use the first location information and the second location information as the target location information;
    注入位置确定单元,用于基于所述目标位置信息,确定所述执行统计代码与行计数统计代码分别对应的第一注入位置与第二注入位置,将所述第一注入位置与第二注入位置作为所述目标注入位置;The injection position determining unit is configured to determine, based on the target position information, a first injection position and a second injection position corresponding to the execution statistics code and the line count statistics code, respectively, and compare the first injection position and the second injection position As the target injection position;
    性能代码注入单元,用于将所述性能统计代码注入所述目标注入位置,将已注入待检测源码作为所述目标代码。The performance code injection unit is configured to inject the performance statistics code into the target injection location, and use the injected source code to be detected as the target code.
  12. 如权利要求11所述的代码性能检测装置,其中,所述代码性能检测装置还包括:11. The code performance detection device of claim 11, wherein the code performance detection device further comprises:
    特定语句判断模块,用于判断所述目标语句块中是否存在特定语句;The specific sentence judgment module is used to judge whether there is a specific sentence in the target sentence block;
    代码直接注入模块,用于若所述目标语句块中存在所述特定语句,则将所述特定语句所在的位置作为所述第二注入位置,并将所述行计数统计代码注入所述第二注入位置;The direct code injection module is configured to, if the specific sentence exists in the target sentence block, use the position of the specific sentence as the second injection position, and inject the line count statistics code into the second Injection position
    代码间接注入模块,用于若所述目标语句块中不存在所述特定语句,则在所述目标语句块中添加所述特定语句,并重复执行步骤:将所述特定语句所在的位置作为所述第二注入位置,并将所述行计数统计代码注入所述第二注入位置。The code indirect injection module is used to add the specific sentence to the target sentence block if the specific sentence does not exist in the target sentence block, and repeat the steps: take the location of the specific sentence as the target sentence block. The second injection position, and the row count statistical code is injected into the second injection position.
  13. 如权利要求9-12任一项所述的代码性能检测装置,其中,所述性能数据获取模块具体包括:The code performance detection device according to any one of claims 9-12, wherein the performance data acquisition module specifically comprises:
    函数数据判断单元,用于获取所述第一性能数据中的函数执行次数与函数执行时间,并判断所述函数执行次数与函数执行时间是否分别超出预设第一阈值与预设第二阈值;The function data judgment unit is configured to obtain the number of function execution times and the function execution time in the first performance data, and determine whether the number of function execution times and the function execution time exceed a preset first threshold and a preset second threshold, respectively;
    优化函数确定单元,用于若所述函数执行次数超出所述第一阈值且所述函数执行时间超出所述第二阈值,则判定超出所述第一阈值和第二阈值的数据所对应的函数为待优化函数;An optimized function determining unit, configured to determine the function corresponding to the data exceeding the first threshold and the second threshold if the number of executions of the function exceeds the first threshold and the execution time of the function exceeds the second threshold Is the function to be optimized;
    语句数据判断单元,用于获取所述第二性能数据中与所述待优化函数对应的目标语句块执行次数,并判断所述目标语句块执行次数是否超出预设第三阈值;A sentence data judgment unit, configured to obtain the execution times of the target sentence block corresponding to the function to be optimized in the second performance data, and judge whether the execution times of the target sentence block exceeds a preset third threshold;
    优化语句确定单元,用于若所述目标语句块执行次数超出所述第三阈值,则判定超出所述第三阈值的数据对应的语句为待优化语句。The optimized sentence determining unit is configured to determine that the sentence corresponding to the data exceeding the third threshold is a sentence to be optimized if the number of executions of the target sentence block exceeds the third threshold.
  14. 一种代码性能检测设备,其中,所述代码性能检测设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的代码性能检测程序,所述代码性能检测程序被所述处理器执行时实现如权利要求1至8中任一项所述的代码性能检测方法的步骤。A code performance testing device, wherein the code performance testing device includes a memory, a processor, and a code performance testing program stored on the memory and running on the processor, the code performance testing program being When the processor is executed, the steps of the code performance detection method according to any one of claims 1 to 8 are implemented.
  15. 一种计算机可读存储介质,其中,所述计算机可读存储介质上存储有代码性能检测程序,所述代码性能检测程序被处理器执行时实现如权利要求1至8中任一项所述的代码性能检测方法的步骤。A computer-readable storage medium, wherein a code performance detection program is stored on the computer-readable storage medium, and when the code performance detection program is executed by a processor, the method according to any one of claims 1 to 8 is realized. The steps of the code performance detection method.
PCT/CN2020/128337 2019-11-28 2020-11-12 Code performance testing method, apparatus and device, and storage medium WO2021104027A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911190460.4 2019-11-28
CN201911190460.4A CN110990271A (en) 2019-11-28 2019-11-28 Code performance detection method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2021104027A1 true WO2021104027A1 (en) 2021-06-03

Family

ID=70087789

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/128337 WO2021104027A1 (en) 2019-11-28 2020-11-12 Code performance testing method, apparatus and device, and storage medium

Country Status (2)

Country Link
CN (1) CN110990271A (en)
WO (1) WO2021104027A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110990271A (en) * 2019-11-28 2020-04-10 深圳前海微众银行股份有限公司 Code performance detection method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106201890A (en) * 2016-07-18 2016-12-07 腾讯科技(深圳)有限公司 The performance optimization method of a kind of application and server
CN108563555A (en) * 2018-01-10 2018-09-21 江苏工程职业技术学院 Failure based on four objective optimizations changes code prediction method
CN109885500A (en) * 2019-02-27 2019-06-14 苏州浪潮智能科技有限公司 A kind of method and system improving software test coverage rate
CN110990271A (en) * 2019-11-28 2020-04-10 深圳前海微众银行股份有限公司 Code performance detection method, device, equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106201890A (en) * 2016-07-18 2016-12-07 腾讯科技(深圳)有限公司 The performance optimization method of a kind of application and server
CN108563555A (en) * 2018-01-10 2018-09-21 江苏工程职业技术学院 Failure based on four objective optimizations changes code prediction method
CN109885500A (en) * 2019-02-27 2019-06-14 苏州浪潮智能科技有限公司 A kind of method and system improving software test coverage rate
CN110990271A (en) * 2019-11-28 2020-04-10 深圳前海微众银行股份有限公司 Code performance detection method, device, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
SONG YUANFENG: "Software Performance Analysis based on Reverse Engineering and Instrumentation Technology", CNKI MASTER'S THESES DATABASE, 1 May 2012 (2012-05-01), XP055814926 *

Also Published As

Publication number Publication date
CN110990271A (en) 2020-04-10

Similar Documents

Publication Publication Date Title
US8473915B2 (en) Coverage analysis tool for testing database-aware software applications
CN105787367B (en) A kind of the patch safety detecting method and system of software upgrading
US20090287729A1 (en) Source code coverage testing
US8732676B1 (en) System and method for generating unit test based on recorded execution paths
CN110059006B (en) Code auditing method and device
CN106529304B (en) A kind of Android applies concurrent leakage location
CN112579437B (en) Method for verifying conformity in program running process
KR101979329B1 (en) Method and apparatus for tracking security vulnerable input data of executable binaries thereof
US10241957B2 (en) Workload patterns for realistic load recreation in performance testing
WO2021104027A1 (en) Code performance testing method, apparatus and device, and storage medium
CN116541022A (en) Automatic PHP second-order vulnerability mining method based on semantic state diagram
CN114676061A (en) Knowledge graph-based automatic firmware detection method
Yuan et al. A method for detecting buffer overflow vulnerabilities
CN117992359B (en) Method and device for observing service software and electronic equipment
Ding et al. Identifying buffer overflow vulnerabilities based on binary code
US11816092B2 (en) System and method for automatic application log messages grouping using logging framework code instrumentation
CN109308256A (en) A kind of java dynamically analyzing of program method, equipment and storage medium
CN114490339B (en) Intelligent seed strategy method based on search test
Ashouri et al. Hybrid taint flow analysis in Scala
Zhou et al. ShadowBug: Enhanced Synthetic Fuzzing Benchmark Generation
Abajirov Exploring the adoption of Java version features and their relationship to software quality on GitHub
CN116340082A (en) RISCV application program dynamic analysis method and device based on hardware virtualization
CN118295915A (en) Interface standardization inspection method, platform and device for information system and electronic equipment
CN115658552A (en) Test data recommendation method and device, storage medium and electronic equipment
CN104462368A (en) Data calculating method, device and server

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20893862

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20893862

Country of ref document: EP

Kind code of ref document: A1