CN110727437B - Code optimization item acquisition method and device, storage medium and electronic equipment - Google Patents

Code optimization item acquisition method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN110727437B
CN110727437B CN201910854837.5A CN201910854837A CN110727437B CN 110727437 B CN110727437 B CN 110727437B CN 201910854837 A CN201910854837 A CN 201910854837A CN 110727437 B CN110727437 B CN 110727437B
Authority
CN
China
Prior art keywords
optimization
parameters
target
program code
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910854837.5A
Other languages
Chinese (zh)
Other versions
CN110727437A (en
Inventor
胡鹏强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN201910854837.5A priority Critical patent/CN110727437B/en
Publication of CN110727437A publication Critical patent/CN110727437A/en
Application granted granted Critical
Publication of CN110727437B publication Critical patent/CN110727437B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3628Software debugging of optimised code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Medical Informatics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Stored Programmes (AREA)

Abstract

The disclosure relates to a method, a device, a storage medium and electronic equipment for acquiring a code optimization item, belonging to the technical field of code optimization, wherein the method comprises the following steps: when an optimization request for target program codes is received, acquiring performance test parameters, optimization target parameters, code running environment parameters and program code development parameters for the target program codes from the optimization request; inputting a pre-trained machine learning model to obtain an optimization strategy for the target program code; scanning the target optimization codes according to the optimization strategy to obtain all optimization items corresponding to the optimization strategy; and acquiring target optimization items from all the optimization items corresponding to the optimization strategies. And after the prediction of the code optimization strategy is carried out according to the optimization requirement through the machine learning model, the optimization strategy is utilized to acquire the optimization term, so that the efficiency and accuracy of the acquisition of the optimization term are effectively ensured.

Description

Code optimization item acquisition method and device, storage medium and electronic equipment
Technical Field
The disclosure relates to the technical field of code optimization, in particular to a code optimization item acquisition method, a code optimization item acquisition device, a storage medium and electronic equipment.
Background
Code optimization refers to equivalent (meaning that the result of running a program is not changed) transformations of program code. The program code may be intermediate code or object code. Equivalent means that the code running result after transformation is identical to the code running result before transformation. The optimization means that the finally generated object code works more easily (shorter running time and smaller occupied space) and the space-time efficiency is optimized.
Currently, when code optimization is performed on a program code, the program code to be optimized is generally subjected to full-disk inspection, then optimized codes in the program code are searched according to experience, and then the searched codes are optimized. In the prior art, when code optimization is performed, an optimization term which is suitable for the performance optimization requirement cannot be accurately obtained according to the performance optimization requirement, and performance of each aspect of a system to which the program code is applied cannot be considered after optimization.
It should be noted that the information disclosed in the above background section is only for enhancing understanding of the background of the present disclosure and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
The purpose of the present disclosure is to provide a code optimization term acquisition scheme, and further, after predicting a code optimization strategy according to an optimization requirement at least to a certain extent through a machine learning model, an optimization term is acquired by using the optimization strategy, so that efficiency and accuracy of acquiring the optimization term are effectively ensured.
According to one aspect of the present disclosure, there is provided a code optimization term acquisition method including:
when an optimization request for target program codes is received, acquiring performance test parameters, optimization target parameters, code running environment parameters and program code development parameters for the target program codes from the optimization request;
inputting the input data of the performance test parameters, the optimization target parameters, the code running environment parameters and the program code development parameters into a pre-trained machine learning model to obtain an optimization strategy for the target program code;
scanning the target optimization codes according to the optimization strategy to obtain all optimization items corresponding to the optimization strategy;
and acquiring target optimization items from all the optimization items corresponding to the optimization strategies.
In an exemplary embodiment of the disclosure, inputting the input data of the performance test parameter, the optimization target parameter, the code running environment parameter, and the program code development parameter into a pre-trained machine learning model to obtain an optimization strategy for the target program code includes:
Acquiring a preset input data template, wherein the preset input data template comprises an associated storage area of the same attribute parameters in performance test parameters and optimization target parameters, a code running environment parameter storage area and a program code development parameter storage area;
storing the performance test parameters and parameters with the same attribute in the optimization target parameters in the associated storage area in an associated mode, storing the code running environment parameters in the code running environment parameter storage area, and storing the program code development parameters in the program code development parameter storage area to obtain an input data template;
normalizing the input data template into input data, and inputting a pre-trained machine learning model to obtain an optimization strategy for the target program code.
In one exemplary embodiment of the present disclosure, the optimization strategy is an optimization term list comprising a plurality of predictive optimization terms,
scanning the target optimization code according to the optimization strategy to obtain all optimizable items corresponding to the optimization strategy, wherein the method comprises the following steps:
acquiring a preset scanning template of each prediction optimization term in the optimization strategy;
And scanning the target optimization codes by using each preset scanning template to obtain all optimizable items corresponding to the optimization strategy.
In an exemplary embodiment of the present disclosure, the obtaining a target optimization term from all the optimizable terms corresponding to the optimization policy includes:
acquiring a preset optimization term management list, wherein the preset optimization term management list comprises performance contribution values of optimized performance parameters and performance consumption values of the optimized performance parameters;
and acquiring a plurality of optimization items from all the optimizable items corresponding to the optimization strategy according to a preset rule and taking the optimization items as the target optimization items according to the performance contribution value of each performance parameter and the performance consumption value of each performance parameter after the optimization.
In an exemplary embodiment of the present disclosure, the obtaining, according to a predetermined rule, a plurality of optimization terms from all the optimizable terms corresponding to the optimization policy according to the performance contribution value of each performance parameter after the optimization and the performance consumption value of each performance parameter, where the obtaining, as the target optimization term, includes:
and acquiring a plurality of optimization items, of which the sum of the performance contribution values of all the optimizable items to the optimization target parameters is larger than a preset threshold value, and the performance consumption values of the other performance parameters except the optimization target parameters are smaller than the preset threshold value, as the target optimization items.
In an exemplary embodiment of the disclosure, after obtaining a target optimization term from all optimizable terms corresponding to the optimization strategy, the method further includes:
obtaining an optimization example of the target optimization term from a preset optimization term optimization case database;
and sending the target optimization item and the optimization example to a target terminal to complete the optimization of the target program code.
In one exemplary embodiment of the present disclosure, the training method of the machine learning model is:
collecting a sample set of performance test parameters, optimization target parameters, code running environment parameters and program code development parameters, wherein each sample in the sample set is calibrated with an optimization strategy of a corresponding program code in advance;
inputting the input data of each sample in the sample set into a machine learning model to obtain a prediction optimization strategy of a program code corresponding to each sample;
if the prediction optimization strategy of the program code corresponding to the sample obtained after the sample is input into the machine learning model is inconsistent with the optimization strategy of the program code corresponding to the sample calibrated in advance, the coefficient of the machine learning model is adjusted to be consistent;
When all the samples are input into a machine learning model, the obtained prediction optimization strategy of the program codes corresponding to the samples is consistent with the optimization strategy of the program codes corresponding to the samples calibrated in advance, and training is finished.
According to an aspect of the present disclosure, there is provided a code optimization term acquisition apparatus, including:
the system comprises a parameter acquisition module, a program code development module and a program code optimization module, wherein the parameter acquisition module is used for acquiring performance test parameters, optimization target parameters, code running environment parameters and program code development parameters of target program codes from an optimization request when the optimization request of the target program codes is received;
the prediction module is used for inputting the input data of the performance test parameters, the optimization target parameters, the code running environment parameters and the program code development parameters into a pre-trained machine learning model to obtain an optimization strategy for the target program code;
the scanning module is used for scanning the target optimization codes according to the optimization strategy to obtain all optimization items corresponding to the optimization strategy;
the target acquisition module is used for acquiring target optimization items from all the optimization items corresponding to the optimization strategies.
According to one aspect of the present disclosure, there is provided a computer-readable storage medium having stored thereon a code-optimized item acquisition program, characterized in that the code-optimized item acquisition program, when executed by a processor, implements the method of any one of the above.
According to an aspect of the present disclosure, there is provided an electronic apparatus, including:
a processor; and
a memory for storing a code optimization term acquisition program of the processor; wherein the processor is configured to perform the method of any of the above via execution of the code optimization term acquisition program.
When an optimization request for a target program code is received, performance test parameters, optimization target parameters, code running environment parameters and program code development parameters for the target program code are acquired from the optimization request; thus, by acquiring the parameters of the target program code, the parameters can clearly reflect the code running condition, and the method can be used for accurately analyzing the bottleneck of the code running in the subsequent steps. Furthermore, inputting the input data of the performance test parameters, the optimization target parameters, the code running environment parameters and the program code development parameters into a pre-trained machine learning model to obtain an optimization strategy for the target program code; therefore, the optimization strategy under the current environment of the code can be efficiently and accurately analyzed based on the parameters through a pre-trained machine learning model. Then, scanning the target optimization codes according to the optimization strategy to obtain all optimization items corresponding to the optimization strategy; all optimization items corresponding to the optimization strategy under the current optimization environment in the target program code can be obtained. Furthermore, the target optimization items are obtained from all the optimization items corresponding to the optimization strategies, all the performances of the target program code which can be considered in the program code can be obtained from all the optimization items, and meanwhile, part of the optimization items of the optimization targets can be realized, so that the reliability of the optimization items is effectively ensured. In this way, after the prediction of the code optimization strategy is performed according to the optimization requirement through the machine learning model, the optimization strategy is utilized to obtain the optimization term, so that the efficiency and accuracy of obtaining the optimization term are effectively ensured.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure. It will be apparent to those of ordinary skill in the art that the drawings in the following description are merely examples of the disclosure and that other drawings may be derived from them without undue effort.
Fig. 1 schematically shows a flow chart of a code optimization term acquisition method.
Fig. 2 schematically shows an example diagram of an application scenario of a code optimization term acquisition method.
Fig. 3 schematically shows a flow chart of a method of obtaining an optimization strategy.
Fig. 4 schematically shows a block diagram of a code optimization term acquisition device.
Fig. 5 schematically shows an example block diagram of an electronic device for implementing the above-described code optimization term acquisition method.
Fig. 6 schematically shows a computer-readable storage medium for implementing the code optimization term acquisition method described above.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. However, the exemplary embodiments may be embodied in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the present disclosure. One skilled in the relevant art will recognize, however, that the aspects of the disclosure may be practiced without one or more of the specific details, or with other methods, components, devices, steps, etc. In other instances, well-known technical solutions have not been shown or described in detail to avoid obscuring aspects of the present disclosure.
Furthermore, the drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus a repetitive description thereof will be omitted. Some of the block diagrams shown in the figures are functional entities and do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in software or in one or more hardware modules or integrated circuits or in different networks and/or processor devices and/or microcontroller devices.
In this exemplary embodiment, a method for obtaining a code optimization term is provided first, where the method for obtaining a code optimization term may be run on a server, or may be run on a server cluster or a cloud server, or the like, and of course, those skilled in the art may also run the method of the present invention on other platforms according to requirements, which is not limited in particular in this exemplary embodiment. Referring to fig. 1, the code optimization term acquisition method may include the steps of:
step S110, when an optimization request for target program codes is received, performance test parameters, optimization target parameters, code running environment parameters and program code development parameters for the target program codes are obtained from the optimization request;
step S120, inputting the input data of the performance test parameters, the optimization target parameters, the code running environment parameters and the program code development parameters into a pre-trained machine learning model to obtain an optimization strategy for the target program code;
step S130, scanning the target optimization codes according to the optimization strategy to obtain all optimization items corresponding to the optimization strategy;
and step S140, obtaining a target optimization term from all the optimization terms corresponding to the optimization strategy.
In the above code optimization term obtaining method, first, when an optimization request for a target program code is received, performance test parameters, optimization target parameters, code running environment parameters and program code development parameters for the target program code are obtained from the optimization request; thus, by acquiring the parameters of the target program code, the parameters can clearly reflect the code running condition, and the method can be used for accurately analyzing the bottleneck of the code running in the subsequent steps. Furthermore, inputting the input data of the performance test parameters, the optimization target parameters, the code running environment parameters and the program code development parameters into a pre-trained machine learning model to obtain an optimization strategy for the target program code; therefore, the optimization strategy under the current environment of the code can be efficiently and accurately analyzed based on the parameters through a pre-trained machine learning model. Then, scanning the target optimization codes according to the optimization strategy to obtain all optimization items corresponding to the optimization strategy; all optimization items corresponding to the optimization strategy under the current optimization environment in the target program code can be obtained. Furthermore, the target optimization items are obtained from all the optimization items corresponding to the optimization strategies, all the performances of the target program code which can be considered in the program code can be obtained from all the optimization items, and meanwhile, part of the optimization items of the optimization targets can be realized, so that the reliability of the optimization items is effectively ensured. In this way, after the prediction of the code optimization strategy is performed according to the optimization requirement through the machine learning model, the optimization strategy is utilized to obtain the optimization term, so that the efficiency and accuracy of obtaining the optimization term are effectively ensured.
Next, each step in the code optimization term acquisition method according to the present exemplary embodiment will be explained and described in detail with reference to the accompanying drawings.
In step S110, when an optimization request for a target program code is received, performance test parameters, optimization target parameters, code running environment parameters, and program code development parameters for the target program code are acquired from the optimization request.
In the embodiment of the present example, referring to fig. 2, when the server 201 receives an optimization request for a target program code sent by the server 202, performance test parameters, optimization target parameters, code running environment parameters, and program code development parameters for the target program code are obtained from the optimization request. This allows the server 201 to accurately analyze the bottleneck of code execution in subsequent steps. It will be appreciated that, according to the requirement, the server 202 may also directly obtain the performance test parameters, the optimization target parameters, the code running environment parameters and the program code development parameters of the target program code from the optimization request, and accurately analyze the bottleneck of code running in the subsequent steps. The server 201 and the server 202 may be any devices having processing capabilities, such as a computer, a microprocessor, etc., which are not particularly limited herein.
The optimization request for the target program code carries a request for parameters related to the optimization for triggering an optimization operation for the target program code. The performance test parameters of the object program code are, for example, execution time, CPU time, memory allocation, disk throughput, network throughput, response time, etc. The optimization target parameters are parameters which the user wants to optimize, namely parameters which the user system compares attention, and the optimization needs to be performed as much as possible. The code running environment parameter is the running environment of the program code during test, such as development environment or test environment. Program code development parameters requirements for developing program code, such as the use of the program code, how much CPU usage must be guaranteed, how much network usage is or how efficient running is, thread safety requirements, etc.
At different stages we have certain requirements on the performance of the system, such as how much throughput is to be achieved. If this index is not reached, then a de-optimization is required. When an optimization request for the target program code is received, performance test parameters, optimization target parameters, code running environment parameters and program code development parameters for the target program code are obtained from the optimization request, so that judgment of an optimization strategy of the program code can be accurately carried out in the subsequent steps.
In step S120, input data of the performance test parameter, the optimization target parameter, the code running environment parameter, and the program code development parameter are input into a pre-trained machine learning model, so as to obtain an optimization strategy for the target program code.
In the present exemplary embodiment, the input data is data in an input format that can be used for a machine learning model, such as binary form data, or the like. The optimization strategy is an optimization index for optimizing the program code and a prediction optimization term corresponding to each optimization index, and according to all parameters of the source of the input data, the performance bottleneck of the program code when the program code is applied in a corresponding environment can be reflected, so that corresponding optimization is needed. The various parameters that are currently available can be analyzed by inputting so-called input data into a pre-trained machine learning model, resulting in an optimization strategy that can optimize performance in the optimization objective parameters. The optimization indexes are, for example, final modifiers of specified classes and methods, reuse objects or reduction of repeated calculation of variables, and different optimization indexes can optimize different performances of the program code. The prediction optimization items corresponding to the optimization indexes are, for example, the use of String objects corresponding to reuse objects, for example, string builder/String buffer should be used when character String connection occurs, so that the method can be used for reducing the establishment of objects, further avoiding garbage recovery and processing, and effectively improving the running efficiency of program codes. By inputting the input data of the performance test parameters, the optimization target parameters, the code running environment parameters and the program code development parameters into the pre-trained machine learning model, the comprehensive output optimization strategy can be automatically, accurately and efficiently obtained according to the optimization requirements, the current performance test parameters of the program codes and the like, the performance optimization of the target optimization parameters can be realized, and other performance defects can not be brought. Meanwhile, the search range of the optimization term which is suitable for the optimization target can be effectively reduced to a certain extent, and the accuracy and the high efficiency of the acquisition of the optimization term in the subsequent steps are effectively ensured.
In one embodiment of the present example, the inputting the input data of the performance test parameter, the optimization target parameter, the code running environment parameter, and the program code development parameter into a pre-trained machine learning model to obtain an optimization strategy for the target program code is shown in fig. 3, and includes:
step S310, a preset input data template is obtained, wherein the preset input data template comprises an associated storage area of the same attribute parameters in the performance test parameters and the optimization target parameters, a code running environment parameter storage area and a program code development parameter storage area;
step S320, storing the performance test parameter and the parameter with the same attribute in the optimization target parameter in the associated storage area, storing the code running environment parameter in the code running environment parameter storage area, and storing the program code development parameter in the program code development parameter storage area, so as to obtain an input data template;
and step S330, normalizing the input data template into input data, and inputting a pre-trained machine learning model to obtain an optimization strategy for the target program code.
The preset input data template is a data storage table formulated according to preset formats and association relations of various parameters, and comprises different storage areas; the performance test parameters and parameters with the same attribute in the optimization target parameters are stored in the associated storage area in an associated mode, so that the relation between the performance test parameters and the optimization target parameters can be accurately represented, then data are stored in the corresponding storage area, and the categories corresponding to the parameters can be accurately represented through the distribution of the storage area, for example, the program code development parameters are stored in the program code development parameter storage area. Thereby effectively ensuring the accurate identification of the machine learning model to the data of each parameter. And finally, normalizing the input data template to be used as input data, namely converting the input data template into data with the same data format, and obtaining data which can be used for calculation and analysis of a machine learning model. Thus, the optimization strategy of the target program code can be accurately and efficiently obtained.
In one embodiment of the present example, the training method of the machine learning model is:
collecting a sample set of performance test parameters, optimization target parameters, code running environment parameters and program code development parameters, wherein each sample in the sample set is calibrated with an optimization strategy of a corresponding program code in advance;
Inputting the input data of each sample in the sample set into a machine learning model to obtain a prediction optimization strategy of a program code corresponding to each sample;
if the prediction optimization strategy of the program code corresponding to the sample obtained after the sample is input into the machine learning model is inconsistent with the optimization strategy of the program code corresponding to the sample calibrated in advance, the coefficient of the machine learning model is adjusted to be consistent;
when all the samples are input into a machine learning model, the obtained prediction optimization strategy of the program codes corresponding to the samples is consistent with the optimization strategy of the program codes corresponding to the samples calibrated in advance, and training is finished.
Different combinations of performance test parameters, optimization objective parameters, code execution environment parameters, and program code development parameters may indicate different code performance issues. The method comprises the steps of collecting a sample set of performance test parameters, optimization target parameters, code running environment parameters and program code development parameters of an optimization strategy for calibrating corresponding program codes in advance as input of a machine learning model, and calibrating the optimization strategy of the corresponding program codes by an expert in advance as output of the machine learning model by each sample. Then, by adjusting the coefficients, after all the samples are input into a machine learning model, the obtained prediction optimization strategy of the program codes corresponding to the samples is consistent with the optimization strategy of the program codes corresponding to the samples calibrated in advance, and training is finished, so that training accuracy can be effectively ensured.
In one embodiment of the present example, the optimization strategy is a list comprising a plurality of predictive optimization indicators, wherein each predictive optimization indicator is associated with a corresponding plurality of predictive optimization terms.
The optimization strategy is a list comprising a plurality of predictive optimization indicators, i.e. all or part of the optimization indicators that can be used to optimize the performance in the target parameters are saved through the list. Wherein each predictive optimization index is associated with a corresponding plurality of predictive optimization terms. Therefore, the prediction optimization index can be conveniently managed, and the optimization item can be efficiently searched according to the list in the subsequent step.
In step S130, according to the optimization strategy, the target optimization code is scanned, so as to obtain all optimization terms corresponding to the optimization strategy.
In the embodiment of the present example, according to the optimization policy, the target optimization code is scanned, that is, according to the range of the determined optimization term in the optimization policy, and according to the search method of the corresponding optimization term, the target optimization code is scanned, so that all the optimization terms that are suitable for the optimization target can be efficiently and accurately scanned, that is, all the optimizable terms that are corresponding to the optimization policy are obtained.
In one embodiment of the present example, the optimization strategy is a scan script comprising a plurality of scan objects,
Scanning the target optimization code according to the optimization strategy to obtain all optimizable items corresponding to the optimization strategy, wherein the method comprises the following steps:
and scanning the target optimization codes by using the scanning script in turn to obtain all optimizable items corresponding to the optimization strategy.
In this way, all optimizable items can be efficiently scanned from the target optimization code through the optimization strategy in the form of a scanning script. Wherein, the scan objects in the scan script of the plurality of scan objects can be respective code optimization items.
In one embodiment of the present example, the optimization strategy is an optimization term list comprising a plurality of predictive optimization terms,
scanning the target optimization code according to the optimization strategy to obtain all optimizable items corresponding to the optimization strategy, wherein the method comprises the following steps:
acquiring a preset scanning template of each prediction optimization term in the optimization strategy;
and scanning the target optimization codes by using each preset scanning template to obtain all optimizable items corresponding to the optimization strategy.
The preset scanning template is a scanning algorithm template according to different optimization items in preset program codes. And acquiring a preset scanning template of each predicted optimization term in the optimization strategy, so that the optimizable term corresponding to each predicted optimization term in the optimization strategy can be accurately acquired from the program code. Further, if the optimization term is not scanned from the program code according to a scan template, it is stated that the optimization term that is not scanned does not need to be optimized in the program code.
In step S140, a target optimization term is obtained from all the optimization terms corresponding to the optimization strategy.
In the embodiment of the present example, all optimizable items corresponding to the optimization policy are all optimizable items found according to the optimization policy in the target optimization code. The target optimization term is obtained from all optimizable terms, namely, each term performance of the program code can be considered, and meanwhile, part of optimization terms of the optimization target can be realized, namely, the target optimization term for ensuring future performance of the program code can be obtained. Therefore, the target optimization item which is suitable for the optimization target can be accurately obtained, and further the efficiency and accuracy of program code optimization are effectively ensured.
In one embodiment of this example, the obtaining a target optimization term from all the optimizable terms corresponding to the optimization policy includes:
acquiring a preset optimization term management list, wherein the preset optimization term management list comprises performance contribution values of optimized performance parameters and performance consumption values of the optimized performance parameters;
and acquiring a plurality of optimization items from all the optimizable items corresponding to the optimization strategy according to a preset rule and taking the optimization items as the target optimization items according to the performance contribution value of each performance parameter and the performance consumption value of each performance parameter after the optimization.
The preset optimizing item management list is a preset list for managing information of all optimizing items, and the performance contribution value of each optimizing item after optimization and the performance consumption value of each performance parameter are recorded in the list, for example, a certain optimizing item can improve the operation efficiency by 1 after optimization, that is, the performance contribution value is 1. At the same time, the resource occupation is increased by 2%, namely the performance consumption value is 2%. And then, according to the performance contribution value of each performance parameter after optimization and the performance consumption value of each performance parameter, acquiring a plurality of optimization items from all optimizable items corresponding to the optimization strategy according to a preset rule, and taking the optimization items as target optimization items, namely, acquiring a plurality of optimization items which ensure good overall performance of the program code by analyzing the overall performance contribution of each optimization item to the program code after optimization, and finishing the optimization target.
In one embodiment of the present example, the obtaining, according to the performance contribution value of each performance parameter after the optimization and the performance consumption value of each performance parameter, a plurality of optimization terms from all the optimizable terms corresponding to the optimization policy according to a predetermined rule, as the target optimization term includes:
And acquiring a plurality of optimization items, of which the sum of the performance contribution values of all the optimizable items to the optimization target parameters is larger than a preset threshold value, and the performance consumption values of the other performance parameters except the optimization target parameters are smaller than the preset threshold value, as the target optimization items.
The sum of the performance contributions of the optimization target parameters is the sum of the contributions to the performance to be optimized in the optimization target parameters, such as the contribution to the operating efficiency. The performance consumption value of the performance parameters other than the optimization target parameters is, for example, a performance consumption value of the performance such as the resource occupation except the operation efficiency which needs to be optimized. And obtaining a plurality of optimization items, of which the sum of the performance contribution values to the optimization target parameters is larger than a preset threshold value and the performance consumption values to the other performance parameters except the optimization target parameters are smaller than the preset threshold value, from all the optimizable items, and taking the optimization items as target optimization items, so that precursors of all the performances of the program code can be ensured, and the optimization target can be completed.
In one embodiment of the present example, after obtaining the target optimization term from all the optimizable terms corresponding to the optimization policy, the method further includes:
Obtaining an optimization example of the target optimization term from a preset optimization term optimization case database;
and sending the target optimization item and the optimization example to a target terminal to complete the optimization of the target program code.
The preset optimizing item optimizing case database stores optimizing examples of various optimizing items under different code environments, and the user can efficiently and accurately complete the optimization of the codes by acquiring the optimizing examples of the target optimizing items and sending the target optimizing items and the optimizing examples to the target terminal.
The disclosure also provides a code optimization term acquisition device. Referring to fig. 4, the code optimization term acquisition device may include a parameter acquisition module 410, a prediction module 420, a scan module 430, and a target acquisition module 440. Wherein:
the parameter obtaining module 410 may be configured to, when receiving an optimization request for a target program code, obtain, from the optimization request, a performance test parameter, an optimization target parameter, a code running environment parameter, and a program code development parameter for the target program code;
the prediction module 420 may be configured to input the input data of the performance test parameter, the optimization target parameter, the code running environment parameter, and the program code development parameter into a pre-trained machine learning model to obtain an optimization strategy for the target program code;
The scanning module 430 may be configured to scan the target optimization code according to the optimization policy, to obtain all optimization terms corresponding to the optimization policy;
the target obtaining module 440 may be configured to obtain a target optimization term from all optimization terms corresponding to the optimization strategy.
The specific details of each module in the above-mentioned code optimization term acquisition device have been described in detail in the corresponding code optimization term acquisition method, so that the details are not repeated here.
It should be noted that although in the above detailed description several modules or units of a device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit in accordance with embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into a plurality of modules or units to be embodied.
Furthermore, although the steps of the methods in the present disclosure are depicted in a particular order in the drawings, this does not require or imply that the steps must be performed in that particular order or that all illustrated steps be performed in order to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform, etc.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.) or on a network, including several instructions to cause a computing device (may be a personal computer, a server, a mobile terminal, or a network device, etc.) to perform the method according to the embodiments of the present disclosure.
In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
Those skilled in the art will appreciate that the various aspects of the invention may be implemented as a system, method, or program product. Accordingly, aspects of the invention may be embodied in the following forms, namely: an entirely hardware embodiment, an entirely software embodiment (including firmware, micro-code, etc.) or an embodiment combining hardware and software aspects may be referred to herein as a "circuit," module "or" system.
An electronic device 500 according to such an embodiment of the invention is described below with reference to fig. 5. The electronic device 500 shown in fig. 5 is merely an example, and should not be construed as limiting the functionality and scope of use of embodiments of the present invention.
As shown in fig. 5, the electronic device 500 is embodied in the form of a general purpose computing device. The components of electronic device 500 may include, but are not limited to: the at least one processing unit 510, the at least one memory unit 520, and a bus 530 connecting the various system components, including the memory unit 520 and the processing unit 510.
Wherein the storage unit stores program code that is executable by the processing unit 510 such that the processing unit 510 performs steps according to various exemplary embodiments of the present invention described in the above section of the "exemplary method" of the present specification. For example, the processing unit 510 may perform step S110 as shown in fig. 1: when an optimization request for target program codes is received, acquiring performance test parameters, optimization target parameters, code running environment parameters and program code development parameters for the target program codes from the optimization request; s120: inputting the input data of the performance test parameters, the optimization target parameters, the code running environment parameters and the program code development parameters into a pre-trained machine learning model to obtain an optimization strategy for the target program code; step S130: scanning the target optimization codes according to the optimization strategy to obtain all optimization items corresponding to the optimization strategy; step S140: and acquiring target optimization items from all the optimization items corresponding to the optimization strategies.
The storage unit 520 may include readable media in the form of volatile storage units, such as Random Access Memory (RAM) 5201 and/or cache memory unit 5202, and may further include Read Only Memory (ROM) 5203.
The storage unit 520 may also include a program/utility 5204 having a set (at least one) of program modules 5205, such program modules 5205 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment.
Bus 530 may be one or more of several types of bus structures including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The electronic device 500 may also communicate with one or more external devices 700 (e.g., keyboard, pointing device, bluetooth device, etc.), one or more devices that enable a client to interact with the electronic device 500, and/or any device (e.g., router, modem, etc.) that enables the electronic device 500 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 550. Also, electronic device 500 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet, through network adapter 560. As shown, network adapter 560 communicates with other modules of electronic device 500 over bus 530. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with electronic device 500, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.) or on a network, including several instructions to cause a computing device (may be a personal computer, a server, a terminal device, or a network device, etc.) to perform the method according to the embodiments of the present disclosure.
In an exemplary embodiment of the present disclosure, a computer-readable storage medium having stored thereon a program product capable of implementing the method described above in the present specification is also provided. In some possible embodiments, the various aspects of the invention may also be implemented in the form of a program product comprising program code for causing a terminal device to carry out the steps according to the various exemplary embodiments of the invention as described in the "exemplary methods" section of this specification, when said program product is run on the terminal device.
Referring to fig. 6, a program product 600 for implementing the above-described method according to an embodiment of the present invention is described, which may employ a portable compact disc read only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto, and in this document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium would include the following: an electrical connection having one or more wires, a portable disk, a hard disk, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The computer readable signal medium may include a data signal propagated in baseband or as part of a carrier wave with readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the client computing device, partly on the client device, as a stand-alone software package, partly on the client computing device and partly on a remote computing device or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the client computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., connected via the Internet using an Internet service provider).
Furthermore, the above-described drawings are only schematic illustrations of processes included in the method according to the exemplary embodiment of the present invention, and are not intended to be limiting. It will be readily appreciated that the processes shown in the above figures do not indicate or limit the temporal order of these processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, for example, among a plurality of modules.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any adaptations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

