CN114064012A - Dynamic and static combined interface code generation method and system and electronic equipment - Google Patents

Dynamic and static combined interface code generation method and system and electronic equipment Download PDF

Info

Publication number
CN114064012A
CN114064012A CN202210051542.6A CN202210051542A CN114064012A CN 114064012 A CN114064012 A CN 114064012A CN 202210051542 A CN202210051542 A CN 202210051542A CN 114064012 A CN114064012 A CN 114064012A
Authority
CN
China
Prior art keywords
code
interface
program
static
dynamic
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.)
Granted
Application number
CN202210051542.6A
Other languages
Chinese (zh)
Other versions
CN114064012B (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.)
Beijing Huiyuanwang Technology Co ltd
Original Assignee
Beijing Huiyuanwang Technology 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 Beijing Huiyuanwang Technology Co ltd filed Critical Beijing Huiyuanwang Technology Co ltd
Priority to CN202210051542.6A priority Critical patent/CN114064012B/en
Publication of CN114064012A publication Critical patent/CN114064012A/en
Application granted granted Critical
Publication of CN114064012B publication Critical patent/CN114064012B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/51Source to source

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a dynamic and static combined interface code generation method, a system and electronic equipment. The scheme includes the steps of obtaining a current running program setting condition and a future modified program setting condition, calculating to obtain a first intelligent margin corresponding to a current program and a second intelligent margin corresponding to a future program, judging whether a normal adjustment instruction is sent or not, obtaining the normal adjustment instruction, calculating a substitution advantage level, sending a starting adjustment instruction or an integral code generation instruction according to the substitution advantage level, compiling an interface definition to generate a static interface after obtaining the starting adjustment instruction, generating an embedded code block to generate a dynamic code according to the static interface, and performing online test deployment after obtaining the static interface and the dynamic code. According to the scheme, interface deviation adjustment is carried out by dynamically adjusting the interface definition text file, and automatic program solidification execution efficiency loss analysis is combined, so that the interface efficiency can be improved, and the execution efficiency of the algorithm cannot be influenced.

Description

