Program optimization suggestion generation method and device, electronic equipment and storage medium
By collecting and analyzing code programs and SQL statements in regression testing and generating optimization suggestions, the problem of testers' workload in the transformation of information and innovation is solved, rapid discovery and optimization are achieved, and the quality of code and SQL statements is improved.
Patent Information
- Application Number
- CN202411024392.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-12-06
AI Technical Summary
During the process of innovation and innovation transformation, database switching and program adjustments have caused testers to rely on regression testing and feedback, making it difficult to quickly discover programs that need to be optimized, resulting in a large amount of workload and the inability to quickly improve the quality of code programs and SQL statements.
By collecting code programs and SQL statements to be optimized during the regression testing process, performing static code analysis and SQL statement analysis, generating program optimization suggestions, reducing intrusion into the original system and improving universality.
Quickly discover code programs and SQL statements that need to be optimized, reduce the workload of testers, improve the quality of code programs and SQL statements, reduce intrusion into the original system, and improve universality.
Smart Images

Figure CN119088676A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software development and testing technology, and in particular to a method, device, electronic device and storage medium for generating program optimization suggestions. Background Art
[0002] During the information innovation transformation process, it may involve database switching and program adjustment. In the testing phase after the transformation, it mainly relies on regression testing and feedback from testers. Since the system involves many business functions to be transformed, the workload of testers may be heavy and they may not be able to quickly find programs that need to be optimized. Summary of the invention
[0003] The present application aims to solve one of the technical problems in the related art at least to some extent.
[0004] To this end, the first purpose of this application is to propose a method for generating program optimization suggestions, so as to quickly discover programs and SQL statements that need to be optimized and give optimization suggestions, thereby reducing the workload of testers and improving the quality of code programs and SQL statements.
[0005] The second objective of this application is to provide a device for generating program optimization suggestions.
[0006] The third objective of the present application is to provide an electronic device.
[0007] A fourth objective of the present application is to provide a computer-readable storage medium.
[0008] A fifth object of the present application is to provide a computer program product.
[0009] To achieve the above-mentioned purpose, the first embodiment of the present application proposes a method for generating program optimization suggestions, including:
[0010] In the process of regression testing the system to be tested, the code program to be optimized and the SQL statement to be optimized of the system to be tested are collected through the probe;
[0011] Performing code static analysis on the code program to be optimized to obtain a first optimization suggestion for the code program to be optimized;
[0012] Analyze the SQL statement to be optimized to obtain a second optimization suggestion for the SQL statement to be optimized;
[0013] A program optimization suggestion corresponding to the system to be tested is generated according to the first optimization suggestion and the second optimization suggestion.
[0014] To achieve the above-mentioned purpose, the second embodiment of the present application proposes a device for generating program optimization suggestions, including:
[0015] A collection module is used to collect the code program to be optimized and the SQL statement to be optimized of the system to be tested through a probe during the process of regression testing of the system to be tested;
[0016] A first acquisition module, configured to perform a code static analysis on the code program to be optimized to obtain a first optimization suggestion for the code program to be optimized;
[0017] A second acquisition module is used to analyze the SQL statement to be optimized to obtain a second optimization suggestion for the SQL statement to be optimized;
[0018] The first generating module is used to generate a program optimization suggestion corresponding to the system to be tested according to the first optimization suggestion and the second optimization suggestion.
[0019] To achieve the above-mentioned purpose, the third aspect of the present application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0020] The memory stores computer-executable instructions;
[0021] The processor executes the computer-executable instructions stored in the memory to implement the method as described in the embodiment of the first aspect.
[0022] To achieve the above-mentioned purpose, the fourth aspect embodiment of the present application proposes a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by a processor, they are used to implement the method described in the first aspect embodiment.
[0023] To achieve the above-mentioned purpose, the fifth aspect of the present application proposes a computer program product, including a computer program, which implements the method described in the first aspect when executed by a processor.
[0024] The method, device, electronic device and storage medium for generating program optimization suggestions provided by the present application collect and analyze the code program and SQL statement to be optimized when performing regression testing on the system to be tested, and obtain optimization suggestions. Thus, by performing code program and SQL statement detection and optimization in conjunction with regression testing, the code program and SQL statement that need to be optimized can be quickly found, and the quality of the code program and SQL statement can be improved while reducing the workload of testers. In addition, by collecting the code program and SQL statement that need to be optimized through the probe, the intrusion into the original system can be greatly reduced, and the versatility can be improved.
[0025] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0027] Figure 1 A flowchart of a method for generating program optimization suggestions provided in an embodiment of the present application;
[0028] Figure 2 A flowchart of another method for generating program optimization suggestions provided in an embodiment of the present application;
[0029] Figure 3 A flowchart of another method for generating program optimization suggestions provided in an embodiment of the present application;
[0030] Figure 4 A process diagram of an automatic regression testing and program optimization method provided in an embodiment of the present application;
[0031] Figure 5 A schematic diagram of the specific execution process of the SQL statement optimization model provided in the embodiment of the present application;
[0032] Figure 6 A schematic diagram of a device for generating program optimization suggestions provided in an embodiment of the present application and
[0033] Figure 7 It is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0034] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0035] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0036] The data acquisition, transmission, storage, use, and processing in the technical solution of this application are in compliance with the provisions of national laws and regulations.
[0037] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0038] The following describes a method and device for generating program optimization suggestions according to an embodiment of the present application with reference to the accompanying drawings.
[0039] Figure 1 A flowchart of a method for generating program optimization suggestions provided in an embodiment of the present application.
[0040] During the information innovation transformation process, it may involve database switching and program adjustment. In the testing phase after the transformation, it mainly relies on regression testing and feedback from testers. Since the system involves many business functions to be transformed, the workload of testers may be heavy and they may not be able to quickly find programs that need to be optimized.
[0041] To address this problem, an embodiment of the present application provides a method for generating program optimization suggestions, so as to quickly discover programs and SQL statements that need to be optimized and provide optimization suggestions, thereby reducing the workload of testers and improving the quality of code programs and SQL statements.
[0042] like Figure 1 As shown, the method for generating program optimization suggestions includes the following steps:
[0043] Step 101 , during the process of regression testing the system to be tested, the code program to be optimized and the SQL statement to be optimized of the system to be tested are collected through a probe.
[0044] In this embodiment, the system to be tested may be a system obtained by updating the code of an old system, and the regression test on the system to be tested may include performing an interface regression test on the system to be tested.
[0045] For example, when business personnel perform iterative testing, request message logs can be generated in the server directory. Therefore, the request message logs of the old system corresponding to the system to be tested can be collected, and the interface request messages can be obtained from the request message logs. By sending interface request messages to each interface in the system to be tested, regression testing can be performed on the system to be tested.
[0046] Exemplarily, in the test environment where the system to be tested is located, the interface request message in the request message log can be replayed to obtain the interface response message corresponding to the interface. By comparing the interface response message with the reference response message, it is determined whether the interface call is successful, thereby implementing regression testing of the test system, wherein the reference response message can be the message obtained by the old system in response to the interface request message.
[0047] Exemplarily, the request message obtained from the request message log can be cleaned to retain complete business message data, that is, to obtain the interface request message for subsequent automatic initiation of the interface request to perform regression testing on the system to be tested.
[0048] In this embodiment, a probe can be configured in the program of the system to be tested, and it can be determined that during the process of regression testing of the system to be tested, the execution status of the regression test and the execution time of the database corresponding to the system to be tested are monitored by the probe, and the code program to be optimized and the SQL statement to be optimized in the system to be tested are collected. Among them, the database corresponding to the system to be tested stores the data used and generated by the system to be tested in the process of processing the interface request message.
[0049] For example, if the system to be tested is a system written in Java programming language, a Java probe can be used to collect the Java program to be optimized and the SQL statement to be optimized.
[0050] Exemplarily, the code program to be optimized may be a code program corresponding to a target interface, such as an interface whose response time is greater than a first preset time, or a preset interface, or an interface that meets other conditions.
[0051] Exemplarily, the SQL statement to be optimized may be a SQL statement that executes a preset operation such as an insert operation or a modify operation, or a SQL statement whose execution time is greater than a second preset time, or a SQL statement that meets other conditions.
[0052] Step 102: Perform code static analysis on the code program to be optimized to obtain a first optimization suggestion for the code program to be optimized.
[0053] In this embodiment, the code static analysis may include, but is not limited to, determining the number of code lines of the code program to be optimized, the amount of calculation in the loop body, the keywords or operators used to concatenate strings, and the like.
[0054] Exemplarily, the first optimization suggestion can be obtained by determining which aspects can be optimized and the corresponding optimization suggestions based on the results of the static analysis of the code program to be optimized. For example, if the number of lines of code in the code program to be optimized exceeds a preset number of lines, the first optimization suggestion may include a suggestion to reduce the number of lines of code; if the amount of calculation in the loop body of the code program to be optimized is greater than the preset amount of calculation, the first optimization suggestion may include a suggestion to reduce conditional judgments, avoid creating objects in the loop body, and consider reducing the number of accesses if the loop body needs to read data from external resources.
[0055] Step 103: Analyze the SQL statement to be optimized to obtain a second optimization suggestion for the SQL statement to be optimized.
[0056] In this embodiment, the SQL statement to be optimized can be analyzed from the aspects of whether the SQL statement to be optimized hits the index, whether operator sinking is used, whether table analysis is required, the time consumption of table connection after the keyword from, whether there is a subquery in the keyword select, etc., and the second optimization suggestion is determined according to the analysis result.
[0057] For example, if a field in a data table in the database does not hit the index, the second optimization suggestion may include a suggestion to add a suitable index for the field to improve query efficiency. If there is a subquery in the keyword select, then look at the data volume of the subquery. If the data volume of the subquery is too large, the second optimization suggestion may include a suggestion to optimize the subquery to reduce the data volume of the subquery.
[0058] Step 104: Generate a program optimization suggestion corresponding to the system to be tested according to the first optimization suggestion and the second optimization suggestion.
[0059] In this embodiment, the program optimization suggestions corresponding to the system to be tested may include a first optimization suggestion for the code program to be optimized, a second optimization suggestion for the SQL statement to be optimized, and may also include version information of the system to be tested, the name or identifier of the program file to which the code program to be optimized belongs, the program file to which the SQL statement to be optimized belongs, the position of the SQL statement to be optimized in the program file to which it belongs, etc.
[0060] Exemplarily, program optimization suggestions may be generated in the form of a report.
[0061] In an embodiment of the present application, during the process of regression testing the system to be tested, the code program to be optimized and the SQL statement to be optimized are collected by a probe, and a code static analysis is performed on the code program to be optimized to obtain a first optimization suggestion for the code program to be optimized, and the SQL statement to be optimized is analyzed to obtain a second optimization suggestion for the SQL statement to be optimized, and then a program optimization suggestion corresponding to the system to be tested is generated based on the first optimization suggestion and the second optimization suggestion. Thus, when the system to be tested is subjected to regression testing, the code program to be optimized and the SQL statement to be optimized are collected and analyzed to obtain optimization suggestions, so that the code program and SQL statement detection and optimization are performed in conjunction with the regression test, so that the code program and SQL statement that need to be optimized can be quickly found, and the quality of the code program and SQL statement can be improved while reducing the workload of the tester. In addition, the code program and SQL statement that need to be optimized are collected by the probe, which can greatly reduce the intrusion into the original system and improve the versatility.
[0062] Figure 2 A flowchart of another method for generating program optimization suggestions provided in an embodiment of the present application.
[0063] like Figure 2 As shown, the method for generating program optimization suggestions may include the following steps:
[0064] Step 201 , during the process of regression testing the system to be tested, the code program to be optimized and the SQL statement to be optimized of the system to be tested are collected through a probe.
[0065] In this embodiment, step 201 can be implemented in any of the embodiments of the present application, so it will not be described in detail here.
[0066] Exemplarily, the probe can be used to count the response time of each interface in the system to be tested and the execution time of each SQL statement used to access the database corresponding to the system to be tested. If the response time of any interface is longer than a first preset time, the code program corresponding to the interface can be obtained, and the code program corresponding to the interface can be determined as the code program to be optimized. If the execution time of any SQL statement is longer than a second preset time, the SQL statement can be determined as a SQL statement to be optimized.
[0067] Therefore, the code program corresponding to the interface with a slower response can be used as the code program to be optimized, and the SQL statement with a longer execution time can be used as the SQL statement to be optimized, so as to achieve the optimization of the code program corresponding to the interface with a slower response and the SQL statement with a longer execution time, thereby improving the interface response speed and the efficiency of accessing the database.
[0068] Step 202: Perform code static analysis on the code program to be optimized to obtain a first optimization suggestion for the code program to be optimized.
[0069] In this embodiment, step 202 can be implemented in any of the embodiments of the present application, so it will not be described in detail here.
[0070] Exemplarily, static analysis can be performed on the code in the code program to be optimized to obtain code analysis results, and based on the code optimization rules corresponding to the programming language used by the code program to be optimized, the items to be optimized in the code analysis results and the optimization suggestions corresponding to the items to be optimized can be determined, and then based on the optimization suggestions corresponding to the items to be optimized, the first optimization suggestion can be obtained.
[0071] For example, the code optimization rules include optimization items and corresponding optimization suggestions. Each analysis result in the code analysis result can be matched with the code optimization rules to determine the items to be optimized in the code analysis result and the optimization suggestions corresponding to the items to be optimized.
[0072] For example, if the number of lines of code is greater than the preset number of lines, the optimization suggestions include suggestions on how to streamline the code. For another example, if there are potential risks, the optimization suggestions include suggestions on how to avoid potential risks, such as the risk of program crash or data loss due to improper exception handling, and the optimization suggestions include suggestions on how to reasonably handle the exception.
[0073] Therefore, based on the code analysis results and the code optimization rules corresponding to the programming language used, the items to be optimized and the corresponding optimization suggestions are determined, thereby improving the accuracy and optimization effect of program optimization.
[0074] Step 203 , by calling the database corresponding to the system to be tested, the execution plan statement of the SQL statement to be optimized is executed to obtain the execution plan corresponding to the SQL statement to be optimized.
[0075] The execution plan corresponding to the SQL statement to be optimized may refer to the relevant information of the execution process of the SQL statement to be optimized provided by the database. For example, the execution plan corresponding to the SQL statement to be optimized may include but is not limited to information such as how the SQL statement to be optimized intends to find data, whether to use indexes, and how many rows of data are expected to be scanned.
[0076] In this embodiment, the data table to be accessed by the SQL statement to be optimized in the database corresponding to the system to be tested may be called, and a plan statement may be executed on the SQL statement to be optimized to obtain an execution plan corresponding to the SQL statement to be optimized.
[0077] For example, the plan statement is an explain statement, which is used to obtain the execution plan of a SQL statement. When explain is used on a SQL statement, the database does not actually execute the SQL statement, but returns the execution plan of the SQL statement.
[0078] In order to improve accuracy, before obtaining the execution plan of the SQL statement to be optimized, the syntax of the SQL statement to be optimized can be verified for correctness. When the syntax of the SQL statement to be optimized is verified to be correct, the execution plan of the SQL statement to be optimized can be obtained, thereby improving the accuracy of subsequent operations.
[0079] Step 204: parse the SQL statement to be optimized to obtain a syntax tree of the SQL statement to be optimized.
[0080] In this embodiment, the syntax tree may be an abstract syntax tree, and an open source syntax analyzer generation tool may be used to parse the SQL statement to be optimized to obtain the abstract syntax tree of the SQL statement to be optimized. The node types of the abstract syntax tree mainly include three abstract types: SQLObject, SQLExpr, and SQLStatement.
[0081] It should be noted that step 204 and step 205 may be executed in the above order, or step 204 may be executed first and then step 205, or step 204 and step 205 may be executed in parallel. This application does not limit the execution order of step 204 and step 205.
[0082] Step 205: Obtain a second optimization suggestion according to the execution plan and the syntax tree.
[0083] In this embodiment, the execution plan can be analyzed to determine the first optimization condition satisfied by the SQL statement to be optimized, and the optimization suggestion corresponding to the first optimization condition can be obtained. The syntax tree can be analyzed to obtain the second optimization condition satisfied by the SQL statement to be optimized, and the optimization suggestion corresponding to the second optimization condition can be obtained. Then, based on the optimization suggestion corresponding to the first optimization condition and the optimization suggestion corresponding to the second optimization condition, the second optimization suggestion can be obtained.
[0084] For example, the execution plan can be analyzed from aspects such as index usage, operator sinking usage, table scanning, and whether table analysis is required to determine the first optimization condition satisfied by the SQL statement to be optimized, and obtain optimization suggestions corresponding to the first optimization condition. Among them, multiple first optimization conditions can be preset, and each first optimization condition has a corresponding optimization suggestion.
[0085] For example, you can check whether there is prompt information in the execution plan that the target field of the target data table in the database is not hit. If such prompt information exists, it can be determined that the SQL statement to be optimized does not hit the index, and the corresponding optimization suggestion can be to add a suitable index for the target field that does not hit the index.
[0086] For example, it is possible to determine whether there is an aggregate function in the SQL statement to be optimized by analyzing the execution plan. If there is an aggregate function in the SQL statement to be optimized, it is determined whether operator sinking is used. If the SQL statement to be optimized does not use operator sinking, the SQL statement to be optimized meets the first optimization condition of not using operator sinking, and the corresponding optimization suggestion can be to suggest optimizing the SQL statement to be optimized, adjusting the expression, and adding an order by clause. Operator sinking is an important query optimization technology, which refers to moving certain query operations (or "operators") as far as possible to the data source or the early stage of query processing.
[0087] Exemplarily, the operation type, index usage, expected number of scan rows, etc. in the execution plan are analyzed. If the execution plan satisfies one or more of the following conditions, including the preset operation type, the use of indexes in the execution plan, and the difference between the expected number of scan rows and the number of rows in the target data table in the database is less than the first threshold, it can be determined that the SQL statement to be optimized meets the first optimization condition for performing a full table scan, and the corresponding optimization suggestion can be a suggestion to add a query condition.
[0088] For example, the preset operation type is "TABLE SCAN" or "FULL TABLE SCAN", and a step in the execution plan is marked as "TABLE SCAN" or "FULL TABLE SCAN", which directly indicates that the entire target data table is scanned.
[0089] In addition, if the difference between the estimated number of scan rows and the number of rows in the target data table in the database is less than the first threshold, it can be considered that the estimated number of scan rows is close to the number of rows in the target data table to be scanned, and it can be determined to perform a full table scan on the target data table.
[0090] In addition, you can also analyze the filter conditions in the execution plan. If the filter conditions cannot effectively use the index, or the filter conditions are evaluated to be valid for all rows, it can be considered that a full scan occurs in the execution plan.
[0091] Exemplarily, the number of insert operations or delete operations in the execution plan can be analyzed. If the number of insert operations or delete operations in the execution plan is greater than the second threshold, it can be determined that the SQL statement to be optimized meets the first optimization condition that requires table analysis, and the corresponding optimization suggestion can be to perform table analysis and timely update the table metadata information.
[0092] For example, Table 1 shows that the execution plan can be analyzed from several aspects and the corresponding optimization suggestions for each aspect.
[0093] Table 1
[0094]
[0095] Therefore, the execution plan can be analyzed from multiple aspects to determine the first optimization condition satisfied by the SQL statement to be optimized, and based on the optimization suggestion corresponding to the first optimization condition, the second optimization suggestion can be obtained, thereby analyzing the execution plan and giving corresponding optimization suggestions, thereby improving the accuracy of the optimization suggestions for the SQL statement to be optimized, and further improving the quality of the SQL statement.
[0096] Exemplarily, the number of operation objects specified by preset keywords in the syntax tree can be determined. If the number of specified operation objects is greater than the third threshold, it means that the table connection after from takes a long time. It can be determined that the SQL statement to be optimized meets the second optimization condition that the operation object time consumption does not meet the requirement, and the corresponding optimization suggestion can be a suggestion to optimize the table connection. The preset keyword can be the from keyword.
[0097] Exemplarily, the retrieval item specified keyword in the syntax tree is analyzed to see whether it contains a subquery. If it contains a subquery, the data volume of the subquery is determined. If the retrieval item specified keyword contains a subquery and the data volume of the subquery is greater than a fourth threshold, it can be determined that the SQL statement to be optimized meets the second optimization condition that the subquery data volume does not meet the requirement. The corresponding optimization suggestion can be a suggestion to optimize the subquery to reduce the subquery data volume.
[0098] Exemplarily, it is determined whether there is a function aggregation node in the syntax tree and the type of the database is determined. If there is a function aggregation node in the syntax tree and the database is of a preset type, it is determined that the SQL statement to be optimized meets the second optimization condition of using the preset function, and the corresponding optimization suggestion can be a suggestion to modify the expression statement. For example, the preset type is tidb, and the preset function can be a recursive function, a max function, or a min function, etc.
[0099] Exemplarily, the number of valid parameters can be determined by traversing the parameter nodes in the syntax tree. If the number of valid parameters is less than the fifth threshold, a full table scan is likely to occur. It can be determined that the SQL statement to be optimized meets the second optimization condition that the parameter transfer is unreasonable. The corresponding optimization suggestion can be a suggestion to optimize the SQL statement parameter transfer.
[0100] For example, Table 2 shows that the syntax tree can be analyzed from several aspects and the corresponding optimization suggestions for each aspect.
[0101] Table 2
[0102]
[0103] Therefore, the syntax tree of the SQL statement to be optimized can be analyzed from multiple aspects, the second optimization condition satisfied by the SQL statement to be optimized can be determined, and the second optimization suggestion can be obtained based on the optimization suggestion corresponding to the second optimization condition, so as to analyze the SQL statement from the grammatical perspective and give corresponding optimization suggestions, thereby improving the accuracy of the optimization suggestions for the SQL statement to be optimized, and further improving the quality of the SQL statement.
[0104] Step 206: Generate a program optimization suggestion corresponding to the system to be tested according to the first optimization suggestion and the second optimization suggestion.
[0105] In this embodiment, step 206 can be implemented in any of the embodiments of the present application, so it will not be described in detail here.
[0106] In the embodiment of the present application, by obtaining the execution plan and syntax tree of the SQL statement to be optimized, the execution plan and syntax tree are analyzed respectively to obtain corresponding optimization suggestions, and then the final optimization suggestions for the SQL statement to be optimized are obtained based on the optimization suggestions based on the execution plan and the optimization suggestions based on the syntax tree. Thus, by analyzing the SQL statement to be optimized from two directions, the execution plan and syntax tree, the optimization suggestions for the SQL statement to be optimized are more comprehensive, which can effectively improve the quality of the SQL statement.
[0107] Figure 3 A flowchart of another method for generating program optimization suggestions provided in an embodiment of the present application.
[0108] like Figure 3 As shown, the method for generating program optimization suggestions may include the following steps:
[0109] Step 301: monitor changes in a database corresponding to the system to be tested through a timer.
[0110] In this embodiment, the database corresponding to the system to be tested may be polled by a timer to monitor whether the database has changed.
[0111] For example, if the timer is triggered, the table structure and table data of each data table in the database can be queried by executing SQL statements to obtain the current query result of the database, and the current query result is compared with the previous query result of the database to determine whether the database has changed. If the current query result is different from the previous query result of the database, the database has changed; if the current query result is the same as the previous query result of the database, the database has not changed.
[0112] Exemplarily, the change in the database may include that the current table structure of the database is changed compared with the previous polling and / or the current table data of the database is changed compared with the previous polling.
[0113] Therefore, by monitoring whether the table structure and table data of the database have changed, the change of the database is monitored, thereby improving the accuracy of monitoring.
[0114] Step 302: In response to monitoring changes in the database, regression testing is performed on the system to be tested.
[0115] In this embodiment, if a change in the database is detected, a regression test task can be automatically triggered to automatically perform regression testing on the system to be tested. For example, if the table structure and / or table data of the database changes, a regression test case corresponding to the corresponding table can be automatically triggered to perform regression testing.
[0116] Step 303: during the regression test of the system to be tested, the code program to be optimized and the SQL statement to be optimized of the system to be tested are collected through the probe.
[0117] In this embodiment, step 303 can be implemented in any of the embodiments of the present application, so it will not be described in detail here.
[0118] Step 304: Perform code static analysis on the code program to be optimized to obtain a first optimization suggestion for the code program to be optimized.
[0119] In this embodiment, step 304 can be implemented in any of the embodiments of the present application, so it will not be described in detail here.
[0120] Step 305: Analyze the SQL statement to be optimized to obtain a second optimization suggestion for the SQL statement to be optimized.
[0121] In this embodiment, step 305 can be implemented in any of the embodiments of the present application, so it will not be described in detail here.
[0122] Step 306: Generate a program optimization suggestion corresponding to the system to be tested according to the first optimization suggestion and the second optimization suggestion.
[0123] In this embodiment, step 306 can be implemented in any of the embodiments of the present application, so it will not be described in detail here.
[0124] In the embodiment of the present application, the database corresponding to the system under test can be monitored through a timer. If changes in the database are monitored, regression testing can be automatically performed on the system under test, thereby realizing automated regression testing of the system under test, improving testing efficiency, reducing the workload of testers, and providing optimization suggestions for code programs and SQL statements during automated regression testing of the system under test, thereby reducing the workload of testers and improving the quality of code programs and SQL statements.
[0125] In one embodiment of the present application, based on the above embodiment, the regression test results of the system to be tested can be obtained according to the comparison results between the interface response message of the system to be tested and the reference response message, and then a target report can be generated according to the regression test results and program optimization suggestions.
[0126] The target report may include regression test results, program optimization suggestions, request time consumption, data comparison results, target interface, SQL statements to be optimized, etc. The target interface may refer to the interface corresponding to the code program to be optimized.
[0127] In this way, the results of regression testing and program optimization can be compiled into a regression testing and optimization suggestion report for system administrators, developers, and testers to read and make improvements based on the optimization suggestions.
[0128] In order to facilitate understanding of the method for generating program optimization suggestions of the present application, taking Java as an example, the programming language used by the system to be tested is Figure 4 To explain, Figure 4 A process diagram of an automatic regression testing and program optimization method provided in an embodiment of the present application.
[0129] 1. Log message collection
[0130] When business personnel perform iterative testing, request message logs will be generated in the server directory. The program will collect these request messages, and after cleaning, retain the complete business message data for subsequent automatic request initiation.
[0131] 2. Configure the Java probe
[0132] Using Java ASM bytecode enhancement technology, a monitoring and statistical Java probe is developed. The Java probe is configured in programs that require automated regression testing and SQL statement optimization. The probe can monitor the execution status of automated regression testing, the execution time of the database, and collect interfaces with response times longer than the first preset time, SQL statements with execution times longer than the second preset time, etc. At the same time, through Java probe technology, the intrusion into the original system can be greatly reduced and the versatility can be improved.
[0133] 3. Java program optimization model
[0134] For interfaces whose response time exceeds, for example, 20 seconds, the probe will collect the interfaces and the corresponding Java programs, and then submit them to the Java program optimization model. After static code analysis, the optimization model will give optimization suggestions based on the rules and finally summarize them in the interface test report.
[0135] 4. SQL statement optimization model
[0136] For example, if the SQL statement takes more than 10 seconds to execute, the probe will capture it, record its mybatismapper id in the system, and send it to the SQL statement optimization module. The optimization suggestions can be integrated into the SQL statement optimization model so that the execution time of most SQL statements to be optimized can be controlled within 10 seconds, achieving better actual optimization results. The SQL statement to be optimized can be a SQL statement with an execution time of more than 10 seconds. The specific execution process of the SQL statement optimization model can be as follows: Figure 5 As shown in the figure, the probe collects the SQL statements to be optimized, and then verifies whether the SQL statement syntax is correct. If it is correct, it automatically executes explain, obtains the execution plan, analyzes the execution plan, obtains optimization suggestions, and parses the SQL syntax tree to give optimization suggestions. For details, please refer to the description in 5.2 below.
[0137] 5. Application of SQL statement optimization model
[0138] 5.1 Monitor database changes and automatically schedule regression testing tasks
[0139] The SQL statement optimization model can monitor the changes in the database table structure and table data, and cooperate with the backend timer to automatically manage and schedule regression testing tasks.
[0140] You can use the table structure and data difference timer to check whether the table structure and table data in the database have changed compared to the last polling by periodic polling. If there is a change, the regression test case corresponding to the corresponding table will be automatically triggered. The main implementation steps are as follows:
[0141] (1) Use a timer in the backend service to poll the database regularly.
[0142] (2) When the timer is triggered, the SQL statement is executed to query the table structure and table data in the database, and the query results are compared with the last saved results to determine whether there are any changes.
[0143] (3) If the data changes, the backend service is notified to automatically adjust the regression test cases and automatically execute regression tests to ensure the correctness and consistency of the database after the change.
[0144] 5.2 Dynamic Analysis and Optimization of SQL Statements
[0145] (1) Verify SQL syntax
[0146] You can use the tidb syntax tree to check the syntax correctness of SQL statements.
[0147] (2) Automatically execute explain and obtain the execution plan
[0148] You can call the tidb database to automatically execute explain, obtain the execution plan, and analyze the contents of the execution plan. For example, you can analyze and judge according to the contents of Table 1 and give optimization suggestions.
[0149] (3) Parsing the SQL syntax tree
[0150] You can parse SQL statements and use open source parser generation tools, such as antlr4, to generate an abstract syntax tree. The abstract syntax tree node types mainly include three abstract types: SQLObject, SQLExpr, and SQLStatement. Then, based on the parsed abstract syntax tree node content, analyze and judge according to the content in Table 2, and give optimization suggestions.
[0151] It should be noted that obtaining optimization suggestions through execution plan and obtaining optimization suggestions through parsing SQL statement tree can be performed in parallel.
[0152] 6. Regression testing and optimization suggestion report
[0153] The above regression test results, request time, data comparison, interfaces with response time longer than the first preset time, SQL statements with execution time longer than the second preset time, etc. can be recorded. At the same time, for interfaces with response time longer than the first preset time and SQL statements with execution time longer than the second preset time, the Java program optimization model and SQL statement optimization model can be called for in-depth analysis, and reasonable and effective optimization suggestions can be given. Finally, the results of regression testing and program optimization are organized into a regression testing and optimization suggestion report for system administrators, developers and testers to read and make improvements based on the optimization suggestions. Among them, the regression testing and optimization suggestion report can be understood as the above target report.
[0154] In order to implement the above embodiment, the present application also proposes a device for generating program optimization suggestions.
[0155] Figure 6 A schematic diagram of the structure of a device for generating program optimization suggestions provided in an embodiment of the present application.
[0156] like Figure 6As shown, the device 600 for generating program optimization suggestions includes:
[0157] The collection module 610 is used to collect the code program to be optimized and the SQL statement to be optimized of the system to be tested through the probe during the regression test of the system to be tested;
[0158] A first acquisition module 620, configured to perform a code static analysis on the code program to be optimized to obtain a first optimization suggestion for the code program to be optimized;
[0159] A second acquisition module 630 is used to analyze the SQL statement to be optimized to obtain a second optimization suggestion for the SQL statement to be optimized;
[0160] The first generating module 640 is used to generate a program optimization suggestion corresponding to the system to be tested according to the first optimization suggestion and the second optimization suggestion.
[0161] Furthermore, in a possible implementation of the embodiment of the present application, the second acquisition module 630 is configured to:
[0162] By calling the database corresponding to the system to be tested, executing the plan statement for the SQL statement to be optimized, so as to obtain the execution plan corresponding to the SQL statement to be optimized;
[0163] Analyze the execution plan to determine a first optimization condition satisfied by the SQL statement to be optimized;
[0164] Parsing the SQL statement to be optimized to obtain a syntax tree of the SQL statement to be optimized;
[0165] Parsing the syntax tree to determine a second optimization condition satisfied by the SQL statement to be optimized;
[0166] The second optimization suggestion is obtained according to the optimization suggestion corresponding to the first optimization condition and the optimization suggestion corresponding to the second optimization condition.
[0167] Furthermore, in a possible implementation of the embodiment of the present application, the second acquisition module 630 is configured to:
[0168] In response to prompt information that the execution plan does not hit a target field of a target data table in the database, determining that the first optimization condition includes that the SQL statement to be optimized does not hit an index; and / or,
[0169] In response to the execution plan satisfying one or more of the following: the execution plan includes a preset operation type, an index is used, and the difference between the expected number of scanned rows and the number of rows of the target data table in the database is less than a first threshold, determining that the first optimization condition includes performing a full table scan; and / or,
[0170] In response to the number of insert operations or delete operations in the execution plan being greater than a second threshold, determining that the first optimization condition includes the need to perform table analysis.
[0171] Furthermore, in a possible implementation of the embodiment of the present application, the second acquisition module 630 is configured to:
[0172] Determining the number of operation objects specified by preset keywords in the syntax tree, and in response to the number of specified operation objects being greater than a third threshold, determining that the second optimization condition includes that the operation object time consumption does not meet the requirement; and / or,
[0173] In response to the search item specified keyword in the syntax tree including a subquery and the data volume of the subquery being greater than a fourth threshold, determining that the second optimization condition includes that the data volume of the subquery does not meet the requirement; and / or,
[0174] In response to the presence of a function aggregation node in the syntax tree and the database being of a preset type, determining that the second optimization condition includes using a preset function; and / or,
[0175] The number of valid parameters is determined by traversing the parameter nodes in the syntax tree, and in response to the number of valid parameters being less than a fifth threshold, it is determined that the second optimization condition includes unreasonable transmission of parameters.
[0176] Furthermore, in a possible implementation of the embodiment of the present application, the acquisition module 610 is used to:
[0177] By using the probe, statistics are collected on the response time of each interface in the system to be tested and the execution time of each SQL statement used to access the database corresponding to the system to be tested;
[0178] In response to a response time length of any interface being longer than a first preset time length, obtaining a code program corresponding to the any interface, and determining the code program corresponding to the any interface as the code program to be optimized;
[0179] In response to the execution time of any one of the SQL statements being greater than a second preset time, determining that the any one of the SQL statements is the SQL statement to be optimized.
[0180] Furthermore, in a possible implementation of the embodiment of the present application, the first acquisition module 620 is configured to:
[0181] Performing static analysis on the code in the code program to be optimized to obtain a code analysis result;
[0182] Determine the items to be optimized in the code analysis result and the optimization suggestions corresponding to the items to be optimized according to the code optimization rules corresponding to the programming language used by the code program to be optimized;
[0183] The first optimization suggestion is obtained according to the optimization suggestion corresponding to the item to be optimized.
[0184] Furthermore, in a possible implementation of the embodiment of the present application, the device may also include:
[0185] A monitoring module, used to monitor changes in the database corresponding to the system to be tested through a timer;
[0186] The testing module is used to perform regression testing on the system to be tested in response to monitoring changes in the database.
[0187] Furthermore, in a possible implementation of the embodiment of the present application, the monitoring module is used to:
[0188] In response to the timer being triggered, querying the table structure and table data of each data table in the database to obtain the current query result of the database;
[0189] In response, the current query result is compared with a previous query result of the database to determine whether the database has changed.
[0190] Furthermore, in a possible implementation of the embodiment of the present application, it also includes:
[0191] A third acquisition module is used to collect the request message log of the old system corresponding to the system to be tested, and obtain the interface request message from the request message log;
[0192] The testing module is used to perform regression testing on the system to be tested by sending the interface request message.
[0193] Furthermore, in a possible implementation of the embodiment of the present application, the device further includes:
[0194] A fourth acquisition module, used for acquiring a regression test result of the system to be tested according to a comparison result between the interface response message of the system to be tested and the reference response message;
[0195] The second generating module is used to generate a target report according to the regression test results and the program optimization suggestions.
[0196] It should be noted that the above explanations and descriptions of the embodiment of the method for generating program optimization suggestions are also applicable to the device for generating program optimization suggestions of this embodiment, and will not be repeated here.
[0197] In an embodiment of the present application, when performing regression testing on the system to be tested, the code program to be optimized and the SQL statement to be optimized are collected and analyzed to obtain optimization suggestions, so that by cooperating with the regression test to perform code program and SQL statement detection and optimization, the code program and SQL statement that need to be optimized can be quickly found, and the quality of the code program and SQL statement can be improved while reducing the workload of testers. In addition, by collecting the code program and SQL statement that need to be optimized through the probe, the intrusion into the original system can be greatly reduced and the versatility can be improved. In order to realize the above embodiment, the present application also proposes an electronic device, including: a processor, and a memory connected to the processor in communication; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory to implement the method provided by the above embodiment.
[0198] In order to implement the above embodiments, the present application also proposes an electronic device, comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method provided by the above embodiments.
[0199] As an example, Figure 7 is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of the present disclosure, such as Figure 7 As shown, the electronic device 700 may further include:
[0200] The memory 710 and the processor 720, a bus 730 connecting different components (including the memory 710 and the processor 720), the memory 710 stores a computer program, and when the processor 720 executes the program, the information collection method described in the embodiment of the present disclosure is implemented.
[0201] Bus 730 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.
[0202] The electronic device 700 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by the electronic device 700, including volatile and non-volatile media, removable and non-removable media.
[0203] The memory 710 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 740 and / or cache memory 750. The electronic device 700 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 760 may be used to read and write non-removable, non-volatile magnetic media ( Figure 7 not shown, usually called a "hard drive"). Although Figure 7 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 730 via one or more data medium interfaces. The memory 710 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present disclosure.
[0204] A program / utility 780 having a set (at least one) of program modules 770 may be stored, for example, in the memory 710, such program modules 770 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 770 generally perform the functions and / or methods of the embodiments described in the present disclosure.
[0205] The electronic device 700 may also communicate with one or more external devices 790 (e.g., keyboard, pointing device, display 791, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 700, and / or communicate with any device that enables the electronic device 700 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 792. Furthermore, the electronic device 700 may also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) through a network adapter 793. As shown, the network adapter 793 communicates with other modules of the electronic device 700 through a bus 730. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0206] The processor 720 executes various functional applications and data processing by running the programs stored in the memory 710 .
[0207] In order to implement the above embodiments, the present application also proposes a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the methods provided by the above embodiments.
[0208] In order to implement the above embodiments, the present application also proposes a computer program product, including a computer program, which implements the methods provided by the above embodiments when executed by a processor.
[0209] The collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in this application are in compliance with relevant laws and regulations and do not violate public order and good morals.
[0210] It should be noted that personal information from users should be collected for legitimate and reasonable purposes and should not be shared or sold outside of these legitimate uses. In addition, such collection / sharing should be carried out after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign the agreement / authorization including authorization of relevant user information before the user uses the function. In addition, any necessary steps should be taken to protect and safeguard access to such personal information data and ensure that others who have access to personal information data comply with its privacy policy and procedures.
[0211] The present application is expected to provide an implementation scheme for users to selectively block the use or access of personal information data. That is, the present disclosure is expected to provide hardware and / or software to prevent or block access to such personal information data. Once the personal information data is no longer needed, the risk can be minimized by limiting data collection and deleting the data. In addition, when applicable, such personal information is de-identified to protect the privacy of the user.
[0212] In the description of the aforementioned embodiments, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0213] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0214] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0215] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0216] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0217] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0218] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0219] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A method for generating program optimization suggestions, characterized in that: The method comprises the following steps: In the process of regression testing the system to be tested, the code program to be optimized and the SQL statement to be optimized of the system to be tested are collected through the probe; Performing code static analysis on the code program to be optimized to obtain a first optimization suggestion for the code program to be optimized; Analyze the SQL statement to be optimized to obtain a second optimization suggestion for the SQL statement to be optimized; A program optimization suggestion corresponding to the system to be tested is generated according to the first optimization suggestion and the second optimization suggestion.
2. The method according to claim 1, characterized in that The analyzing the SQL statement to be optimized to obtain a second optimization suggestion for the SQL statement to be optimized includes: By calling the database corresponding to the system to be tested, executing the plan statement for the SQL statement to be optimized, so as to obtain the execution plan corresponding to the SQL statement to be optimized; Analyze the execution plan to determine a first optimization condition satisfied by the SQL statement to be optimized; Parsing the SQL statement to be optimized to obtain a syntax tree of the SQL statement to be optimized; Parsing the syntax tree to determine a second optimization condition satisfied by the SQL statement to be optimized; The second optimization suggestion is obtained according to the optimization suggestion corresponding to the first optimization condition and the optimization suggestion corresponding to the second optimization condition.
3. The method according to claim 2, characterized in that The analyzing the execution plan to determine the first optimization condition satisfied by the SQL statement to be optimized includes: In response to prompt information that the execution plan does not hit a target field of a target data table in the database, determining that the first optimization condition includes that the SQL statement to be optimized does not hit an index; and / or, In response to the execution plan satisfying one or more of the following: the execution plan includes a preset operation type, an index is used, and the difference between the expected number of scanned rows and the number of rows of the target data table in the database is less than a first threshold, determining that the first optimization condition includes performing a full table scan; and / or, In response to the number of insert operations or delete operations in the execution plan being greater than a second threshold, determining that the first optimization condition includes the need to perform table analysis.
4. The method according to claim 2, characterized in that The parsing of the syntax tree to determine the second optimization condition satisfied by the SQL statement to be optimized includes: Determining the number of operation objects specified by preset keywords in the syntax tree, and in response to the number of specified operation objects being greater than a third threshold, determining that the second optimization condition includes that the operation object time consumption does not meet the requirement; and / or, In response to the search item specified keyword in the syntax tree including a subquery and the data volume of the subquery being greater than a fourth threshold, determining that the second optimization condition includes that the data volume of the subquery does not meet the requirement; and / or, In response to the presence of a function aggregation node in the syntax tree and the database being of a preset type, determining that the second optimization condition includes using a preset function; and / or, The number of valid parameters is determined by traversing the parameter nodes in the syntax tree, and in response to the number of valid parameters being less than a fifth threshold, it is determined that the second optimization condition includes unreasonable transmission of parameters.
5. The method according to claim 1, characterized in that The collecting of the code program to be optimized and the SQL statement to be optimized of the system to be tested by the probe includes: By using the probe, statistics are collected on the response time of each interface in the system to be tested and the execution time of each SQL statement used to access the database corresponding to the system to be tested; In response to a response time length of any interface being longer than a first preset time length, obtaining a code program corresponding to the any interface, and determining the code program corresponding to the any interface as the code program to be optimized; In response to the execution time of any one of the SQL statements being greater than a second preset time, determining that the any one of the SQL statements is the SQL statement to be optimized.
6. The method according to claim 1, characterized in that The performing code static analysis on the code program to be optimized to obtain a first optimization suggestion for the code program to be optimized includes: Performing static analysis on the code in the code program to be optimized to obtain a code analysis result; Determine the items to be optimized in the code analysis result and the optimization suggestions corresponding to the items to be optimized according to the code optimization rules corresponding to the programming language used by the code program to be optimized; The first optimization suggestion is obtained according to the optimization suggestion corresponding to the item to be optimized.
7. The method according to claim 1, characterized in that Also includes: Monitoring changes in the database corresponding to the system to be tested through a timer; In response to monitoring changes in the database, regression testing is performed on the system to be tested.
8. The method according to claim 7, characterized in that The monitoring of the changes of the database by a timer includes: In response to the timer being triggered, querying the table structure and table data of each data table in the database to obtain the current query result of the database; In response, the current query result is compared with a previous query result of the database to determine whether the database has changed.
9. The method according to claim 1, characterized in that Also includes: Collecting the request message log of the old system corresponding to the system to be tested, and obtaining the interface request message from the request message log; By sending the interface request message, a regression test is performed on the system to be tested.
10. The method according to any one of claims 1 to 9, characterized in that Also includes: Obtaining a regression test result of the system to be tested according to a comparison result between the interface response message of the system to be tested and the reference response message; Generate a target report based on the regression test results and the program optimization suggestions.
11. A device for generating program optimization suggestions, characterized in that: include: A collection module is used to collect the code program to be optimized and the SQL statement to be optimized of the system to be tested through a probe during the process of regression testing of the system to be tested; A first acquisition module, configured to perform a code static analysis on the code program to be optimized to obtain a first optimization suggestion for the code program to be optimized; A second acquisition module is used to analyze the SQL statement to be optimized to obtain a second optimization suggestion for the SQL statement to be optimized; The first generating module is used to generate a program optimization suggestion corresponding to the system to be tested according to the first optimization suggestion and the second optimization suggestion.
12. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 10 when executed by a processor.
14. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 10 when being executed by a processor.
Citation Information
Cited By
SQL (Structured Query Language) statement optimization suggestion generation method and device, medium and electronic equipment
CN120067140A
SQL (Structured Query Language) statement analysis optimization method and system based on large language model
CN120353822A
A sql statement analysis and optimization method and system based on a large language model
CN120353822B
SQL (Structured Query Language) optimization method and device based on intelligent agent, equipment and medium
CN121188085A