Claims (9)

1. A code optimization term acquisition method, comprising:
when an optimization request for target program codes is received, acquiring performance test parameters, optimization target parameters, code running environment parameters and program code development parameters for the target program codes from the optimization request; the program code development parameters include the purpose of the program code;
Inputting the input data of the performance test parameters, the optimization target parameters, the code running environment parameters and the program code development parameters into a pre-trained machine learning model to obtain an optimization strategy for the target program code;
scanning the target program code according to the optimization strategy to obtain all optimization items corresponding to the optimization strategy;
acquiring a preset optimization term management list, wherein the preset optimization term management list comprises performance contribution values of optimized performance parameters and performance consumption values of the optimized performance parameters;
and obtaining a plurality of optimization items from all the optimization items corresponding to the optimization strategy according to a preset rule and taking the optimization items as target optimization items according to the performance contribution value of each performance parameter after the optimization and the performance consumption value of each performance parameter.
2. The method of claim 1, wherein inputting the input data of the performance test parameters, optimization target parameters, code running environment parameters, and program code development parameters into a pre-trained machine learning model to obtain an optimization strategy for the target program code comprises:
Acquiring a preset input data template, wherein the preset input data template comprises an associated storage area of the same attribute parameters in performance test parameters and optimization target parameters, a code running environment parameter storage area and a program code development parameter storage area;
storing the performance test parameters and parameters with the same attribute in the optimization target parameters in the associated storage area in an associated mode, storing the code running environment parameters in the code running environment parameter storage area, and storing the program code development parameters in the program code development parameter storage area to obtain an input data template;
normalizing the input data template into input data, and inputting a pre-trained machine learning model to obtain an optimization strategy for the target program code.
3. The method of claim 1, wherein the optimization strategy is an optimization term list comprising a plurality of predictive optimization terms,
and scanning the target program code according to the optimization strategy to obtain all optimization items corresponding to the optimization strategy, wherein the method comprises the following steps:
acquiring a preset scanning template of each prediction optimization term in the optimization strategy;
And scanning the target program codes by using each preset scanning template to obtain all optimization items corresponding to the optimization strategy.
4. The method according to claim 1, wherein the obtaining, according to a predetermined rule, a plurality of optimization terms from all the optimization terms corresponding to the optimization policy according to the performance contribution value of each performance parameter after the optimization and the performance consumption value of each performance parameter, as target optimization terms, includes:
and acquiring a plurality of optimization items, of which the sum of the performance contribution values of all the optimization items to the optimization target parameters is larger than a preset threshold value, and the performance consumption values of the other performance parameters except the optimization target parameters are smaller than the preset threshold value, as the target optimization items.
5. The method according to claim 1, wherein the method further comprises:
obtaining an optimization example of the target optimization term from a preset optimization term optimization case database;
and sending the target optimization item and the optimization example to a target terminal to complete the optimization of the target program code.
6. The method of claim 1, wherein the training method of the machine learning model is:
Collecting a sample set of performance test parameters, optimization target parameters, code running environment parameters and program code development parameters, wherein each sample in the sample set is calibrated with an optimization strategy of a corresponding program code in advance;
inputting the input data of each sample in the sample set into a machine learning model to obtain a prediction optimization strategy of a program code corresponding to each sample;
if the prediction optimization strategy of the program code corresponding to the sample obtained after the sample is input into the machine learning model is inconsistent with the optimization strategy of the program code corresponding to the sample calibrated in advance, the coefficient of the machine learning model is adjusted to be consistent;
when all the samples are input into a machine learning model, the obtained prediction optimization strategy of the program codes corresponding to the samples is consistent with the optimization strategy of the program codes corresponding to the samples calibrated in advance, and training is finished.
7. A code optimization term acquisition apparatus, comprising:
the system comprises a parameter acquisition module, a program code development module and a program code optimization module, wherein the parameter acquisition module is used for acquiring performance test parameters, optimization target parameters, code running environment parameters and program code development parameters of target program codes from an optimization request when the optimization request of the target program codes is received; the program code development parameters include the purpose of the program code;
The prediction module is used for inputting the input data of the performance test parameters, the optimization target parameters, the code running environment parameters and the program code development parameters into a pre-trained machine learning model to obtain an optimization strategy for the target program code;
the scanning module is used for scanning the target program codes according to the optimization strategy to obtain all optimization items corresponding to the optimization strategy;
the target acquisition module is used for acquiring a preset optimization term management list, wherein the preset optimization term management list comprises performance contribution values of each performance parameter after optimization and performance consumption values of each performance parameter; and obtaining a plurality of optimization items from all the optimization items corresponding to the optimization strategy according to a preset rule and taking the optimization items as target optimization items according to the performance contribution value of each performance parameter after the optimization and the performance consumption value of each performance parameter.
8. A computer readable storage medium having stored thereon a code optimisation retrieval program, wherein the code optimisation retrieval program when executed by a processor implements the method of any one of claims 1 to 6.
9. An electronic device, comprising:
A processor; and
a memory for storing a code optimization term acquisition program of the processor; wherein the processor is configured to perform the method of any of claims 1-6 via execution of the code optimization term acquisition program.
CN201910854837.5A 2019-09-10 2019-09-10 Code optimization item acquisition method and device, storage medium and electronic equipment Active CN110727437B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910854837.5A CN110727437B (en) 2019-09-10 2019-09-10 Code optimization item acquisition method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910854837.5A CN110727437B (en) 2019-09-10 2019-09-10 Code optimization item acquisition method and device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN110727437A CN110727437A (en) 2020-01-24
CN110727437B true CN110727437B (en) 2024-04-09