Dynamic and static combined interface code generation method and system and electronic equipment
Technical Field
The invention relates to the technical field of software generation, in particular to a dynamic and static combined interface code generation method, a system and electronic equipment.
Background
In order to improve the efficiency of programming, it is necessary to accurately and efficiently generate a written algorithm or program into executable code through a preset code generator.
Before the technology of the invention, the existing technology mainly generates codes in the following two ways, namely 1) generating an entity, a data operation class and a front-end page code based on table definition of a database; 2) generating an interface based on the API interface definition. The above methods are all code generation by static method, each generation is one time, if modification is needed subsequently, there is no way to solidify part of the code. This is particularly true during the use of embedded artificial intelligence chips, because the static code of the algorithm of the artificial intelligence chip is written after optimization, whereas the dynamic algorithm necessarily requires a large portion of the area to be solidified and not to change every time.
Disclosure of Invention
In view of the above problems, the present invention provides a dynamic and static combined interface code generation method, system and electronic device, which perform interface deviation adjustment by dynamically adjusting an interface definition text file, and combine with automatic program solidification execution efficiency loss analysis, so as to improve interface efficiency without affecting execution efficiency of an algorithm.
According to a first aspect of the embodiments of the present invention, a dynamic and static combined interface code generation method is provided.
In one or more embodiments, preferably, the method for generating dynamic and static combined interface codes includes:
obtaining the current program setting condition and the future program modification setting condition, and calculating to obtain a first intelligent margin corresponding to the current program and a second intelligent margin corresponding to the future program;
independently extracting the first intelligent margin and the second intelligent margin, and judging whether to send a normal adjustment instruction;
acquiring the normal adjustment instruction, calculating a substitute advantage level, and sending an adjustment starting command or an integral code generating command according to the size of the substitute advantage level;
after the adjustment starting command is obtained, compiling an interface definition to generate a static interface;
generating an embedded code block according to the static interface to generate a dynamic code;
and after the static interface and the dynamic code are obtained, performing on-line test deployment.
In one or more embodiments, preferably, the obtaining a current running program setting condition and a future modified program setting condition, and calculating to obtain a first intelligent margin corresponding to the current program and a second intelligent margin corresponding to the future program specifically includes:
acquiring the current on-going program setting condition, wherein the on-going program setting condition comprises the total operation time of original codes and the operation time of original solidified codes;
obtaining future modified program setting conditions, wherein the modified program setting conditions comprise future solidified code operation time and future code total operation time;
calculating a first curing proportion by using a first calculation formula according to the total operation time of the original code and the operation time of the original curing code;
calculating a second curing proportion by using a second calculation formula according to the future curing code operation time and the future code total operation time;
setting a preset solidification increasing ratio of a current running process, and calculating first calculation example time by using a third calculation formula according to the first solidification ratio;
calculating a second example time by using a fourth calculation formula according to the second curing proportion;
calculating the first intelligent margin by using a fifth calculation formula according to the first example time and the upper limit of the program operation period;
calculating the second intelligent margin by using a sixth calculation formula according to the second example time and the upper limit of the program operation period;
the first calculation formula is:
G1=tg1/ tz1
wherein G is1Is the first curing ratio, tg1Operating time, t, for the original solidification codez1Calculating the total operation time for the original code;
the second calculation formula is:
G2=tg2/ tz2
wherein G is2Is the second curing ratio, tg2Operating time, t, for the future solidification codez2Calculating the total operation time for the future code;
the third calculation formula is:
T1=G1A+ tz1
wherein A is the preset curing increase ratio and T is1Is the first example time;
the fourth calculation formula is:
T2=G2A+ tz2
wherein, T2Is the second example time;
the fifth calculation formula is:
Y1=0.8Tmax- T1
wherein, TmaxIs the upper limit of the program run period, Y1Is the first smart margin;
the sixth calculation formula is:
Y2=0.8Tmax- T2
wherein, Y2Is the second smart margin.
In one or more embodiments, preferably, the separately extracting the first intelligent margin and the second intelligent margin, and determining whether to issue a normal adjustment instruction specifically includes:
extracting the first intelligent margin and the second intelligent margin separately;
judging whether the first intelligent margin is larger than zero, and if not, outputting a first state abnormal command;
judging whether the second intelligent margin is larger than zero, and if not, outputting a second state abnormal command;
and if the command is the first state abnormal command or the second state abnormal command, sending the normal adjustment command.
In one or more embodiments, preferably, the obtaining the normal adjustment instruction, calculating an alternative advantage level, and issuing a start adjustment command or an overall code generation command according to the size of the alternative advantage level includes:
after the normal adjustment instruction is obtained, setting a preset utilization coefficient of equipment where a program is located;
acquiring an original code generation cost and a new code generation cost;
obtaining the generation times of the codes, and calculating the alternative advantage level by using a seventh calculation formula;
when the substitution advantage level is greater than a preset substitution limit, sending the adjustment starting command, otherwise, sending the whole code generating command;
the seventh calculation formula is:
L=Y2-Y1-C×K×(X1-X0)
wherein L is the alternative advantage level, C is the code generation frequency, K is the preset utilization coefficient, and X is1Generating a cost, X, for the new code0Generating a cost for the original code.
In one or more embodiments, preferably, after obtaining the start adjustment command, writing an interface definition to generate a static interface includes:
after the adjustment starting command is acquired, defining all metadata contents related to business logic;
the reference interpreter is used for calling the interface definition code to perform interface logic writing;
after the interface definition is written, the static interface is generated.
In one or more embodiments, preferably, the generating an embedded code block according to the static interface to generate a dynamic code specifically includes:
judging whether the interface definition of the current code has deviation or not according to the static interface;
if the interface definition has deviation, eliminating the deviation by dynamically adjusting the interface and generating a program template;
if the interface definition has no deviation, generating the program template;
and generating an embedded code block according to the program template to generate the dynamic code.
In one or more embodiments, preferably, after obtaining the static interface and the dynamic code, performing online test deployment specifically includes:
after the static interface and the dynamic code are obtained, an interface form is obtained, wherein the interface form comprises a parameter name, a data type, a maximum length, whether the interface can be empty or not, Chinese description and an effectiveness checking rule;
automatically generating a solidified static code and generating an artificial dynamic code through a custom domain language;
and combining the solidified static code and the manual dynamic code to generate a test program, and performing on-line test deployment.
According to a second aspect of the embodiments of the present invention, a dynamic and static combined interface code generation system is provided.
In one or more embodiments, preferably, the system for generating dynamic and static combined interface codes comprises:
the code execution analysis module is used for obtaining the current program setting condition and the future program modification setting condition, and calculating and obtaining a first intelligent margin corresponding to the current program and a second intelligent margin corresponding to the future program;
the first judgment module is used for independently extracting the first intelligent margin and the second intelligent margin and judging whether to send a normal adjustment instruction or not;
the second judgment module is used for acquiring the normal adjustment instruction, calculating a substitution advantage level and sending an adjustment starting command or an integral code generation command according to the size of the substitution advantage level;
the user-defined interface module is used for compiling interface definition and generating a static interface after the adjustment starting command is obtained;
the embedded code generation module is used for generating an embedded code block according to the static interface to generate a dynamic code;
and the test deployment module is used for carrying out on-line test deployment after the static interface and the dynamic code are obtained.
The dynamic and static combined interface code generation system further comprises: a readable storage medium to store the static interface and the dynamic code.
According to a third aspect of embodiments of the present invention, there is provided an electronic device, comprising a memory and a processor, the memory being configured to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method of any one of the first aspect of embodiments of the present invention.
The technical scheme provided by the embodiment of the invention can have the following beneficial effects:
in the embodiment of the invention, an interface definition code interpretation execution mode is adopted in the early stage of interface development, the efficiency of interface development is improved, the response performance and the operation efficiency of an interface are improved in the later stage of development, and the interface definition code is converted into a local code by adopting a code generation mode.
In the embodiment of the invention, the current algorithm execution efficiency loss degree and the program part curing cost are analyzed in an online self-adaptive manner, and the generation of the dynamic and static combined interface code is automatically coordinated.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
The technical solution of the present invention is further described in detail by the accompanying drawings and embodiments.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart of a dynamic and static combined interface code generation method according to an embodiment of the present invention.
Fig. 2 is a flowchart of obtaining a current program setting condition and a future modified program setting condition, and calculating to obtain a first intelligent margin corresponding to a current program and a second intelligent margin corresponding to a future program in a dynamic and static combined interface code generation method according to an embodiment of the present invention.
Fig. 3 is a flowchart of separately extracting the first intelligent margin and the second intelligent margin and determining whether to issue a normal adjustment instruction in the dynamic and static combined interface code generation method according to an embodiment of the present invention.
Fig. 4 is a flowchart of acquiring the normal adjustment instruction, calculating an alternative advantage level, and issuing a start adjustment command or an entire code generation command according to the size of the alternative advantage level in the dynamic-static combined interface code generation method according to an embodiment of the present invention.
Fig. 5 is a flowchart of writing an interface definition to generate a static interface after acquiring the start adjustment command in the dynamic and static combined interface code generation method according to an embodiment of the present invention.
Fig. 6 is a flowchart of generating an embedded code block according to the static interface to generate a dynamic code in the dynamic and static combined interface code generation method according to an embodiment of the present invention.
Fig. 7 is a flowchart of performing on-line test deployment after the static interface and the dynamic code are obtained in a dynamic and static combined interface code generation method according to an embodiment of the present invention.
Fig. 8 is a block diagram of a dynamic-static interface code generation system according to an embodiment of the present invention.
Fig. 9 is a block diagram of an electronic device in one embodiment of the invention.
Detailed Description
In some of the flows described in the present specification and claims and in the above figures, a number of operations are included that occur in a particular order, but it should be clearly understood that these operations may be performed out of order or in parallel as they occur herein, with the order of the operations being indicated as 101, 102, etc. merely to distinguish between the various operations, and the order of the operations by themselves does not represent any order of performance. Additionally, the flows may include more or fewer operations, and the operations may be performed sequentially or in parallel. It should be noted that, the descriptions of "first", "second", etc. in this document are used for distinguishing different messages, devices, modules, etc., and do not represent a sequential order, nor limit the types of "first" and "second" to be different.
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to improve the efficiency of programming, it is necessary to accurately and efficiently generate a written algorithm or program into executable code through a preset code generator.
Before the technology of the invention, the existing technology mainly generates codes in the following two ways, namely 1) generating an entity, a data operation class and a front-end page code based on table definition of a database; 2) generating an interface based on the API interface definition. The above methods are all code generation by static method, each generation is one time, if modification is needed subsequently, there is no way to solidify part of the code. This is particularly true during the use of embedded artificial intelligence chips, because the static code of the algorithm of the artificial intelligence chip is written after optimization, whereas the dynamic algorithm necessarily requires a large portion of the area to be solidified and not to change every time.
The embodiment of the invention provides a dynamic and static combined interface code generation method, a system and electronic equipment. According to the scheme, interface deviation adjustment is carried out by dynamically adjusting the interface definition text file, and automatic program solidification execution efficiency loss analysis is combined, so that the interface efficiency can be improved, and the execution efficiency of the algorithm cannot be influenced.
Fig. 1 is a flowchart of a dynamic and static combined interface code generation method according to an embodiment of the present invention.
According to a first aspect of the embodiments of the present invention, a dynamic and static combined interface code generation method is provided.
In one or more embodiments, preferably, the method for generating dynamic and static combined interface codes includes:
s101, obtaining a current program setting condition and a future program modification setting condition, and calculating to obtain a first intelligent margin corresponding to a current program and a second intelligent margin corresponding to a future program;
s102, independently extracting the first intelligent margin and the second intelligent margin, and judging whether a normal adjustment instruction is sent;
s103, acquiring the normal adjustment instruction, calculating a substitute advantage level, and sending an adjustment starting command or an integral code generating command according to the size of the substitute advantage level;
s104, after the adjustment starting command is obtained, compiling an interface definition to generate a static interface;
s105, generating an embedded code block according to the static interface to generate a dynamic code;
and S106, after the static interface and the dynamic code are obtained, performing on-line test deployment.
In the embodiment of the invention, an interface definition code interpretation execution mode is adopted at the early stage of interface development, the efficiency of interface development is improved, the response performance and the operation efficiency of an interface are improved at the later stage of development, a code generation mode is adopted, the interface definition code is converted into a local code, in order to improve the programming efficiency of the code, the interface is subjected to self-adaptive adjustment in the code receiving process, and whether a partially cured programming mode is carried out or not is determined through analysis.
Fig. 2 is a flowchart of obtaining a current program setting condition and a future modified program setting condition, and calculating to obtain a first intelligent margin corresponding to a current program and a second intelligent margin corresponding to a future program in a dynamic and static combined interface code generation method according to an embodiment of the present invention.
As shown in fig. 2, in one or more embodiments, preferably, the obtaining a current program setting situation and a future program modification setting situation, and calculating a first intelligent margin corresponding to the current program and a second intelligent margin corresponding to the future program, specifically include:
s201, obtaining the current running program setting condition, wherein the running program setting condition comprises the total operation time of original codes and the operation time of original solidified codes;
s202, obtaining future modified program setting conditions, wherein the modified program setting conditions comprise future solidified code operation time and future code total operation time;
s203, calculating a first curing proportion by using a first calculation formula according to the total operation time of the original code and the operation time of the original curing code;
s204, calculating a second curing proportion by using a second calculation formula according to the future curing code operation time and the future code total operation time;
s205, setting a preset solidification increasing ratio of a current running process, and calculating first example time by using a third calculation formula according to the first solidification ratio;
s206, calculating second example time by using a fourth calculation formula according to the second curing proportion;
s207, calculating the first intelligent margin by using a fifth calculation formula according to the first example time and the upper limit of the program operation period;
s208, calculating the second intelligent margin by using a sixth calculation formula according to the second example time and the upper limit of the program operation cycle;
the first calculation formula is:
G1=tg1/ tz1
wherein the content of the first and second substances,G1is the first curing ratio, tg1Operating time, t, for the original solidification codez1Calculating the total operation time for the original code;
the second calculation formula is:
G2=tg2/ tz2
wherein G is2Is the second curing ratio, tg2Operating time, t, for the future solidification codez2Calculating the total operation time for the future code;
the third calculation formula is:
T1=G1A+ tz1
wherein A is the preset curing increase ratio and T is1Is the first example time;
the fourth calculation formula is:
T2=G2A+ tz2
wherein, T2Is the second example time;
the fifth calculation formula is:
Y1=0.8Tmax- T1
wherein, TmaxIs the upper limit of the program run period, Y1Is the first smart margin;
the sixth calculation formula is:
Y2=0.8Tmax- T2
wherein, Y2Is the second smart margin.
In the embodiment of the present invention, in order to confirm whether the current program can dynamically adjust the total amount of each written program, detailed code segment calculation is performed. The calculation includes three types, the first type is calculation of program curing proportion, when the running time of the code of the program to be modified and the running time of a curing part are known, calculation of the curing proportion under the current original state and the future planning state is carried out, the curing proportion is an intermediate variable, the curing proportion is mainly used for carrying out the second part of calculation, the second part of calculation is mainly used for calculating the calculation time, the calculation time mainly reflects the possible time occupation condition of the current running program after modification, and further, the third step is carried out by utilizing the time occupation condition.
Fig. 3 is a flowchart of separately extracting the first intelligent margin and the second intelligent margin and determining whether to issue a normal adjustment instruction in the dynamic and static combined interface code generation method according to an embodiment of the present invention.
As shown in fig. 3, in one or more embodiments, preferably, the separately extracting the first intelligent margin and the second intelligent margin, and determining whether to issue a normal adjustment instruction specifically includes:
s301, independently extracting the first intelligent margin and the second intelligent margin;
s302, judging whether the first intelligent margin is larger than zero, and outputting a first state abnormal command if the first intelligent margin is not larger than zero;
s303, judging whether the second intelligent margin is larger than zero, and outputting a second state abnormal command if the second intelligent margin is not larger than zero;
s304, if the first state abnormal command or the second state abnormal command is received, the normal adjusting instruction is sent out.
In the embodiment of the invention, the first intelligent margin and the second intelligent margin are two parameters which respectively correspond to two kinds of exceptions, the original replacement process can be stopped no matter which kind of exceptions exists, and if the original program and the new program do not have exception commands, normal adjustment is carried out, and corresponding normal adjustment instructions are sent out.
Fig. 4 is a flowchart of acquiring the normal adjustment instruction, calculating an alternative advantage level, and issuing a start adjustment command or an entire code generation command according to the size of the alternative advantage level in the dynamic-static combined interface code generation method according to an embodiment of the present invention.
As shown in fig. 4, in one or more embodiments, preferably, the obtaining the normal adjustment instruction, calculating an alternative advantage level, and issuing a start adjustment command or an overall code generation command according to the size of the alternative advantage level specifically includes:
s401, after the normal adjustment instruction is obtained, setting a preset utilization rate coefficient of equipment where a program is located;
s402, acquiring the generation cost of the original code and the generation cost of the new code;
s403, obtaining the code generation times, and calculating the alternative advantage level by using a seventh calculation formula;
s404, when the substitution advantage level is larger than a preset substitution limit, the adjustment starting command is sent out, otherwise, the integral code generating command is sent out;
the seventh calculation formula is:
L=Y2-Y1-C×K×(X1-X0)
wherein L is the alternative advantage level, C is the code generation frequency, K is the preset utilization coefficient, and X is1Generating a cost, X, for the new code0Generating a cost for the original code.
In the embodiment of the present invention, after receiving a normal adjustment instruction, the program performs calculation of the substitution advantage level according to the preset utilization factor and the specific code running times, and if the calculated value is high enough, the mentioned high enough mainly means that the adjustment start instruction is issued when the data can be larger than the preset substitution limit, and the adjustment start instruction is issued at this time.
Fig. 5 is a flowchart of writing an interface definition to generate a static interface after acquiring the start adjustment command in the dynamic and static combined interface code generation method according to an embodiment of the present invention.
As shown in fig. 5, in one or more embodiments, preferably, after obtaining the start adjustment command, writing an interface definition to generate a static interface includes:
s501, after the adjustment starting command is obtained, defining all metadata contents related to business logic;
s502, invoking an interpreter, and calling the interface definition code to perform interface logic writing through the interpreter;
s503, after the interface definition is compiled, the static interface is generated.
In the embodiment of the invention, after the adjustment is started, all metadata are designed through the business logic, and then the interpreter is used for calling the interface and generating the static interface. The interface definition language not only defines interface parameters, but also can define the complex action logic related to the interface. Such as interface request and return parameter checks, interface call procedures, etc. And providing an interpreter which supports the interpretation and execution of the service code logic source code, does not need to generate the code by using the interpreter, and is directly deployed on line. The method can be adopted for newly developed interfaces or interfaces with low debugging quantity, and the workload of development and debugging can be greatly reduced. The same interface definition can simultaneously support the logic and code generation of a server and a client; the generation process may be embedded in the compilation process as a step of the compilation process.
Fig. 6 is a flowchart of generating an embedded code block according to the static interface to generate a dynamic code in the dynamic and static combined interface code generation method according to an embodiment of the present invention.
As shown in fig. 6, in one or more embodiments, preferably, the generating an embedded code block according to the static interface to generate a dynamic code specifically includes:
s601, judging whether the interface definition of the current code has deviation or not according to the static interface;
s602, if the interface definition has deviation, eliminating the deviation by dynamically adjusting the interface, and generating a program template;
s603, if the interface definition has no deviation, generating the program template;
s604, generating an embedded code block according to the program template to generate the dynamic code.
In the embodiment of the invention, on the basis of obtaining the static interface, deviation analysis is carried out, if the interface deviation exists, the deviation is dynamically eliminated, a corresponding program template is generated, and then subsequent programming is prepared to generate a dynamic code.
Fig. 7 is a flowchart of performing on-line test deployment after the static interface and the dynamic code are obtained in a dynamic and static combined interface code generation method according to an embodiment of the present invention.
As shown in fig. 7, in one or more embodiments, preferably, after the static interface and the dynamic code are obtained, performing online test deployment specifically includes:
s701, after the static interface and the dynamic code are obtained, an interface form is obtained, wherein the interface form comprises a parameter name, a data type, a maximum length, whether the interface can be empty, Chinese description and an effectiveness checking rule;
s702, automatically generating a solidified static code and generating an artificial dynamic code through a custom domain language;
and S703, combining the solidified static code and the artificial dynamic code to generate a test program, and performing online test deployment.
In the embodiment of the invention, under the condition that both the dynamic code and the interface are determined, the user-defined domain language is utilized to write the program, the deployment on the line is completed, and the complete code generation is realized; interface definitions based on this approach are described by custom domain languages. The custom domain language is separate from the actual programming language used to generate the source code. In actual work, only the business logic code file is modified, and codes of specific frame specific languages are generated according to frame requirements. The generated code is embedded in a project engineering source code file, and the manual maintenance code and the automatic generation code can be mixed together, so that a specific logic code outside the generated logic is conveniently realized, and the automatic generation part can generate a new code in time according to the change of the business logic definition.
According to a second aspect of the embodiments of the present invention, a dynamic and static combined interface code generation system is provided.
Fig. 8 is a block diagram of a dynamic-static interface code generation system according to an embodiment of the present invention.
In one or more embodiments, preferably, the system for generating dynamic and static combined interface codes comprises:
a code execution analysis module 801, configured to obtain a current program setting situation and a future program modification setting situation, and calculate to obtain a first intelligent margin corresponding to the current program and a second intelligent margin corresponding to the future program;
a first determining module 802, configured to separately extract the first intelligent margin and the second intelligent margin, and determine whether to send a normal adjustment instruction;
a second judgment module 803, configured to obtain the normal adjustment instruction, calculate a substitute advantage level, and issue an adjustment start command or an entire code generation command according to the size of the substitute advantage level;
a custom interface module 804, configured to compile an interface definition after obtaining the start adjustment command, and generate a static interface;
an embedded code generation module 805, configured to generate an embedded code block according to the static interface to generate a dynamic code;
and a test deployment module 806, configured to perform online test deployment after obtaining the static interface and the dynamic code.
The dynamic and static combined interface code generation system further comprises: a readable storage medium to store the static interface and the dynamic code.
In the embodiment of the invention, in order to effectively execute the code and further comprehensively adjust the execution efficiency of the whole system, on one hand, the efficiency can generally realize partial code generation, and on the other hand, the execution efficiency of the whole algorithm is not influenced.
According to a third aspect of the embodiments of the present invention, there is provided an electronic apparatus. Fig. 9 is a block diagram of an electronic device in one embodiment of the invention. The electronic device shown in fig. 9 is a general dynamic and static code generating apparatus, which includes a general computer hardware structure, and includes at least a processor 901 and a memory 902. The processor 901 and the memory 902 are connected by a bus 903. The memory 902 is adapted to store instructions or programs executable by the processor 901. Processor 901 may be a stand-alone microprocessor or a collection of one or more microprocessors. Thus, the processor 901 implements the processing of data and the control of other devices by executing instructions stored by the memory 902 to perform the method flows of embodiments of the present invention as described above. The bus 903 connects the above components together, as well as to the display controller 904 and display devices and input/output (I/O) devices 905. Input/output (I/O) devices 905 may be a mouse, keyboard, modem, network interface, touch input device, motion-sensing input device, printer, and other devices known in the art. Typically, the input/output devices 905 are connected to the system through an input/output (I/O) controller 906.
The technical scheme provided by the embodiment of the invention can have the following beneficial effects:
in the embodiment of the invention, an interface definition code interpretation execution mode is adopted in the early stage of interface development, the efficiency of interface development is improved, the response performance and the operation efficiency of an interface are improved in the later stage of development, and the interface definition code is converted into a local code by adopting a code generation mode.
In the embodiment of the invention, the current algorithm execution efficiency loss degree and the program part curing cost are analyzed in an online self-adaptive manner, and the generation of the dynamic and static combined interface code is automatically coordinated.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (10)

1. A dynamic and static combined interface code generation method is characterized by comprising the following steps:
obtaining the current program setting condition and the future program modification setting condition, and calculating to obtain a first intelligent margin corresponding to the current program and a second intelligent margin corresponding to the future program;
independently extracting the first intelligent margin and the second intelligent margin, and judging whether to send a normal adjustment instruction;
acquiring the normal adjustment instruction, calculating a substitute advantage level, and sending an adjustment starting command or an integral code generating command according to the size of the substitute advantage level;
after the adjustment starting command is obtained, compiling an interface definition to generate a static interface;
generating an embedded code block according to the static interface to generate a dynamic code;
and after the static interface and the dynamic code are obtained, performing on-line test deployment.
2. The method for generating dynamic and static combined interface codes according to claim 1, wherein the obtaining a current setting condition of the running program and a future setting condition of the modified program, and calculating to obtain a first intelligent margin corresponding to the current program and a second intelligent margin corresponding to the future program specifically comprises:
acquiring the current on-going program setting condition, wherein the on-going program setting condition comprises the total operation time of original codes and the operation time of original solidified codes;
obtaining future modified program setting conditions, wherein the modified program setting conditions comprise future solidified code operation time and future code total operation time;
calculating a first curing proportion by using a first calculation formula according to the total operation time of the original code and the operation time of the original curing code;
calculating a second curing proportion by using a second calculation formula according to the future curing code operation time and the future code total operation time;
setting a preset solidification increasing ratio of a current running process, and calculating first calculation example time by using a third calculation formula according to the first solidification ratio;
calculating a second example time by using a fourth calculation formula according to the second curing proportion;
calculating the first intelligent margin by using a fifth calculation formula according to the first example time and the upper limit of the program operation period;
calculating the second intelligent margin by using a sixth calculation formula according to the second example time and the upper limit of the program operation period;
the first calculation formula is:
G1=tg1/ tz1
wherein G is1Is the first curing ratio, tg1Operating time, t, for the original solidification codez1Calculating the total operation time for the original code;
the second calculation formula is:
G2=tg2/ tz2
wherein G is2Is the second curing ratio, tg2Operating time, t, for the future solidification codez2Calculating the total operation time for the future code;
the third calculation formula is:
T1=G1A+ tz1
wherein A is the preset curing increase ratio and T is1Is the first example time;
the fourth calculation formula is:
T2=G2A+ tz2
wherein, T2Is the second example time;
the fifth calculation formula is:
Y1=0.8Tmax- T1
wherein, TmaxIs the upper limit of the program run period, Y1Is the first smart margin;
the sixth calculation formula is:
Y2=0.8Tmax- T2
wherein, Y2Is the second smart margin.
3. The method for generating dynamic and static combined interface code according to claim 1, wherein the separately extracting the first intelligent margin and the second intelligent margin and determining whether to issue a normal adjustment instruction specifically includes:
extracting the first intelligent margin and the second intelligent margin separately;
judging whether the first intelligent margin is larger than zero, and if not, outputting a first state abnormal command;
judging whether the second intelligent margin is larger than zero, and if not, outputting a second state abnormal command;
and if the command is the first state abnormal command or the second state abnormal command, sending the normal adjustment command.
4. The method according to claim 1, wherein the obtaining the normal adjustment command, calculating an alternative advantage level, and issuing a start adjustment command or an overall code generation command according to the alternative advantage level specifically includes:
after the normal adjustment instruction is obtained, setting a preset utilization coefficient of equipment where a program is located;
acquiring an original code generation cost and a new code generation cost;
obtaining the generation times of the codes, and calculating the alternative advantage level by using a seventh calculation formula;
when the substitution advantage level is greater than a preset substitution limit, sending the adjustment starting command, otherwise, sending the whole code generating command;
the seventh calculation formula is:
L=Y2-Y1-C×K×(X1-X0)
wherein L is the alternative advantage level, C is the code generation frequency, K is the preset utilization coefficient, and X is1Generating a cost, X, for the new code0Generating a cost for the original code.
5. The method for generating dynamic and static combined interface codes according to claim 1, wherein after the start adjustment command is obtained, an interface definition is written to generate a static interface, and specifically includes:
after the adjustment starting command is acquired, defining all metadata contents related to business logic;
the reference interpreter is used for calling the interface definition code to perform interface logic writing;
after the interface definition is written, the static interface is generated.
6. The method according to claim 1, wherein the generating of the embedded code block into the dynamic code according to the static interface specifically includes:
judging whether the interface definition of the current code has deviation or not according to the static interface;
if the interface definition has deviation, eliminating the deviation by dynamically adjusting the interface and generating a program template;
if the interface definition has no deviation, generating the program template;
and generating an embedded code block according to the program template to generate the dynamic code.
7. The method for generating dynamic and static combined interface codes according to claim 1, wherein performing online test deployment after obtaining the static interface and the dynamic code specifically comprises:
after the static interface and the dynamic code are obtained, an interface form is obtained, wherein the interface form comprises a parameter name, a data type, a maximum length, whether the interface can be empty or not, Chinese description and an effectiveness checking rule;
automatically generating a solidified static code and generating an artificial dynamic code through a custom domain language;
and combining the solidified static code and the manual dynamic code to generate a test program, and performing on-line test deployment.
8. A dynamic and static combined interface code generation system, characterized in that the system comprises:
the code execution analysis module is used for obtaining the current program setting condition and the future program modification setting condition, and calculating and obtaining a first intelligent margin corresponding to the current program and a second intelligent margin corresponding to the future program;
the first judgment module is used for independently extracting the first intelligent margin and the second intelligent margin and judging whether to send a normal adjustment instruction or not;
the second judgment module is used for acquiring the normal adjustment instruction, calculating a substitution advantage level and sending an adjustment starting command or an integral code generation command according to the size of the substitution advantage level;
the user-defined interface module is used for compiling interface definition and generating a static interface after the adjustment starting command is obtained;
the embedded code generation module is used for generating an embedded code block according to the static interface to generate a dynamic code;
and the test deployment module is used for carrying out on-line test deployment after the static interface and the dynamic code are obtained.
9. The dynamic-static combined interface code generating system according to claim 8, further comprising: a readable storage medium to store the static interface and the dynamic code.
10. An electronic device comprising a memory and a processor, wherein the memory is configured to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method of any of claims 1-7.
CN202210051542.6A 2022-01-18 2022-01-18 Dynamic and static combined interface code generation method and system and electronic equipment Active CN114064012B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210051542.6A CN114064012B (en) 2022-01-18 2022-01-18 Dynamic and static combined interface code generation method and system and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210051542.6A CN114064012B (en) 2022-01-18 2022-01-18 Dynamic and static combined interface code generation method and system and electronic equipment

Publications (2)

Publication Number Publication Date
CN114064012A true CN114064012A (en) 2022-02-18
CN114064012B CN114064012B (en) 2022-03-29

Family

ID=80231195

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210051542.6A Active CN114064012B (en) 2022-01-18 2022-01-18 Dynamic and static combined interface code generation method and system and electronic equipment

Country Status (1)

Country Link
CN (1) CN114064012B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI800327B (en) * 2022-03-23 2023-04-21 慧榮科技股份有限公司 Data storage system and parameter margin evaluation method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2261802A1 (en) * 2009-06-10 2010-12-15 ITI Scotland Limited Automated debugging system and method
US20160378644A1 (en) * 2015-06-23 2016-12-29 International Business Machines Corporation Flexible configuration and control of a testing system
CN108256325A (en) * 2016-12-29 2018-07-06 中移(苏州)软件技术有限公司 A kind of method and apparatus of the detection of malicious code mutation
CN112099880A (en) * 2020-08-12 2020-12-18 北京大学 Method and system for reducing application program driven by scene

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2261802A1 (en) * 2009-06-10 2010-12-15 ITI Scotland Limited Automated debugging system and method
US20160378644A1 (en) * 2015-06-23 2016-12-29 International Business Machines Corporation Flexible configuration and control of a testing system
CN108256325A (en) * 2016-12-29 2018-07-06 中移(苏州)软件技术有限公司 A kind of method and apparatus of the detection of malicious code mutation
CN112099880A (en) * 2020-08-12 2020-12-18 北京大学 Method and system for reducing application program driven by scene

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
MOHAMMAD MASUDUR RAHMA等: "RACK: Automatic API Recommendation Using Crowdsourced Knowledge", 《2016 IEEE 23RD INTERNATIONAL CONFERENCE ON SOFTWARE ANALYSIS, EVOLUTION, AND REENGINEERING (SANER)》 *
SEOHYUN KIM等: "Code Prediction by Feeding Trees to Transformers", 《2021 IEEE/ACM 43RD INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING (ICSE)》 *
王润民: "基于嵌入式Linux的车载终端系统研究与实现", 《中国优秀硕士学位论文全文数据库 工程科技Ⅱ辑》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI800327B (en) * 2022-03-23 2023-04-21 慧榮科技股份有限公司 Data storage system and parameter margin evaluation method

Also Published As

Publication number Publication date
CN114064012B (en) 2022-03-29

Similar Documents

Publication Publication Date Title
CN106960103B (en) Automatic generation method and device of power grid graph
CN101859135B (en) Method and device for controlling distributed automation system
CN110262783B (en) Interface generation method and device and terminal equipment
CN107168749A (en) A kind of Compilation Method, device, equipment and computer-readable recording medium
CN110990053A (en) Method for creating and using machine learning scheme template and device
CN114064012B (en) Dynamic and static combined interface code generation method and system and electronic equipment
CN105302719A (en) Mutation test method and apparatus
CN111190814B (en) Method and device for generating software test case, storage medium and terminal
CN201435074Y (en) Device for generating test case based on member
CN107577521A (en) A kind of virtual resource management method and device
CN103078952A (en) Automatic deployment method for cloud resources at cloud resource tenant end
CN110968308A (en) Method for changing model for generating source code
US11126408B2 (en) Incremental code generation method
CN102541811B (en) On-demand computing-based data analysis device and method for analysis factors
CN106383734A (en) Method for extracting detailed design from codes
CN106843822B (en) Execution code generation method and equipment
CN111898808A (en) Nuclear power plant in-service inspection data management and analysis method
CN116468259A (en) Workflow configuration method and device based on rule engine
CN110334001A (en) A kind of method and apparatus that batch automatically generates echo test
Laucelli et al. WDNetXL: hydraulic and topology analysis integration and features
CN111273901B (en) File format and deployment method of machine learning model capable of being rapidly deployed online
CN114997127A (en) Financial data acquisition method, computer device and storage medium
Millerchip et al. The generic problem competition: A whole system specification of the boiler system
CN114020717A (en) Method, device, equipment and medium for acquiring performance data of distributed storage system
Zhang An Approach for Extracting UML Diagram from Object-Oriented Program Based on J2X

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