Semantic service performance prediction method based on scale features and machine learning model
By building a semantic service performance testing system based on scale features and machine learning models, determining key impact features and training performance prediction models, the problems of poor accuracy and high resource consumption of semantic service performance prediction in the existing technology are solved, and the problem of poor quality and high resource consumption is realized Fast and efficient performance prediction.
Patent Information
- Application Number
- CN202411045538.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-11-19
AI Technical Summary
The existing semantic service performance prediction methods have problems such as poor accuracy, time cost and high material resources consumption.
Using a method based on scale features and machine learning models, the semantic service performance testing system is built, the execution time of the code file is obtained, the key impact characteristics are determined, the machine learning model is established, and the performance prediction model is trained to achieve rapid and efficient semantic service performance to be tested. predict.
It reduces the time cost and physical resource consumption of semantic service performance prediction, improves the accuracy and adaptability of prediction, and provides a fast and efficient method for semantic service performance acquisition.
Smart Images

Figure CN118981431A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of semantic service performance prediction, and in particular to a semantic service performance prediction method based on scale characteristics and a machine learning model. Background Art
[0002] A Domain-Specific Language (DSL) is a programming language designed specifically for a specific domain or target problem set. Unlike a General Purpose Language (GPL), a DSL is tailored to the needs of a specific application domain, making it more expressive and efficient in tasks within that domain. Due to these characteristics, DSLs have been successfully applied in improving software development efficiency and software quality in various fields, such as embedded systems, robotics, multimedia, multi-agent systems, home automation, distributed system protocols, Industry 4.0 aviation operating systems, machine learning, etc. DSLs are also used to enhance the capabilities of activities in the software development process, such as ensuring software quality or assisting code analysis, code debugging, formal verification, etc.
[0003] After the DSL semantic service is developed, the performance of the semantic service needs to be tested. Generally speaking, the existing DSL file is used as the test input, and the performance of the semantic service is tested by actually running the semantic service. However, this actual testing method often requires a lot of resources and time to build a test environment and conduct repeated tests, and the test results are difficult to cover all situations.
[0004] Therefore, a fast and efficient method for predicting semantic service performance is needed, which can predict semantic service performance in all situations. Summary of the invention
[0005] In view of the above analysis, an embodiment of the present invention aims to provide a semantic service performance prediction method based on scale characteristics and machine learning models, so as to solve the problems of poor accuracy, high time cost and high consumption of material resources in existing semantic service performance prediction.
[0006] On the one hand, an embodiment of the present invention provides a semantic service performance prediction method based on scale characteristics and a machine learning model, comprising:
[0007] S1: Building a semantic service performance test system, wherein the semantic service performance test system is used to obtain the execution time of the semantic service;
[0008] S2: construct a code snippet, generate a code file set based on the code snippet, and use the semantic service performance testing system to obtain a first execution time of the code file set, where the first execution time includes the execution time of each semantic service;
[0009] S3: Determine key impact features corresponding to each semantic service using a ranking importance algorithm based on the code file set and the first execution time;
[0010] S4: establishing a test file set for each key influencing feature based on the code snippet, and acquiring a second execution time of each test file set based on the semantic service performance testing system, wherein the second execution time includes the execution time of each semantic service;
[0011] S5: Build a machine learning model for each semantic service, and train the machine learning model based on a set of test files corresponding to the key influencing features of each semantic service to obtain a performance prediction model for the semantic service;
[0012] S6: Obtain the semantic service file to be tested, count the feature values of each code feature in the file, and input all the feature values into the machine learning model corresponding to the semantic service to obtain the performance prediction result of the semantic service.
[0013] Based on the further improvement of the above method, the semantic service performance testing system is implemented based on vscode / test-web, including a server and a client. The server is used to write and store semantic services, and the client is used to request semantic services and fill in parameters related to semantic services.
[0014] Based on the further improvement of the above method, the semantic services include: semantic tokens, document highlighting, file symbols, naming, workspace symbols, go to declaration, go to definition, go to type definition, go to implementation, find reference, call hierarchy, type hierarchy, document link, hover, inline value mosaic prompt, signature help, scope filter completion, symbol type filter completion, function signature completion, existence check, type consistency check, accessibility check, duplicate definition check.
[0015] Based on the further improvement of the above method, the execution time of the semantic service refers to the difference between the time when the server returns the message and the time when the client requests the message.
[0016] Based on the further improvement of the above method, the constructing code snippets and generating a code file set based on the code snippets include: S21: constructing DSL code snippets with different cyclomatic complexities; S22: selecting any code feature as a variable, setting the minimum value, maximum value and number of code files in the code file set of the code feature, and calculating a generation step based on the number of code files, the minimum value and maximum value of the code feature, based on the minimum value and the generation step, using the code feature as a variable, and using the code snippet to generate a group of code files that vary according to the generation step, thereby obtaining a code file set.
[0017] Based on the further improvement of the above method, the method of determining the key influencing features corresponding to each semantic service by using a permutation importance algorithm based on the code file set and the first execution time includes S31: constructing a first data sample set based on the code file set, each sample in the first data sample set includes a semantic service corresponding to a code file, a feature value of each code feature and an execution time of each semantic service, and dividing the first data sample set into a training set and a test set according to a certain ratio; S32: constructing a machine learning model; S33: selecting any semantic service from the unselected semantic services, taking the feature value of each code feature of each code file in the training set as an input data, and taking the execution time of the semantic service in the code file as a label, to train the machine learning model; S34: after the training is completed, inputting the feature value of each code feature of each code file in the test set as input data into the machine learning model, and calculating the determination coefficient based on the output predicted execution time and the execution time of the semantic service in the test set. S35: Select a code feature from the unselected code features, disrupt the original correspondence between the feature value of the code feature and the code file in each code file in the test set, and then input the test set into the machine learning model, and calculate the execution time of the semantic service in the test set based on the output predicted execution time by As the importance score of the code feature; S36: Repeat step S35 until each code feature in the test set is calculated, and take the code feature corresponding to the maximum importance score as the key influencing feature of the current semantic service; S37: Repeat S33-S36 until all semantic services obtain the corresponding key influencing features.
[0018] Based on further improvement of the above method, the code features include the number of code lines, the number of defined identifiers, the number of occurring identifiers, cyclomatic complexity, the number of nodes, degree, and depth.
[0019] Based on the further improvement of the above method, the test file set for each key influencing feature established based on the code snippet includes: S41: selecting one of the key influencing features, setting the minimum and maximum values of the feature in the test file set, and setting the number of files in the test file set, calculating a generation step based on the number of files, the minimum and maximum values, based on the minimum value and the generation step, taking the key influencing feature as a variable, using the code snippet to generate a group of test files that change according to the generation step, thereby forming a test file set; S42: counting the minimum and maximum values of the feature values of other key influencing features of the test file set; S43: selecting a feature from the key influencing features that have not been selected, and calculating a generation step based on the number of files, the minimum and maximum values of the feature, based on the minimum value and the generation step, taking the feature as a variable, using the code snippet to generate a group of test files that change according to the generation step, thereby forming a test file set; S44: repeating S43 until all key influencing features have established corresponding test file sets.
[0020] Based on the further improvement of the above method, the machine learning model of each semantic service is constructed, and the performance prediction model of the semantic service is obtained by training the machine learning model based on the test file set corresponding to the key influencing features of each semantic service, including: S51: establishing a sample data set based on the test file set of key influencing features corresponding to the semantic service, and the sample data set includes the feature values of the code features of each test file in the test file set and the execution time corresponding to the semantic service; S52: dividing the sample data set into a training set and a test set according to a certain ratio, taking the feature values of the code features contained in each sample as input data, and the execution time of the semantic service in the sample as a label, training the machine learning model, and using the test set to test the trained machine learning model, and when the output result meets the preset conditions, the performance prediction model of the semantic service is obtained.
[0021] Based on the further improvement of the above method, the machine learning models include linear regression, decision tree, support vector regression, ridge regression, random forest, lasso regression, elastic network, k nearest neighbor regression, and gradient boosting regression.
[0022] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0023] 1. The present invention provides a semantic service performance prediction method based on scale characteristics and machine learning models. Based on the machine learning model, the semantic service performance can be obtained by only obtaining the feature values of the code features in the file of the semantic service to be tested, thereby reducing the time cost and physical resource consumption of semantic service performance prediction, and providing a fast and efficient method for obtaining semantic service performance.
[0024] 2. The present invention provides a semantic service performance prediction method based on scale characteristics and machine learning models. The parameters of the performance prediction model of the semantic service are obtained based on a test file set constructed based on DSL code snippets of different cyclomatic complexities. The test file set covers different types and numbers of code features. Therefore, the performance prediction model of the present invention has wider adaptability, higher accuracy and stronger versatility.
[0025] 3. The present invention provides a method for predicting semantic service performance based on scale characteristics and machine learning models. A test file set constructed with key influencing characteristics of each semantic service is used as a training sample to train the machine learning model corresponding to the semantic service. This can improve the sensitivity of machine learning to the influencing characteristics to a certain extent, thereby improving the accuracy of predicting semantic service performance.
[0026] In the present invention, the above-mentioned technical solutions can also be combined with each other to achieve more preferred combination solutions. Other features and advantages of the present invention will be described in the subsequent description, and some advantages can become obvious from the description, or can be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings are only used for the purpose of illustrating specific embodiments and are not to be considered as limiting the present invention. In the entire drawings, the same reference symbols represent the same components;
[0028] Figure 1 Schematic diagram of the semantic service performance prediction method based on scale characteristics and machine learning models. DETAILED DESCRIPTION
[0029] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0030] A specific embodiment of the present invention discloses a semantic service performance prediction method based on scale characteristics and machine learning models, such as Figure 1 As shown, including:
[0031] S1: Construct a semantic service performance testing system, wherein the semantic service performance testing system is used to obtain the execution time of the semantic service.
[0032] Specifically, the semantic service performance testing system is implemented based on vscode / test-web, including a server and a client, wherein the server is used to write and store semantic services, and the client is used to request semantic services and fill in parameters related to semantic services. By adding code in the server to calculate the execution time of the semantic service. Usually, the user-perceived semantic service time is composed of three components: the transmission time between the client and the server, the processing time of the server, and the rendering time of the IDE or editor. Since the transmission time delay depends on the network environment, and the rendering time depends on the specific IDE or editor, the semantic service performance in this application refers to the time it takes for the server to process and return a response after receiving the client request.
[0033] In particular, the LSP specification version 3.17 divides services into five categories: lifecycle messages, services related to the server lifecycle, including operations when the client starts and shuts down the server; document synchronization, services that synchronize the document state between the client and the server; language features, services related to code understanding and writing; workspace features, services that operate symbols and files within the workspace; window features, services that display specific message notifications on the client. Since the language services in the categories of lifecycle messages, document synchronization, and window features do not require specific semantic information, such as symbol types, in their implementation, they are not considered semantic services. The services in the language features and workspace features categories were reviewed and 21 semantic services were finally identified. Of these 21 semantic services, 20 belong to language features. This is because the language features category provides actual intelligence in LSP compared to other categories. These services that provide intelligence usually require semantic information, so they usually belong to semantic services.
[0034] Even within the language feature category, different semantic services may have significant differences in functionality. For example, the definition jump service needs to resolve the definition location of a symbol at a given text document location, while the rename service needs to rename a symbol within the workspace scope. Of course, there may also be semantic services with similar functionality. For example, the difference between the definition jump and the find reference service is that the former resolves the definition location of a symbol, while the latter resolves the reference location of a symbol. Semantic services with significant functional differences may have significant differences in their execution processes, indicating that their performance may be significantly different. On the contrary, semantic services with minor functional differences usually have similar execution processes, indicating that their performance may be very similar. Therefore, in order to clarify the boundaries of semantic services, the semantic services in the LSP specification are reclassified, and semantic services with similar execution processes are classified into the same group, resulting in 5 categories of semantic services: Highlight: These services provide highlighting support for symbols in documents, such as highlighting different types of symbols with different colors. Symbol Operation: These services are responsible for handling symbol-related operations, such as finding and modifying symbols. Code Navigation: These services help users understand and navigate code. It includes finding and jumping to the definition or reference of a symbol, browsing other information related to the symbol, such as symbol annotations and parameter information of function symbols. Code Completion: These services provide code completion suggestions based on the contextual information around the cursor position. In practice, common code completion includes scope filtering completion, symbol type filtering completion, and function signature completion. Code Diagnostic: These services provide semantic error diagnostic information for the code. The LSP specification does not describe the classification of error diagnostic information. In practice, determining the semantic errors to be checked depends on the programming language. For example, in variable assignment and operation, weakly typed languages like JavaScript have loose type checking and allow implicit conversions between different data types, while strongly typed languages like Java require type checking, and if the types are inconsistent, type errors will occur. In order to define the boundaries of semantic error diagnostic services, this invention summarizes 4 common semantic error categories: existence check, type consistency check, accessibility check, and duplicate definition check.
[0035] Therefore, the semantic service includes: (1) highlighting type: semantic token, document highlighting; (2) symbol operation type: file symbol, naming, workspace symbol; (3) code navigation type: go to declaration, go to definition, go to type definition, go to implementation, find reference, call hierarchy, type hierarchy, document link, hover, inline value mosaic prompt, Moniker, signature help; (4) code completion type: scope filter completion, symbol type filter completion, function signature completion; (5) code diagnosis type: existence check, type consistency check, accessibility check, duplicate definition check.
[0036] S2: construct a code snippet, generate a code file set based on the code snippet, and use the semantic service performance testing system to obtain a first execution time of the code file set, where the first execution time includes the execution time of each semantic service, including:
[0037] S21: Construct DSL code snippets with different cyclomatic complexities;
[0038] S22: Select any code feature as a variable, set the minimum value, maximum value and number of code files in the code file set of the code feature, calculate the generation step based on the number of code files, the minimum value and maximum value of the code feature, based on the minimum value and the generation step, use the code feature as a variable, use the code fragment to generate a group of code files that vary according to the generation step, and thus obtain a code file set.
[0039] Referring to Table 1, the code features include: number of code lines, number of defined identifiers, number of appearing identifiers, cyclomatic complexity, number of nodes, degree, and depth.
[0040] Table 1 Code features
[0041] feature Abbreviation describe Lines of code LOC Number of lines in code file excluding comments Define the number of identifiers DEF The number of identifiers defined in the code file Number of occurrences of identifier OCC The number of occurrences of the identifier in the code file Cyclomatic complexity CYC Cyclomatic complexity of code files Number of nodes in AST NODE The number of nodes in the abstract syntax tree generated by parsing the code file Degree of AST DEGREE The degree of the abstract syntax tree generated by parsing the code file Depth of AST DEPTH The depth of the abstract syntax tree generated by parsing the code file
[0042] Specifically, the number of lines of code (LOC). Generally speaking, the more lines of code there are, the larger the code size is, which will lead to poor performance of semantic services. The number of identifiers. In a program, identifiers are usually used to represent variables, functions, etc. Although Halstead proposed a method of using operators and operands to measure program length, this method is not suitable for semantic services because keywords do not directly affect performance. Therefore, the present invention uses two other features to replace Halstead's method: the number of defined identifiers and the number of identifiers that appear. These two features are related to the "construction" and "search" components. As the number of defined identifiers increases, the number of symbols stored in the symbol table also increases, thereby increasing performance. In addition, some semantic services (such as "semantic tagging") need to obtain information about all identifiers appearing in the document through the "search" component. Therefore, as the number of identifiers appears, the search time in the semantic tagging service will also increase, thus affecting performance; cyclomatic complexity, as a measure of code complexity, the increase in cyclomatic complexity may lead to an increase in the depth of the symbol table, thereby affecting the performance of the "build" and "search" components; tree-related features, including the number of nodes (NODE), degree (DEGREE) and depth (DEPTH). The experimental research objects of the present invention include abstract syntax trees (AbstractSyntax The data represented by NODE, DEGREE and DEPTH come from AST instead of semantic tree. This is because although AST and semantic tree are implemented differently, semantic tree is derived from AST, which implies a positive correlation between the size of semantic tree and AST. In addition, in order to make the performance comparison between the two implementation methods comparable, their code feature values in the same code file should be the same. Therefore, the present invention uses AST data instead of semantic tree data, and the selection of these features is also reasonable. For example, in the AST-based implementation, the "positioning" component needs to find the corresponding node in AST according to the cursor position (row, column), and the time required may be related to the degree and depth of AST. The "traversal" component needs to traverse all nodes in AST, and its performance may be related to the number of nodes in the tree.
[0043] For example, prepare multiple code snippets with different cyclomatic complexities, which cover common definitions, assignments, conditional controls, loops, and function call statements in DSL. Then, perform feature statistics on these prepared code snippets, such as the number of code lines and the number of identifiers, which are recorded as δ n Then, choose a suitable feature δ iAs a control variable to generate code files, for example, the number of code lines is selected as a variable, and a group of 25 code files is generated. The minimum number of code lines of these code files is 400, and the maximum number of code lines can reach 10000. The generation step length is 400 obtained by the minimum and maximum number of code lines and the number of code files in the code file set. A group of code files is generated according to the generation step length, and the number of code lines between each group of adjacent code files differs by 400.
[0044] S3: Determine key impact features corresponding to each semantic service using a ranking importance algorithm based on the code file set and the first execution time, including:
[0045] S31: constructing a first data sample set based on the code file set, wherein each sample in the first data sample set includes a semantic service corresponding to a code file, a feature value of each code feature, and an execution time of each semantic service, and the first data sample set is divided into a training set and a test set according to a certain ratio;
[0046] S32: Build machine learning models;
[0047] S33: selecting any semantic service from the unselected semantic services, taking the feature value of each code feature of each code file in the training set as an input data, and taking the execution time of the semantic service in the code file as a label, to train the machine learning model;
[0048] S34: After the training is completed, the feature values of each code feature of each code file in the test set are input into the machine learning model as input data, and the determination coefficient is calculated based on the output predicted execution time and the execution time of the semantic service in the test set.
[0049] S35: Select a code feature from the unselected code features, disrupt the original correspondence between the feature value of the code feature and the code file in each code file in the test set, and then input the test set into the machine learning model, and calculate the execution time of the semantic service in the test set based on the output predicted execution time by As the importance score of the code feature;
[0050] S36: Repeat step S35 until each code feature in the test set is calculated, and the code feature corresponding to the maximum importance score is used as the key influencing feature of the current semantic service;
[0051] S37: Repeat S33-S36 until all semantic services obtain corresponding key impact features.
[0052] It can be understood that randomly selecting a code feature from the unselected code features and disrupting the original correspondence between the feature value of the code feature in each code file in the test set and the code file means: taking the selected code feature as a variable, keeping the feature values of other code features in each code file unchanged, and randomly disrupting the correspondence between the feature value of the variable in each code file and the code file, for example, taking the feature value of the variable in the first file as the feature value of the variable in the third file, and taking the feature value of the variable in the third file as the feature value of the variable in the last file.
[0053] Specifically, for the coefficient of determination Calculate as follows: R 2 =1-SSE / SST, where SSE is the residual sum of squares, which represents the sum of squares of the difference between the model predicted value and the actual value, and SST is the total sum of squares, which represents the sum of squares of the difference between the actual value and the mean of the true value.
[0054] Although there may be many code features in traditional software engineering, they are different from the features that may affect semantic services. After the ranking importance algorithm, the key influencing features are finally determined to be code lines, number of nodes, number of defined identifiers, and number of identifiers that appear. It can be understood that the key influencing features corresponding to different semantic services may be the same, so in the following step S4, a test file set for each key influencing feature is constructed based on the key influencing features. When training the prediction models corresponding to different semantic services, the test file set of the key influencing features corresponding to the semantic service is used to construct the sample set.
[0055] S4: establishing a test file set for each key influencing feature based on the code snippet, and acquiring a second execution time of each test file set based on the semantic service performance test system, wherein the second execution time includes the execution time of each semantic service, including:
[0056] S41: selecting a feature among the key influencing features, setting the minimum value and the maximum value of the feature in the test file set, and setting the number of files in the test file set, calculating a generation step length based on the number of files, the minimum value and the maximum value, and based on the minimum value and the generation step length, using the key influencing feature as a variable, using the code snippet to generate a group of test files that vary according to the generation step length, thereby forming a test file set;
[0057] S42: Counting the minimum and maximum values of other key influencing feature values of the test file set;
[0058] S43: selecting a feature from the unselected key influencing features, and calculating a generation step length based on the number of files, the minimum value and the maximum value of the feature, and based on the minimum value and the generation step length of the feature, using the feature as a variable, and using the code snippet to generate a set of test files that vary according to the generation step length, thereby forming a test file set;
[0059] S44: Repeat S43 until corresponding test file sets are established for all key influencing features.
[0060] It can be understood that after obtaining the test file set corresponding to each key influencing feature, obtaining the second execution time of each test file set based on the semantic service performance test system includes: for any semantic service stored on the server, sending each test file to the server, and obtaining the service time taken by each test file to execute the semantic service on the server as the second execution time; or, for any test file, sending the file to the server, and obtaining the time taken by the file to execute each semantic service on the server as the second execution time. In the above manner, the service time for each test file to execute each semantic service is obtained. S5: Construct a machine learning model for each semantic service, and train the machine learning model based on the test file set corresponding to the key influencing features of each semantic service to obtain a performance prediction model for the semantic service, including:
[0061] S51: establishing a sample data set based on a test file set of key influencing features corresponding to the semantic service, wherein the sample data set includes a feature value of a code feature of each test file in the test file set and an execution time corresponding to the semantic service;
[0062] S52: Divide the sample data set into a training set and a test set in a certain ratio, use the feature value of the code feature contained in each sample as input data, and the execution time of the semantic service in the sample as a label to train the machine learning model, and use the test set to test the trained machine learning model. When the output result meets the preset conditions, the performance prediction model of the semantic service is obtained.
[0063] Available machine learning models include: linear regression (LR), decision tree (DT), support vector regression (SVR), ridge regression, random forest (RF), lasso regression (Lasso), elastic network (EN), k-nearest neighbor regression (KNR), gradient boosting regression (GBR), etc. For any semantic service, multiple machine learning models can be selected for training at the same time, and the machine learning model with the highest prediction accuracy is used as the performance prediction model corresponding to the semantic service.
[0064] In addition, in machine learning, it is essential to correctly set hyperparameters, as it can significantly improve the prediction performance of the model, including accuracy, precision, and recall. In addition, adjusting some hyperparameters, such as the depth of the tree and the minimum number of samples of the leaf node, can also control the complexity of the model and prevent overfitting and underfitting. However, due to differences in data scale, feature type, and data distribution, the required hyperparameter settings will also be different for different problems. After many experiments, the optimal implementation settings of some hyperparameters of machine learning methods in the semantic service performance analysis problem were explored. The optimal implementation settings of important parameters are as follows: For the decision tree method, the maximum depth of each decision tree is set to 10, which can effectively prevent overfitting while ensuring that the model can fit the data well. The maximum number of features used for splitting the decision tree is set to 3; for the random forest method, the number of trees is set to 4; for the SVR method, the RBF kernel is used. This setting can map the original space into an infinite-dimensional space, which has better performance in semantic service performance prediction; in the elastic network, the 11 ratio is set to 0.5, so that L1 and L2 penalties are used at the same time.
[0065] S6: Obtain the semantic service file to be tested, count the feature values of each code feature in the file, and input all the feature values into the machine learning model corresponding to the semantic service to obtain the performance prediction result of the semantic service.
[0066] It can be understood that when it is necessary to obtain the semantic service performance of a code file, first construct the feature value sequence of each code feature in the code file, then determine the machine learning model corresponding to the semantic service, input the feature value sequence into the machine learning model, and you can get the performance prediction result of the semantic service.
[0067] Compared with the prior art, the present embodiment provides a semantic service performance prediction method based on scale characteristics and machine learning models. The method comprises the following steps: constructing a semantic service performance testing system, generating a code file set based on code snippets, using the semantic service performance testing system to obtain the first execution time of the code file set, determining the key influencing features corresponding to each semantic service based on the code file set and the first execution time using a permutation importance algorithm, establishing a test file set for each key influencing feature based on the code snippet, obtaining the second execution time of each test file set based on the semantic service performance testing system, constructing a machine learning model for each semantic service, training the machine learning model based on the test file set corresponding to the key influencing feature of each semantic service to obtain a performance prediction model for the semantic service, obtaining a semantic service file to be tested, counting the feature values of each code feature in the file, and inputting all feature values into the machine learning model corresponding to the semantic service to obtain a performance prediction result for the semantic service, thereby realizing an accurate and efficient semantic service performance prediction method with low time cost and material resource consumption.
[0068] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0069] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A semantic service performance prediction method based on scale characteristics and machine learning models, It is characterized in that include: S1: Building a semantic service performance test system, wherein the semantic service performance test system is used to obtain the execution time of the semantic service; S2: construct a code snippet, generate a code file set based on the code snippet, and use the semantic service performance testing system to obtain a first execution time of the code file set, where the first execution time includes the execution time of each semantic service; S3: Determine key impact features corresponding to each semantic service using a ranking importance algorithm based on the code file set and the first execution time; S4: establishing a test file set for each key influencing feature based on the code snippet, and acquiring a second execution time of each test file set based on the semantic service performance testing system, wherein the second execution time includes the execution time of each semantic service; S5: Build a machine learning model for each semantic service, and train the machine learning model based on a set of test files corresponding to the key influencing features of each semantic service to obtain a performance prediction model for the semantic service; S6: Obtain the semantic service file to be tested, count the feature values of each code feature in the file, and input all the feature values into the machine learning model corresponding to the semantic service to obtain the performance prediction result of the semantic service.
2. According to claim 1, a semantic service performance prediction method based on scale characteristics and machine learning models, It is characterized in that The semantic service performance testing system is implemented based on vscode / test-web, and includes a server and a client. The server is used to write and store semantic services, and the client is used to request semantic services and fill in parameters related to the semantic services.
3. According to claim 2, a semantic service performance prediction method based on scale characteristics and machine learning models, It is characterized in that The semantic services include: semantic tokens, document highlighting, file symbols, naming, workspace symbols, go to declaration, go to definition, go to type definition, go to implementation, find reference, call hierarchy, type hierarchy, document link, hover, inline value mosaic prompt, signature help, scope filter completion, symbol type filter completion, function signature completion, existence check, type consistency check, accessibility check, duplicate definition check.
4. According to claim 3, a semantic service performance prediction method based on scale characteristics and machine learning models, It is characterized in that The execution time of the semantic service refers to the difference between the time when the server returns a message and the time when the client receives the request message.
5. According to claim 4, a semantic service performance prediction method based on scale characteristics and machine learning models, It is characterized in that The constructing code snippets and generating a code file set based on the code snippets comprises: S21: Construct DSL code snippets with different cyclomatic complexities; S22: Select any code feature as a variable, set the minimum value, maximum value and number of code files in the code file set of the code feature, calculate the generation step based on the number of code files, the minimum value and maximum value of the code feature, based on the minimum value and the generation step, use the code feature as a variable, use the code fragment to generate a group of code files that vary according to the generation step, and thus obtain a code file set.
6. According to claim 5, a semantic service performance prediction method based on scale characteristics and machine learning models, It is characterized in that The step of determining the key influencing features corresponding to each semantic service by using a ranking importance algorithm based on the code file set and the first execution time includes: S31: constructing a first data sample set based on the code file set, wherein each sample in the first data sample set includes a semantic service corresponding to a code file, a feature value of each code feature, and an execution time of each semantic service, and the first data sample set is divided into a training set and a test set according to a certain ratio; S32: Build machine learning models; S33: selecting any semantic service from the unselected semantic services, taking the feature value of each code feature of each code file in the training set as an input data, and taking the execution time of the semantic service in the code file as a label, to train the machine learning model; S34: After the training is completed, the feature values of each code feature of each code file in the test set are input into the machine learning model as input data, and the determination coefficient is calculated based on the output predicted execution time and the execution time of the semantic service in the test set. S35: Select a code feature from the unselected code features, disrupt the original correspondence between the feature value of the code feature and the code file in each code file in the test set, and then input the test set into the machine learning model, and calculate the execution time of the semantic service in the test set based on the output predicted execution time by As the importance score of the code feature; S36: Repeat step S35 until each code feature in the test set is calculated, and the code feature corresponding to the maximum importance score is used as the key influencing feature of the current semantic service; S37: Repeat S33-S36 until all semantic services obtain corresponding key impact features.
7. The semantic service performance prediction method based on scale characteristics and machine learning model according to claim 6, It is characterized in that The code features include the number of code lines, the number of defined identifiers, the number of occurring identifiers, cyclomatic complexity, the number of nodes, degree, and depth.
8. According to claim 7, a semantic service performance prediction method based on scale characteristics and machine learning models, It is characterized in that The test file set for establishing each key influencing feature based on the code snippet includes: S41: selecting a feature among the key influencing features, setting the minimum value and the maximum value of the feature in the test file set, and setting the number of files in the test file set, calculating a generation step length based on the number of files, the minimum value and the maximum value, and based on the minimum value and the generation step length, using the key influencing feature as a variable, using the code snippet to generate a group of test files that vary according to the generation step length, thereby forming a test file set; S42: Counting the minimum and maximum values of other key influencing feature values of the test file set; S43: selecting a feature from the unselected key influencing features, and calculating a generation step length based on the number of files, the minimum value and the maximum value of the feature, and based on the minimum value and the generation step length of the feature, using the feature as a variable, and using the code snippet to generate a set of test files that vary according to the generation step length, thereby forming a test file set; S44: Repeat S43 until corresponding test file sets are established for all key influencing features.
9. The semantic service performance prediction method based on scale characteristics and machine learning model according to claim 8, It is characterized in that The step of constructing a machine learning model for each semantic service and training the machine learning model based on a test file set corresponding to a key influencing feature of each semantic service to obtain a performance prediction model for the semantic service includes: S51: establishing a sample data set based on a test file set of key influencing features corresponding to the semantic service, wherein the sample data set includes a feature value of a code feature of each test file in the test file set and an execution time corresponding to the semantic service; S52: Divide the sample data set into a training set and a test set in a certain ratio, use the feature value of the code feature contained in each sample as input data, and the execution time of the semantic service in the sample as a label to train the machine learning model, and use the test set to test the trained machine learning model. When the output result meets the preset conditions, the performance prediction model of the semantic service is obtained.
10. The semantic service performance prediction method based on scale characteristics and machine learning model according to claim 9, It is characterized in that The machine learning models include linear regression, decision tree, support vector regression, ridge regression, random forest, lasso regression, elastic network, k nearest neighbor regression, and gradient boosting regression.