Family

ID=69217998

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910854837.5A Active CN110727437B (en) 2019-09-10 2019-09-10 Code optimization item acquisition method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN110727437B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111580828B (en) * 2020-04-30 2021-08-27 腾讯科技(深圳)有限公司 Compiling optimization method and device of machine learning model
CN112862013A (en) * 2021-03-31 2021-05-28 中国工商银行股份有限公司 Problem diagnosis method and device for quantitative transaction strategy
CN116069387B (en) * 2023-03-03 2023-08-29 北京特纳飞电子技术有限公司 Storage device adaptation method, adaptation device, storage device and readable storage medium
CN116302041B (en) * 2023-04-06 2023-11-21 北京拙河科技有限公司 Optimization method and device for light field camera interface module
CN116909620A (en) * 2023-09-11 2023-10-20 北京集度科技有限公司 Program optimization method, platform, device and storage medium
CN117908902B (en) * 2024-03-12 2024-06-07 苏州元脑智能科技有限公司 Performance optimization method, device, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1930552A (en) * 2004-01-14 2007-03-14 原子能源局 System for automatically generating optimised codes
US9268537B1 (en) * 2014-04-29 2016-02-23 The Mathworks, Inc. Automatic generation of domain-aware phase ordering for effective optimization of code for a model
CN105930277A (en) * 2016-07-11 2016-09-07 南京大学 Defect source code locating method based on defect report analysis
CN105955709A (en) * 2016-04-16 2016-09-21 浙江大学 Prefetching energy efficiency optimization adaptive device and method based on machine learning
CN106970819A (en) * 2017-03-28 2017-07-21 清华大学 A kind of c program code specification check device based on the regular description languages of PRDL

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1930552A (en) * 2004-01-14 2007-03-14 原子能源局 System for automatically generating optimised codes
US9268537B1 (en) * 2014-04-29 2016-02-23 The Mathworks, Inc. Automatic generation of domain-aware phase ordering for effective optimization of code for a model
CN105955709A (en) * 2016-04-16 2016-09-21 浙江大学 Prefetching energy efficiency optimization adaptive device and method based on machine learning
CN105930277A (en) * 2016-07-11 2016-09-07 南京大学 Defect source code locating method based on defect report analysis
CN106970819A (en) * 2017-03-28 2017-07-21 清华大学 A kind of c program code specification check device based on the regular description languages of PRDL

