Method, apparatus, electronic device, and storage medium for executing code
By determining code module execution order through historical results and dependencies, the method addresses the challenge of adapting to system changes, improving execution efficiency and enabling self-optimization.
Patent Information
- Application Number
- CN202111545287.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-16
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2041-12-16
AI Technical Summary
In the prior art, the code execution logic of organizing multiple business modules through hard-coded methods is difficult to adapt to the dynamic development of the business system, resulting in system performance problems.
By obtaining the historical execution result information and dependencies of the code module, dynamically adjusting the execution order of the code module to achieve self-optimization.
It improves the efficiency of code execution requests, enables the system to optimize itself when the operating environment changes, and improves system performance.
Smart Images

Figure CN114265643B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, an electronic device, and a storage medium for executing code. Background Art
[0002] A service request often involves multiple service modules. For example, in a marketing scenario, a service request may involve different service modules such as remote procedure call (RPC), marketing asset acquisition, inventory deduction, participation limit judgment, and marketing rule execution.
[0003] When multiple service modules need to be executed, code writers usually organize and call these different service modules in a fixed order by means of hard coding. However, with the development and iteration of the service system and the change of the execution environment such as the continuous increase in system traffic, this hard coding method for service execution logic is difficult to adapt well to the dynamic development of the service system and is likely to cause system performance problems. Summary of the Invention
[0004] This Summary of the Invention section is provided to introduce concepts in a brief form, which will be described in detail in the subsequent Detailed Description section. This Summary of the Invention section is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0005] In a first aspect, according to one or more embodiments of the present disclosure, there is provided a method for executing code, including:
[0006] Obtaining a composite code execution request for requesting execution of at least two code modules;
[0007] Obtaining historical execution result information of the at least two code modules;
[0008] Determining an execution order of the at least two code modules based on the historical execution result information and the dependency relationship of the at least two code modules;
[0009] Executing the at least two code modules based on the execution order.
[0010] In a second aspect, according to one or more embodiments of the present disclosure, there is provided an apparatus for executing code, including:
[0011] A request obtaining unit for obtaining a composite code execution request for requesting execution of at least two code modules;
[0012] A result obtaining unit for obtaining historical execution result information of the at least two code modules;
[0013] A policy determination unit, configured to determine an execution order of the at least two code modules based on the historical execution result information and the dependency relationships of the at least two code modules;
[0014] A code execution unit, configured to execute the at least two code modules based on the execution order.
[0015] In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device, including: at least one memory and at least one processor; wherein, the memory is configured to store program code, and the processor is configured to call the program code stored in the memory to enable the electronic device to execute a method for executing code provided according to one or more embodiments of the present disclosure.
[0016] In a fourth aspect, according to one or more embodiments of the present disclosure, there is provided a non-transitory computer storage medium storing program code, which, when executed by a computer device, causes the computer device to execute a method for executing code provided according to one or more embodiments of the present disclosure.
[0017] According to one or more embodiments of the present disclosure, by determining the execution order of each code module based on the historical execution result information and the dependency relationships of each code module, the execution order of each code module can be dynamically adjusted, thereby improving the execution efficiency of code execution requests and enabling the system to continuously self-optimize based on the previous code execution effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In combination with the accompanying drawings and with reference to the following specific embodiments, the above and other features, advantages and aspects of each embodiment of the present disclosure will become more apparent. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic and the original elements and elements are not necessarily drawn to scale.
[0019] Figure 1 FIG. is a flowchart of a method for executing code provided according to an embodiment of the present disclosure;
[0020] Figure 2 FIG. is a schematic structural diagram of a system for executing code provided according to an embodiment of the present disclosure;
[0021] Figures 3A - 3B FIG. is a schematic diagram of the execution order of code modules provided according to an embodiment of the present disclosure;
[0022] Figure 4 FIG. is a schematic structural diagram of a device for executing code provided according to an embodiment of the present disclosure;
[0023] Figure 5 Schematic structural diagram of an electronic device provided according to an embodiment of the present disclosure. Detailed implementation manners
[0024] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. On the contrary, these embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not used to limit the protection scope of the present disclosure.
[0025] It should be understood that the steps recited in the embodiments of the present disclosure can be executed in a different order and / or executed in parallel. In addition, the embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this regard.
[0026] The term "comprising" and its variations used herein are open-ended, that is, "including but not limited to". The term "based on" is "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The terms "responsive to" and related terms refer to a signal or event being affected to a certain extent by another signal or event, but not necessarily completely or directly affected. If event x "occurs in response to" event y, then x can directly or indirectly respond to y. For example, the occurrence of y may ultimately result in the occurrence of x, but there may be other intermediate events and / or conditions. In other cases, y may not necessarily result in the occurrence of x, and x may occur even if y has not occurred. In addition, the term "responsive to" may also mean "at least partially responsive to".
[0027] The term "determine" broadly encompasses a wide variety of actions, which may include obtaining, calculating, computing, processing, deriving, researching, finding (e.g., looking up in a table, database, or other data structure), ascertaining, and similar actions, and may also include receiving (e.g., receiving information), accessing (e.g., accessing data in a memory) and similar actions, as well as parsing, selecting, choosing, establishing, and similar actions, etc. The relevant definitions of other terms will be given in the following description. The relevant definitions of other terms will be given in the following description.
[0028] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependent relationships.
[0029] It should be noted that the modifications of "one" and "multiple" mentioned in this disclosure are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly specified in the context, it should be understood as "one or more".
[0030] For the purposes of this disclosure, the phrase "A and / or B" means (A), (B), or (A and B).
[0031] The names of the messages or information exchanged between multiple devices in the embodiments of this disclosure are only for illustrative purposes and are not used to limit the scope of these messages or information.
[0032] Reference Figure 1 , Figure 1 FIG. shows a flowchart of a method 100 for executing code provided by an embodiment of this disclosure. The method 100 includes:
[0033] Step S120: Obtain a composite code execution request for requesting the execution of at least two code modules.
[0034] Exemplarily, a code module can be referenced by other code modules or programs, and each code module can correspond to at least one business function. By modularizing the code, the reusability, manageability, readability, and reliability of the code can be improved. Taking a marketing scenario as an example for illustrative purposes, the composite code execution request can be a request for obtaining marketing information, which involves executing business logics such as remote procedure calls, marketing asset acquisition, inventory deduction, participation limit judgment, and marketing rule execution. Among them, each business logic can correspond to a code module.
[0035] Step S140: Obtain historical execution result information of the at least two code modules.
[0036] Exemplarily, the historical execution result information of a code module can be the execution result information when the code module is executed once or multiple times within a preset period in the past.
[0037] In some embodiments, the historical execution result information of a code module can include the execution time consumption of the code module, the execution pass rate of the code module, or the execution failure rate of the code module.
[0038] Exemplarily, the execution time of a code module can be used to characterize the duration required to execute the code module; the execution pass rate of a code module can be applied to, but is not limited to, a rule module. The rule module is used to determine whether a pending request can pass or filter a pending request. The higher the pass rate of a rule module, the more pending requests need to be processed subsequently. For example, if there are 100 pending requests and the pass rate of the rule module is 90%, it means that 90 requests pass through the rule module among the 100 requests, and these 90 requests still need to be processed by other code modules. If the pass rate of the rule module is lower, it means that fewer requests need to be processed subsequently, thereby saving the processing resources and processing time of the system; the execution failure rate of a code module can be used to reflect whether the code module is successfully executed.
[0039] Step S160: Determine the execution order of the at least two code modules based on the historical execution result information and the dependency relationship between the at least two code modules.
[0040] Exemplarily, the dependency relationship includes the reference relationship between code modules. For example, if class A must reference class B to complete a certain function, then class A depends on class B.
[0041] In some embodiments, the execution priority of each code module can be determined based on the historical execution result information of each code module and the dependency relationship between each code module. The higher the execution priority, the more preferentially it is executed. Exemplarily, the longer the execution time of a certain code module, the lower its execution priority; the lower the execution pass rate of a certain code module, the higher its execution priority; the higher the execution failure rate of a certain code module, the lower its execution priority; if a certain code module is depended on, its execution priority is higher.
[0042] In some embodiments, corresponding weights can be preset for each metric used to determine the execution order of code modules. For example, weight coefficients are respectively set for the execution time of code modules, the execution pass rate of code modules, and the execution failure rate of code modules, and then weighted summation is used to obtain the final priority of the code module.
[0043] In some embodiments, the at least two modules can be spliced according to the determined execution order for final execution.
[0044] Step S180: Execute the at least two code modules based on the execution order.
[0045] Since the execution efficiency of each code module in a system may change with the running time and running environment, compared with the fixed execution order of code modules set by hard coding, according to the method for executing code provided by one or more embodiments of the present disclosure, by determining the execution order of each code module based on the historical execution result information and dependency relationships of each code module, the execution order of each code module can be adjusted dynamically, thereby improving the execution efficiency of code execution requests and enabling the system to continuously optimize itself based on the previous code execution effects.
[0046] In some embodiments, step S140 includes:
[0047] Step A1: Obtain the code execution logs of the at least two code modules;
[0048] Step A2: Determine the historical execution result information of the at least two code modules based on the code execution logs.
[0049] Exemplarily, one or more code execution logs obtained within a period of time can be aggregated and classified to count the historical execution results of each code module, including but not limited to the execution time consumption, execution pass rate, or execution failure rate of the code module, etc.
[0050] It should be noted that the code execution logs can include system logs automatically generated by the system or other logs used to record the code execution situation, and the present disclosure does not limit this here.
[0051] In some embodiments, method 100 further includes:
[0052] Step S190: Record the execution result information of the at least two code modules for later determining the execution order of the code modules based on the execution result information.
[0053] In this embodiment, when responding to the current composite code execution request, by recording the execution result information of each code module, when determining the execution order of the code modules later (such as step S140), the execution result information recorded this time can be referred to, that is, it can guide the determination of the execution logic of the code modules in the future. In this way, a closed loop is formed and the entire system can continuously optimize itself in a cycle.
[0054] In some embodiments, step S190 includes:
[0055] Step B1: Generate a code execution log, where the code execution log includes the execution order and execution result information of the at least two code modules.
[0056] In this embodiment, the code execution log includes not only the execution time, execution pass rate, or execution failure rate of each code module, but also the execution order of the code modules, so that the code execution log is used preferentially when determining the execution order of the code modules in the future.
[0057] In some embodiments, step S160 includes:
[0058] Based on a preset initial code execution order, the historical execution result information and the dependency relationship between the at least two code modules, an execution order of the at least two code modules is determined.
[0059] Exemplarily, the initial code execution order can be pre-set by the code writer and can be used as an initial reference for determining the execution order of code modules when the system first responds to a compound code execution request. When the system responds to a compound code execution request again, the initial code execution order can be adjusted based on historical execution result information to adjust the execution priority of each code module.
[0060] According to one or more embodiments of the present disclosure, by collecting execution logs generated during the execution of code modules, analyzing the execution results of each code module in real time, and providing feedback and guidance on the determination of the execution order of the code modules, the system is placed in a state of continuous self-optimization, and can get rid of the solidified code module execution process, making the execution of the code modules dynamic. The system automatically adjusts the execution order of the code modules at runtime, so that the code can be arranged in a more reasonable way to improve system performance.
[0061] refer to Figure 2 , Figure 2 The business system 200 provided according to an embodiment of the present disclosure is shown in FIG. 200 may include a business module execution subsystem 210 , a business module analysis subsystem 220 , and a business module decision subsystem 230 .
[0062] When the business system 200 receives a business request for executing a composite code, the business request may be handed over to the business module execution subsystem 210 , and the business module execution subsystem 210 makes a request to the business module decision subsystem 230 based on the business request.
[0063] The business module decision subsystem 230 can determine the priority of the business module to be executed according to the initial business module processing order and the preset module parameters, and then determine the business module execution strategy according to the dependencies between the business modules, and send the execution strategy to the business module execution subsystem 210. Figures 3A - 3B , showing different business module execution strategies.
[0064] According to this execution policy, the service module execution subsystem 210 performs actual operations on the code block. After the execution is completed, it assembles and returns the execution result, and at the same time sends the execution log to the service module analysis subsystem 220.
[0065] The service module analysis subsystem 220 aggregates and classifies the execution logs, and statistically obtains the execution result information of each service module, including execution time consumption, execution pass rate, execution failure rate, etc., and submits the analysis data to the service module decision-making subsystem 230.
[0066] In the decision-making process of the service module execution policy in the future, the service module decision-making subsystem 230 can dynamically adjust the pre-set module parameters according to the execution result information, so as to adjust the execution priorities of each service module, thereby realizing the self-optimization of the system 200.
[0067] Compared with the related technology, in this embodiment, by introducing the service module analysis subsystem and the service module decision-making subsystem, the execution result information of each service module is statistically obtained in real time based on the execution log, so that the execution priorities of each service module can be dynamically adjusted, thereby realizing the self-optimization of the system. Since the execution efficiency of each service module in a system may change with the change of the running time and running environment, compared with the fixed service execution process, this embodiment can dynamically decide the optimal service module execution order during operation.
[0068] As Figure 4 shown, according to an embodiment of the present disclosure, an apparatus 400 for executing code is provided, including:
[0069] A request acquisition unit 420, configured to acquire a composite code execution request, where the composite code execution request is used to request the execution of at least two code modules;
[0070] A result acquisition unit 440, configured to acquire the historical execution result information of the at least two code modules;
[0071] A policy determination unit 460, configured to determine the execution order of the at least two code modules based on the historical execution result information and the dependency relationship of the at least two code modules;
[0072] A code execution unit 480, configured to execute the at least two code modules based on the execution order.
[0073] Since the execution efficiency of each code module in a system may change with the running time and running environment, compared with the fixed execution order of code modules set by hard coding, the apparatus for executing code provided by one or more embodiments of the present disclosure can dynamically adjust the execution order of each code module by determining the execution order of each code module based on the historical execution result information and dependency relationships of each code module, thereby improving the execution efficiency of code execution requests and enabling the system to continuously optimize itself based on the previous code execution effects.
[0074] In some embodiments, the historical execution result information includes at least one of the following: execution time consumption, execution pass rate, and execution failure rate.
[0075] In some embodiments, the result acquisition unit includes:
[0076] A log acquisition subunit for acquiring code execution logs;
[0077] A log analysis subunit for determining the historical execution result information of the at least two code modules based on the code execution logs.
[0078] In some embodiments, the apparatus for executing code further includes:
[0079] A result recording unit for recording the execution result information of the at least two code modules after executing the at least two code modules based on the execution order, for use in determining the execution order of code modules based on the execution result information in the future.
[0080] In some embodiments, the result recording unit is used to generate code execution logs, and the code execution logs include the execution order and execution result information of the at least two code modules.
[0081] In some embodiments, determining the execution order of the at least two code modules based on the historical execution result information and the dependency relationships of the at least two code modules includes: determining the execution order of the at least two code modules based on a preset initial code execution order, the historical execution result information, and the dependency relationships of the at least two code modules.
[0082] In some embodiments, determining the execution order of the at least two code modules based on the historical execution result information and the dependency relationships of the at least two code modules includes: concatenating the at least two code modules based on the determined execution order.
[0083] For the embodiments of the apparatus, since they basically correspond to the method embodiments, the relevant parts can be referred to the descriptions of the method embodiments. The apparatus embodiments described above are merely illustrative. The modules described as separate modules may or may not be separated. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative work.
[0084] Correspondingly, according to one or more embodiments of the present disclosure, an electronic device is provided, including:
[0085] At least one memory and at least one processor;
[0086] Wherein, the memory is used to store program codes, and the processor is used to call the program codes stored in the memory to enable the electronic device to execute the method for executing codes provided according to one or more embodiments of the present disclosure.
[0087] Correspondingly, according to one or more embodiments of the present disclosure, a non-transitory computer storage medium is provided. The non-transitory computer storage medium stores program codes, and the program codes can be executed by a computer device to enable the computer device to execute the method for executing codes provided according to one or more embodiments of the present disclosure.
[0088] Next, refer to Figure 5 , which shows a schematic structural diagram of an electronic device 800 (such as a terminal device or a server) suitable for implementing the embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Tablet Computers), PMPs (Portable Multimedia Players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The electronic device shown is only an example and should not impose any limitation on the functions and usage scope of the embodiments of the present disclosure.
[0089] As Figure 5 shown, the electronic device 800 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 801, which can perform various appropriate actions and processes according to the programs stored in the read-only memory (ROM) 802 or the programs loaded from the storage device 808 into the random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 801, the ROM 802, and the RAM 803 are connected to each other through a bus 804. The input / output (I / O) interface 805 is also connected to the bus 804.
[0090] Typically, the following devices may be connected to the I / O interface 805: an input device 806 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 807 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 808 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 809. The communication device 809 may allow the electronic device 800 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 5 the electronic device 800 with various devices is shown, it should be understood that it is not required to implement or include all the shown devices. More or fewer devices may be alternatively implemented or included.
[0091] Specifically, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program codes for performing the methods shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network through the communication device 809, or installed from the storage device 808, or installed from the ROM 802. When the computer program is executed by the processing device 801, the above functions defined in the methods of the embodiments of the present disclosure are performed.
[0092] It should be noted that the computer-readable medium described above in the present disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and this computer-readable signal medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0093] In some embodiments, the client and the server can communicate using any currently known or future-developed network protocol such as HTTP (HyperText Transfer Protocol), and can be interconnected with digital data communication in any form or medium (e.g., a communication network). Examples of the communication network include a local area network (“LAN”), a wide area network (“WAN”), the Internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future-developed network.
[0094] The above computer-readable medium can be included in the above electronic device; or it can exist separately without being assembled into the electronic device.
[0095] The above computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device is caused to execute the method of the present disclosure described above.
[0096] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may execute entirely on the user's computer, partially on the user's computer, execute as a stand-alone software package, execute partially on the user's computer and partially on a remote computer, or execute entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0097] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a portion of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks may occur in a different order than noted in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system that performs the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
[0098] The units described in the embodiments of the present disclosure may be implemented in software or in hardware. In some cases, the name of the unit does not constitute a limitation on the unit itself.
[0099] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), system on a chip (SOC), complex programmable logic devices (CPLD), and the like.
[0100] In the context of the present disclosure, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0101] According to one or more embodiments of the present disclosure, a method for executing code is provided, including: obtaining a composite code execution request for requesting execution of at least two code modules; obtaining historical execution result information of the at least two code modules; determining an execution order of the at least two code modules based on the historical execution result information and the dependency relationship of the at least two code modules; and executing the at least two code modules based on the execution order.
[0102] According to one or more embodiments of the present disclosure, the historical execution result information includes at least one of the following: execution time consumption, execution pass rate, and execution failure rate.
[0103] According to one or more embodiments of the present disclosure, the obtaining of the historical execution result information of the at least two code modules includes: obtaining a code execution log; and determining the historical execution result information of the at least two code modules based on the code execution log.
[0104] The method for executing code according to one or more embodiments of the present disclosure further includes: after executing the at least two code modules based on the execution order, recording the execution result information of the at least two code modules for later determining the execution order of the code modules based on the execution result information.
[0105] According to one or more embodiments of the present disclosure, the recording of the execution result information of the at least two code modules includes: generating a code execution log including the execution order and the execution result information of the at least two code modules.
[0106] According to one or more embodiments of the present disclosure, determining the execution order of the at least two code modules based on the historical execution result information and the dependency relationships of the at least two code modules includes: determining the execution order of the at least two code modules based on a preset initial code execution order, the historical execution result information, and the dependency relationships of the at least two code modules.
[0107] According to one or more embodiments of the present disclosure, determining the execution order of the at least two code modules based on the historical execution result information and the dependency relationships of the at least two code modules includes: concatenating the at least two code modules based on the determined execution order.
[0108] According to one or more embodiments of the present disclosure, there is provided an apparatus for executing code, including: a request acquisition unit configured to acquire a composite code execution request for requesting execution of at least two code modules; a result acquisition unit configured to acquire historical execution result information of the at least two code modules; a policy determination unit configured to determine the execution order of the at least two code modules based on the historical execution result information and the dependency relationships of the at least two code modules; and a code execution unit configured to execute the at least two code modules based on the execution order.
[0109] According to one or more embodiments of the present disclosure, there is provided an electronic device, including: at least one memory and at least one processor; wherein, the memory is configured to store program code, and the processor is configured to call the program code stored in the memory to cause the electronic device to execute any one of the methods for executing code provided according to one or more embodiments of the present disclosure.
[0110] According to one or more embodiments of the present disclosure, there is provided a non-transitory computer storage medium storing program code, which when executed by a computer device, causes the computer device to execute any one of the methods for executing code provided according to one or more embodiments of the present disclosure.
[0111] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principle. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) having similar functions disclosed in the present disclosure.
[0112] Moreover, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the foregoing discussion, these should not be construed as limitations on the scope of the present disclosure. Certain features that are described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, the various features that are described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.
[0113] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A method for executing code, characterized in that, including: Obtain a composite code execution request for requesting the execution of at least two code modules; Obtain historical execution result information of the at least two code modules, where the historical execution result information includes at least one of the following: execution time consumption, execution pass rate, execution failure rate; Determine the execution order of the at least two code modules based on the historical execution result information and the dependency relationship of the at least two code modules; where determining the execution order of the at least two code modules based on the historical execution result information and the dependency relationship of the at least two code modules includes: determining the execution priority of each code module in the at least two code modules based on the historical execution result information and the dependency relationship; executing the at least two code modules based on the execution order.
2. The method for executing code according to claim 1, wherein The obtaining the historical execution result information of the at least two code modules includes: Obtain a code execution log; Determine the historical execution result information of the at least two code modules based on the code execution log.
3. The method for executing code according to claim 1, characterized in that, It further includes: After executing the at least two code modules based on the execution order, record the execution result information of the at least two code modules for later determining the execution order of the code modules based on the execution result information.
4. The method for executing code according to claim 3, wherein The recording the execution result information of the at least two code modules includes: Generate a code execution log, where the code execution log includes the execution order and execution result information of the at least two code modules.
5. The method for executing code according to claim 1, wherein The determining the execution order of the at least two code modules based on the historical execution result information and the dependency relationship of the at least two code modules includes: Determine the execution order of the at least two code modules based on a preset initial code execution order, the historical execution result information, and the dependency relationship of the at least two code modules.
6. The method for executing code according to claim 1, wherein The determining the execution order of the at least two code modules based on the historical execution result information and the dependency relationship of the at least two code modules includes: Concatenate the at least two code modules based on the determined execution order.
7. An apparatus for executing code, characterized in that, including: A request obtaining unit for obtaining a composite code execution request for requesting the execution of at least two code modules; A result obtaining unit for obtaining the historical execution result information of the at least two code modules, where the historical execution result information includes at least one of the following: execution time consumption, execution pass rate, execution failure rate; A policy determining unit for determining the execution order of the at least two code modules based on the historical execution result information and the dependency relationship of the at least two code modules; where determining the execution order of the at least two code modules based on the historical execution result information and the dependency relationship of the at least two code modules includes: determining the execution priority of each code module in the at least two code modules based on the historical execution result information and the dependency relationship; A code execution unit for executing the at least two code modules based on the execution order.
8. An electronic device, characterized in that, including: At least one memory and at least one processor; Wherein, the memory is used for storing program codes, and the processor is used for calling the program codes stored in the memory to enable the electronic device to execute the method according to any one of claims 1 to 6.
9. A non-transitory computer storage medium, characterized in that the non-transitory computer storage medium stores program codes, and when the program codes are executed by a computer device, the computer device is enabled to execute the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method and device for executing application startup code, terminal and storage medium
CN110727479A
Automatic collection and presentation of runtime data semantics
US20170132109A1