Also Published As

Publication number Publication date
CN110727437A (en) 2020-01-24

Similar Documents

Publication Publication Date Title
CN110727437B (en) Code optimization item acquisition method and device, storage medium and electronic equipment
CN110852421B (en) Model generation method and device
CN111460250B (en) Image data cleaning method, image data cleaning device, image data cleaning medium, and electronic apparatus
CN111343161B (en) Abnormal information processing node analysis method, abnormal information processing node analysis device, abnormal information processing node analysis medium and electronic equipment
CN111143226B (en) Automatic test method and device, computer readable storage medium and electronic equipment
CN109726763A (en) A kind of information assets recognition methods, device, equipment and medium
CN108694221B (en) Data real-time analysis method, module, equipment and device
CN113837596B (en) Fault determination method and device, electronic equipment and storage medium
CN109872230B (en) Test method and device of financial data analysis system, medium and electronic equipment
CN112684396B (en) Data preprocessing method and system for electric energy meter operation error monitoring model
CN111900694B (en) Relay protection equipment information acquisition method and system based on automatic identification
CN110348471B (en) Abnormal object identification method, device, medium and electronic equipment
CN112287603A (en) Prediction model construction method and device based on machine learning and electronic equipment
CN111913931A (en) Method and device for constructing vehicle fault database, storage medium and electronic equipment
CN114691148A (en) Model reasoning acceleration method and device, electronic equipment and storage medium
CN117608630A (en) Code quality detection method, device, equipment and storage medium
CN117931583B (en) Equipment cluster running state prediction method, electronic equipment and storage medium
CN113868214A (en) Log storage method and device, electronic equipment and computer readable medium
CN111582649B (en) Risk assessment method and device based on user APP single-heat coding and electronic equipment
CN110716949A (en) Method, device, medium and electronic equipment for automatically optimizing structured query statement
CN112785556A (en) Reinspection method, reinspection device, electronic equipment and computer-readable storage medium
CN111400414A (en) Decision-making method and system based on standardized enterprise data and electronic equipment
CN110716859A (en) Method for automatically pushing test cases for modified codes and related device
CN110083807B (en) Contract modification influence automatic prediction method, device, medium and electronic equipment
CN114237182B (en) Robot scheduling method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant