CN112083931A - Program processing method, device and equipment - Google Patents

Program processing method, device and equipment Download PDF

Info

Publication number
CN112083931A
CN112083931A CN202010965658.1A CN202010965658A CN112083931A CN 112083931 A CN112083931 A CN 112083931A CN 202010965658 A CN202010965658 A CN 202010965658A CN 112083931 A CN112083931 A CN 112083931A
Authority
CN
China
Prior art keywords
program
code
subprogram
variable
determining
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.)
Pending
Application number
CN202010965658.1A
Other languages
Chinese (zh)
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.)
Shanghai Eye Control Technology Co Ltd
Original Assignee
Shanghai Eye Control 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 Shanghai Eye Control Technology Co Ltd filed Critical Shanghai Eye Control Technology Co Ltd
Priority to CN202010965658.1A priority Critical patent/CN112083931A/en
Publication of CN112083931A publication Critical patent/CN112083931A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation

Landscapes

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

Abstract

The embodiment of the application provides a program processing method, a device and equipment, wherein the method comprises the following steps: acquiring a first program, wherein the first program comprises a plurality of subprograms; adding a timing code corresponding to each subprogram in the first program to obtain a second program; running the second program, and acquiring the running time corresponding to each subprogram through the timing code in the running process of the second program; and determining the subprogram to be optimized according to the running time length corresponding to each subprogram. The terminal equipment can accurately determine the calculation module to be optimized, and further the optimization efficiency of the calculation module is improved.

Description

Program processing method, device and equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, and a device for processing a program.
Background
Currently, scientific calculations can be performed using a computing program. In order to ensure the computational efficiency of the computation program, the computation module can be optimized.
In the prior art, the calculation module is typically optimized based on the experience of the programmer. The programmer selects the computing module to be optimized based on the composition of the computing module (e.g., the amount of code in the computing module). However, this method requires experience of the programmer to select the calculation module to be optimized, and the selection of the calculation module to be optimized by different programmers may be different, so that the calculation module to be optimized cannot be accurately determined, which results in low optimization efficiency.
Disclosure of Invention
The application provides a program processing method, a program processing device and program processing equipment. Therefore, the terminal equipment can accurately determine the calculation module to be optimized, and the optimization efficiency of the calculation module is improved.
In a first aspect, an embodiment of the present application provides a program processing method, where the method includes:
acquiring a first program, wherein the first program comprises a plurality of subprograms;
adding a timing code corresponding to each subprogram in the first program to obtain a second program;
running the second program, and acquiring the running time corresponding to each subprogram through the timing code in the running process of the second program;
and determining the subprogram to be optimized according to the running time length corresponding to each subprogram.
In a possible implementation manner, adding a timing code corresponding to each sub-program in the first program to obtain a second program includes:
determining a plurality of position sets in the first program, wherein the position sets comprise a plurality of adding positions;
determining a timing code corresponding to each adding position;
adding a corresponding timing code at each adding position respectively.
In one possible embodiment, the set of locations comprises:
the starting position of the subprogram code;
an end position of the subroutine code;
an end position of the first program code.
In one possible embodiment said timing code comprises:
a variable assignment code;
a first variable code;
a second variable code;
the variable outputs the code.
In one possible embodiment, determining a timing code corresponding to each adding position includes:
when the adding position is the initial position of the subprogram code, determining that the timing code corresponding to the adding position is a variable assignment code and a first variable code; or,
when the adding position is the end position of the subprogram code, determining that the timing code corresponding to the adding position is a second variable code; or,
and when the adding position is the end position of the first program code, determining that the timing code corresponding to the adding position is a variable output code.
In a possible implementation manner, determining the subprogram to be optimized according to the running time length corresponding to each subprogram includes:
and determining the subprogram with the running time length being greater than or equal to the first threshold value as the subprogram to be optimized.
In a second aspect, an embodiment of the present application provides a program processing apparatus, including an obtaining module, an adding module, an operating module, and a determining module, where:
the acquisition module is used for acquiring a first program, and the first program comprises a plurality of subprograms;
the adding module is used for adding a timing code corresponding to each subprogram in the first program to obtain a second program;
the running module is used for running the second program and acquiring the running time corresponding to each subprogram through the timing code in the running process of the second program;
the determining module is used for determining the subprogram to be optimized according to the running time length corresponding to each subprogram.
In a possible implementation manner, the adding module is specifically configured to:
determining a plurality of position sets in the first program, wherein the position sets comprise a plurality of adding positions;
determining a timing code corresponding to each adding position;
adding a corresponding timing code at each adding position respectively.
In one possible embodiment, the set of locations comprises:
the starting position of the subprogram code;
an end position of the subroutine code;
an end position of the first program code.
In one possible embodiment, the timing code comprises:
a variable assignment code;
a first variable code;
a second variable code;
the variable outputs the code.
In a possible implementation manner, the adding module is specifically configured to:
when the adding position is the initial position of the subprogram code, determining that the timing code corresponding to the adding position is a variable assignment code and a first variable code; or,
when the adding position is the end position of the subprogram code, determining that the timing code corresponding to the adding position is a second variable code; or,
and when the adding position is the end position of the first program code, determining that the timing code corresponding to the adding position is a variable output code.
In a possible implementation, the determining module is specifically configured to:
and determining the subprogram with the running time length being greater than or equal to the first threshold value as the subprogram to be optimized.
In a third aspect, an embodiment of the present application provides a program processing apparatus, including: a memory for storing program instructions, a processor for calling program instructions in the memory to perform the program processing method of any of the first aspects, and a communication interface.
In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a computer program is stored; the computer program is for implementing the program processing method according to any one of the first aspect.
According to the program processing method, the device and the equipment provided by the embodiment of the application, a first program is obtained, wherein the first program comprises a plurality of subprograms, and a timing code corresponding to each subprogram is added into the first program to obtain a second program; running a second program, and acquiring running time corresponding to each subprogram through a timing code in the running process of the second program; and determining the subprogram to be optimized according to the running time length corresponding to each subprogram. Because each subprogram in the second program is added with the corresponding timing code, when the terminal device runs the second program, the timing code can acquire the running time of each subprogram, and a user can determine the subprogram to be optimized according to the running time of each subprogram, so that the terminal device can accurately determine the calculation module to be optimized, and the optimization efficiency of the calculation module is further improved.
Drawings
Fig. 1 is a schematic view of a terminal interface in an application scenario provided in an embodiment of the present application;
fig. 2 is a schematic flowchart of a program processing method according to an embodiment of the present application;
FIG. 3 is a schematic flow chart diagram illustrating another exemplary method of processing programs according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a program processing apparatus according to an embodiment of the present application;
fig. 5 is a schematic hardware structure diagram of a program processing device according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
The terms "comprising" and "having," and any variations thereof, in the description and claims of this application and the drawings described herein are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
For convenience of understanding, an application scenario to which the present application is applied will be described below by taking a terminal device as an example.
Fig. 1 is a schematic view of a terminal interface in an application scenario provided in an embodiment of the present application. Referring to fig. 1, a terminal device 101 is a computer, and a terminal interface includes an interface 102, an interface 103, and an interface 104.
See interface 102, including a first program, timing code, and an add icon. For example, The first program may be in a WRF mode (The Weather forecast mode), where The WRF mode includes a radiation process module, a road surface process module, a planetary boundary layer process module, and a cloud accumulation process module, and each of The modules belongs to a subroutine in The WRF mode. The timing code may include a variable assignment code, a first variable code, a second variable code, and a variable output code. Assuming that the user needs to acquire the running time of each sub program in the first program, the user may click on the "add" icon to cause the terminal device 101 to display the interface 103.
See interface 103, including a second program and a run icon. The second program comprises a plurality of subprograms and a plurality of timing codes. When the user clicks the "add" icon in the interface 102, the terminal device 101 may process the first program by using the program processing method described in the present application, and obtain the second program. For example, the terminal device may add a corresponding timing code in the addition position of each sub program in the first program, resulting in the second program. Assuming that the user needs to acquire the running time of each sub program in the first program, the user may click on the "running" icon to cause the terminal device 101 to display the interface 104.
Please enter the interface 104, including the run time of the subroutine. When the user clicks the "run" icon in the interface 103, the interface 104 may display the run time of each sub-program in the first program. The terminal apparatus 101 may select the subprogram to be optimized according to the running time of each subprogram.
In the application, the terminal device may obtain a first program, where the first program includes multiple subprograms, and adds a timing code corresponding to each subprogram in the first program to obtain a second program; running a second program, and acquiring running time corresponding to each subprogram through a timing code in the running process of the second program; and determining the subprogram to be optimized according to the running time length corresponding to each subprogram. Because each subprogram in the second program is added with the corresponding timing code, when the terminal device runs the second program, the timing code can acquire the running time of each subprogram, and a user can determine the subprogram to be optimized according to the running time of each subprogram, so that the terminal device can accurately determine the calculation module to be optimized, and the optimization efficiency of the calculation module is further improved.
The method described in the present application will be described below with reference to specific examples. It should be noted that the following embodiments may exist alone or in combination with each other, and the description of the same or similar contents is not repeated in different embodiments.
Fig. 2 is a flowchart illustrating a program processing method according to an embodiment of the present application. Please refer to fig. 2, which includes:
s201, acquiring a first program.
The execution main body of the embodiment of the application may be an electronic device, or may be a program processing apparatus provided in the electronic device. The electronic device can be a computer, a server and the like. The electronic device may be a portable electronic device. For example, the electronic device may be a mobile phone, a tablet computer, or the like. The program processing means may be implemented by software, or by a combination of software and hardware.
The first program may include an application program, a numerical calculation program, a driver of the controller, and the like. For example, the first program may include a WRF mode, a numerical mode that requires a large number of calculations.
Optionally, the first program includes a plurality of subroutines. For example, the WRF mode includes physical modules and chemical modules, wherein the physical modules include a radiation process module, a road surface process module, a planetary boundary layer process module, and a cloud accumulation process module, and each of the physical modules belongs to a subroutine in the WRF mode.
Alternatively, the first program may be acquired in a feasible manner as follows: the first program may be obtained based on a runtime of the program. For example, a first program is obtained according to a preset time threshold, and if the running time of the program is greater than or equal to the preset time threshold, the program may be determined as the first program and optimized; if the running time of the program is less than the preset time threshold, the program can be determined as a program which does not need to be optimized.
Alternatively, the first program may be acquired in a feasible manner as follows: the first program may be obtained according to the computational requirements of the user. For example, a first program is obtained according to a preset calculation requirement threshold, and in the field of meteorological services, if the requirement of the meteorological services for the calculation capability is greater than or equal to the preset calculation requirement, the program for calculating the meteorological services can be determined as the first program and optimized; if the demand of the meteorological service on the computing capacity is less than the preset computing demand, the program for computing the meteorological service does not need to be optimized.
S202, adding a timing code corresponding to each subprogram in the first program to obtain a second program.
The timing code may include a variable assignment code, a first variable code, a second variable code, and a variable output code.
Alternatively, a timer code external to the first program may be used. For example, a timer code may be edited.
The variable assignment code is used for assigning a value to the time variable. For example, in the WRF mode, before the operation time of the radiation process module is obtained, the time variable of the radiation process module may be assigned, if the radiation process module is operated for the first time, the time variable may be assigned to be 0, and if the radiation process module is operated for the second time, the time variable may be assigned to be the time when the radiation process module is operated for the first time. This allows the total operating time of all the radiation process modules in the WRF mode to be obtained.
The first variable code is used to obtain the system time. For example, a first variable code is added to a first line of the program code, and when the program runs, the first time variable code may acquire the system time when the program starts running.
The second variable code is used for acquiring the system time difference. The system time difference may be a difference between the system time obtained by the second variable and the system time obtained by the first variable. For example, the second variable code may be a difference between the system time obtained at the current time and the system time obtained at the first variable code.
Optionally, the acquiring system time code may include a timer code, for example, the timer code may include a stopwatch timer code and a code of the current system time.
Alternatively, the timer code may be determined according to the first program. For example, in the WRF mode, the program of the WRF code includes an RSL _ INTERNAL _ micro () function, which mainly functions to obtain the current time of the operating system, and may be used as a timer code.
The variable output code is used for outputting the assigned time variable. For example, the time difference obtained by the second time variable code to the system may be an assigned time variable, and the variable output code may output the assigned time variable, which is the time difference of the output system.
The second program may comprise a subroutine to which timing code is added. For example, in the WRF mode, the sub-program may be a planetary boundary layer process module in the physical module, and after adding the timing code to the planetary boundary layer process module, a second program of the planetary boundary layer process module may be obtained.
Optionally, a timing code may be added to each subroutine in the first program according to the following feasible manner: determining a plurality of position sets in a first program, wherein the position sets comprise a plurality of adding positions, determining a timing code corresponding to each adding position, and adding a corresponding timing code at each adding position respectively.
The position set comprises a plurality of adding positions, and the adding positions are used for indicating adding positions of the timing codes. For example, the adding position may be a start position of the sub program code, an end position of the sub program code, or the like.
The set of locations may include: a starting position of the sub program code, an ending position of the sub program code, and an ending position of the first program code. For example, if two radiation process modules are included in the WRF mode, the location of the addition of the timing code for the radiation process may include: an end position of the WRF mode code, a start position of the radiation process module code, and an end position of the radiation process module code.
Optionally, a corresponding timing code may be determined according to each adding position. For example, two radiation process modules are included in the WRF mode, a variable output code may be added to the end position of the WRF mode code, a variable assignment code and a first variable code may be added to the start position of the radiation process module code, and a second variable code may be added to the end position of the radiation process module code.
Optionally, a corresponding timing code may be added at each adding position in the first program, respectively, to obtain the second program. For example, adding a corresponding timing code to each adding position in the WRF mode may obtain a second program corresponding to the WRF mode.
And S203, operating the second program, and acquiring the operation duration corresponding to each subprogram through the timing code in the operation process of the second program.
And adding a corresponding timing code at each adding position in the first program to obtain a second program, wherein in the running process of the second program, the timing code can obtain the running time length corresponding to each subprogram.
Optionally, when the second program runs, the start position and the end position of each subroutine are added with corresponding timing codes.
When the second program is operated, the timing code is also operated, and the timing code outputs the operation time length of each sub-program. For example, in the WRF mode, a variable assignment code and a first variable code are added to the starting position of the radiation process module, the variable assignment code can assign a time variable of the radiation process module which operates for the first time to 0, the time variable of the radiation process module which operates for the second time is assigned to the time variable of the previous operation of the radiation process module, and the first variable code can acquire the system time when the radiation process starts to operate; adding a second variable code at the end position of the radiation process module, wherein when the operation of the radiation process module is ended, the second variable code can acquire the time difference between the current system time and the time when the radiation process module starts to operate, so as to acquire the operation time of the radiation process module; and adding a variable output code at the end position of the WRF mode, wherein the variable output code can output the total running time of the radiation process module.
And S204, determining the subprogram to be optimized according to the running time length corresponding to each subprogram.
Optionally, the subroutine with the longest running time may be determined as the subroutine to be optimized. For example, in the WRF mode, the radiation process module may be used as a subroutine to be optimized in the WRF mode, where the operation time of the radiation process module is 10 seconds, the operation time of the land process module is 7 seconds, the operation time of the planetary boundary layer process module is 6 seconds, and the operation time of the cloud process module is 4 seconds.
Optionally, the sub-program with the running time length greater than or equal to the first threshold may be determined as the sub-program to be optimized. For example, if the first threshold is 10 seconds, if the running time of the output subroutine after the second program is run is greater than or equal to 10 seconds, the subroutine is a subroutine to be optimized, and if the running time of the output subroutine is less than 10 seconds, the subroutine is a subroutine that does not need to be optimized.
Optionally, the second program may be run for multiple times, the total running time of the multiple sub-programs is obtained, and the average value of the total running time of the multiple sub-programs is taken as the total running time of the sub-programs. For example, in the WRF mode, the total operating time of the radiation process module is obtained multiple times, and the average value thereof is taken as the total operating time of the radiation process module.
In this application, a terminal device may obtain a first program, where the first program includes a plurality of subprograms. And the terminal equipment adds the timing code corresponding to each subprogram in the first program to obtain a second program. And the terminal equipment runs the second program, and obtains the running time length corresponding to each subprogram through the timing code in the running process of the second program. And determining the subprogram to be optimized according to the running time length corresponding to each subprogram. Because each subprogram in the second program is added with the corresponding timing code, when the terminal device runs the second program, the timing code can acquire the running time of each subprogram, and a user can determine the subprogram to be optimized according to the running time of each subprogram, so that the terminal device can accurately determine the calculation module to be optimized, and the optimization efficiency of the calculation module is further improved.
In addition to any of the above embodiments, the following describes the above program processing method in detail with reference to fig. 3.
Fig. 3 is a flowchart illustrating another program processing method according to an embodiment of the present disclosure. Referring to fig. 3, the method may include:
s301, acquiring a first program and determining the structure of the first program.
The first program may include an application program, a numerical calculation program, a driver of the controller, and the like. For example, the first program may include a WRF mode, a numerical mode that requires a large number of calculations.
The first program includes a plurality of subprograms. For example, the application includes a plurality of functionally different subroutines.
Alternatively, the first program may be a local program in the terminal device (for example, a system program in the terminal device), or may be a program in the network.
The first program may be structured such that a calling position of the subprogram, a function name of the subprogram, and a calling order of the subprogram in the first program. The calling location of the subroutine may be the address where the subroutine is called when the subroutine is running. The function name of the subroutine may be the function name called when the subroutine runs. The order of invocation of the subroutines is used to indicate the priority in which the subroutines are invoked. For example, in the WRF model, the physical processes all exist as subfunctions in the Fortran language. According to the structure of the WRF mode, it can be known that the main physical process is called in the module _ first _ rk _ step _ part1.F program under the WRF code subdirectory dyn _ em. The sequence of calls is a radial process (function name: radiation _ driver ()), a land process (function name: surface _ driver ()), a planetary boundary layer process (function name: pbl _ driver ()), and a cumulus process (function name: cumulus _ driver ()).
S302, determining an adding position in the first program according to the structure of the first program.
Optionally, the calling position of each subprogram may be obtained according to the structure of the first program, and the adding position in the first program is determined according to the calling position of each subprogram. For example, in the WRF mode, a physical process is called in a module _ first _ rk _ step _ part1.f program under a WRF code subdirectory dyn _ em, and an addition position in the physical process can be acquired under the directory.
Alternatively, the terminal device may obtain the start position and the end position of the subroutine code according to the code of each subroutine.
And S303, adding the timing code corresponding to each subprogram in the first program according to the corresponding relation between the adding position and the timing code to obtain a second program.
The correspondence is used to indicate a relationship between the addition position and the timing code, and for example, the correspondence may be as shown in table 1:
TABLE 1
Serial number AddingPosition of Timing code
1 Starting position of subprogram code Variable assignment code
2 Starting position of subprogram code First variable code
3 End position of subroutine code Second variable code
4 End position of first program code Variable output code
…… ……
Each adding position in table 1 has a corresponding timing code, and it should be noted that table 1 illustrates the corresponding relationship by way of example only, and does not limit the corresponding relationship.
For example, when the adding position is the initial position of the subprogram code, determining that the timing code corresponding to the adding position is a variable assignment code and a first variable code; when the adding position is the end position of the subprogram code, determining that the timing code corresponding to the adding position is a second variable code; and when the adding position is the end position of the first program code, determining that the timing code corresponding to the adding position is a variable output code.
Optionally, the adding position of the variable assignment code is before the adding position of the first variable code, the variable assignment code may assign a time variable of the radiation process module running for the first time to 0, and assign a time variable of the radiation process module running for the second time to a time variable of the radiation process module running for the last time. Thus, when the second program finishes running, the code is assigned according to the variable, and the total running time of the same function subprogram can be obtained. For example, in the WRF mode, the variable assignment code can obtain the total operation duration of all the radiation process modules in the WRF mode.
Alternatively, variable output code may be added at the end of the last subroutine. For example, in the WRF mode, the variable output code may be added to the end position of the last radiation process module, and when all the radiation process modules are finished operating, the variable output code may output the total operating duration of all the radiation process modules.
And S304, operating the second program, and acquiring the operating duration corresponding to each subprogram through the timing code.
The following describes in detail a process of acquiring an operation duration corresponding to each subroutine by using a timing code, taking the WRF mode as an example.
Optionally, the physical processes in the WRF mode include a radiation process, a land surface process, a planetary boundary layer process, and a cloud process, taking the radiation process as an example.
According to the structure of the WRF mode, it can be determined that the radiation process is called in a module _ first _ rk _ step _ part1.F program under a WRF code subdirectory dyn _ em, the function name is radiation _ driver (), and the priority of the radiation process is higher than that of a land process, a planet boundary layer process and a cloud process.
Optionally, an RSL _ INTERNAL _ micro () function in the WRF mode is used as a function for acquiring the current time of the system.
The following codes are added at the starting position of the radiation process module:
BENCH_DECL(rad_driver_tim)rad_driver_tim=0
the time variable of the radiation process module is assigned to 0, and then the code is added:
BENCH_START(rad_driver_tim)btimex=rsl_internal_microclock()
and acquiring the system time when the radiation process module starts to operate. Adding the following codes at the end position of the radiation process module:
BENCH_END(rad_driver_tim)
rad_driver_tim=rad_driver_tim+rsl_internal_microclock()-btimex
and acquiring the difference value between the system time when the operation of the radiation process module is finished and the system time when the operation of the radiation process module is finished, and assigning the difference value of the system time to the time variable of the radiation process module.
The following code is added at the end of the WRF mode: BENCH _ REPORT (rad _ driver _ tim) write (0)' rad _ driver _ tim ═ rad _ driver _ tim
And outputting the time variable of the radiation process module to obtain the total operation time of all the radiation process modules in the WRF mode.
Optionally, the macro definition may be added before the subroutine variable declaration ends, which may reduce the complexity of the program. Optionally, a-DBENCH option may be added to the ARCHFLAGS variable definition of WRF schema compilation configuration. When the macro definition is added, a code defined as null can be added, when the program runs, if the macro BENCH is defined, the code can be replaced by the macro definition code, and if the macro BENCH is not defined, the code can be replaced by the null line, so that the program is not influenced.
S305, determining the subprogram to be optimized according to the running time length corresponding to each subprogram.
Optionally, the terminal device may sort the total running time lengths corresponding to the subroutines. For example, the running time lengths corresponding to the sub-programs output by the terminal device are sorted from high to low. And determining the subprogram with the total running time length being greater than or equal to the preset time threshold as the subprogram to be optimized.
Alternatively, the subprogram to be optimized may be determined according to the running time of each subprogram. For example, in the WRF mode, the total operation time of the radiation process modules is 10 seconds, the total operation time of the land process modules is 8 seconds, but the operation time of each radiation process module is 2 seconds, and the operation time of each land process module is 4 seconds, and the land process modules can be used as the subroutines to be optimized.
Optionally, the running duration of each subroutine may be obtained multiple times, the average running duration of each subroutine is obtained, and the subroutine to be optimized is determined according to the average running duration of each subroutine.
In this application, a terminal device may obtain a first program, where the first program includes a plurality of subprograms. And the terminal equipment adds the timing code in each subprogram according to the corresponding relation between the adding position and the timing code to obtain a second program. And the terminal equipment runs the second program, and obtains the running time length corresponding to each subprogram through the timing code in the running process of the second program. And determining the subprogram to be optimized according to the running time length corresponding to each subprogram. Because each subprogram in the second program is added with the corresponding timing code, when the terminal device runs the second program, the timing code can acquire the running time of each subprogram, and a user can determine the subprogram to be optimized according to the running time of each subprogram, so that the terminal device can accurately determine the calculation module to be optimized, and the optimization efficiency of the calculation module is further improved.
Fig. 4 is a schematic structural diagram of a program processing apparatus according to an embodiment of the present application. The apparatus may be disposed in a terminal device, please refer to fig. 4, where the program processing apparatus 10 includes an obtaining module 11, an adding module 12, an operating module 13, and a determining module 14, where:
the obtaining module 11 is configured to obtain a first program, where the first program includes multiple subprograms;
the adding module 12 is configured to add a timing code corresponding to each sub-program in the first program to obtain a second program;
the running module 13 is configured to run the second program, and obtain a running duration corresponding to each sub-program through the timing code in a running process of the second program;
the determining module 14 is configured to determine the subprogram to be optimized according to the running time duration corresponding to each subprogram.
In a possible implementation manner, the adding module is specifically configured to:
determining a plurality of position sets in the first program, wherein the position sets comprise a plurality of adding positions;
determining a timing code corresponding to each adding position;
adding a corresponding timing code at each adding position respectively.
In one possible embodiment, the set of locations comprises:
the starting position of the subprogram code;
an end position of the subroutine code;
an end position of the first program code.
In one possible embodiment, the timing code comprises:
a variable assignment code;
a first variable code;
a second variable code;
the variable outputs the code.
In a possible implementation manner, the adding module is specifically configured to:
when the adding position is the initial position of the subprogram code, determining that the timing code corresponding to the adding position is a variable assignment code and a first variable code; or,
when the adding position is the end position of the subprogram code, determining that the timing code corresponding to the adding position is a second variable code; or,
and when the adding position is the end position of the first program code, determining that the timing code corresponding to the adding position is a variable output code.
In a possible implementation, the determining module is specifically configured to:
and determining the subprogram with the running time length being greater than or equal to the first threshold value as the subprogram to be optimized.
The frequency adjustment apparatus provided in the embodiment of the present application can implement the technical solutions shown in the above method embodiments, and the implementation principles and beneficial effects thereof are similar, and are not described herein again.
Fig. 5 is a schematic hardware structure diagram of a program processing device according to an embodiment of the present application. Referring to fig. 5, the program processing device 20 may include: a processor 21 and a memory 22, wherein the processor 21 and the memory 22 may communicate; illustratively, the processor 21 and the memory 22 communicate via a communication bus 23, the memory 22 being configured to store program instructions, and the processor 21 being configured to call the program instructions in the memory to perform the program processing method shown in any of the above-described method embodiments.
Optionally, the program processing device 20 may further comprise a communication interface, which may comprise a transmitter and/or a receiver.
Optionally, the Processor may be a Central Processing Unit (CPU), or may be another general-purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present application may be embodied directly in a hardware processor, or in a combination of the hardware and software modules in the processor.
A readable storage medium having a computer program stored thereon; the computer program is for implementing the program processing method according to any of the embodiments described above.
The embodiment of the application provides a computer program product, which comprises instructions, and when the instructions are executed, the instructions cause a computer to execute the program processing method.
All or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The aforementioned program may be stored in a readable memory. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned memory (storage medium) includes: read-only memory (ROM), RAM, flash memory, hard disk, solid state disk, magnetic tape (magnetic tape), floppy disk (flexible disk), optical disk (optical disk), and any combination thereof.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. 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 processing unit 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 processing unit 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 embodiments of the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to encompass such modifications and variations.
It should be understood that, although the respective steps in the flowcharts in the above-described embodiments are sequentially shown as indicated by arrows, the steps are not necessarily performed sequentially as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, in different orders, and may be performed alternately or at least partially with respect to other steps or sub-steps of other steps.
In the present application, the terms "include" and variations thereof may refer to non-limiting inclusions; the term "or" and variations thereof may mean "and/or". The terms "first," "second," and the like in this application are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. In the present application, "a plurality" means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.

Claims (14)

1. A program processing method characterized by comprising:
acquiring a first program, wherein the first program comprises a plurality of subprograms;
adding a timing code corresponding to each subprogram in the first program to obtain a second program;
running the second program, and acquiring the running time corresponding to each subprogram through the timing code in the running process of the second program;
and determining the subprogram to be optimized according to the running time length corresponding to each subprogram.
2. The method of claim 1, wherein adding a timing code corresponding to each sub-program to the first program to obtain a second program comprises:
determining a plurality of position sets in the first program, wherein the position sets comprise a plurality of adding positions;
determining a timing code corresponding to each adding position;
adding a corresponding timing code at each adding position respectively.
3. The method of claim 2, wherein the set of locations comprises:
the starting position of the subprogram code;
an end position of the subroutine code;
an end position of the first program code.
4. A method according to claim 2 or 3, wherein the timing code comprises:
a variable assignment code;
a first variable code;
a second variable code;
the variable outputs the code.
5. The method of claim 2, wherein determining a timing code for each add location comprises:
when the adding position is the initial position of the subprogram code, determining that the timing code corresponding to the adding position is a variable assignment code and a first variable code; or,
when the adding position is the end position of the subprogram code, determining that the timing code corresponding to the adding position is a second variable code; or,
and when the adding position is the end position of the first program code, determining that the timing code corresponding to the adding position is a variable output code.
6. The method according to any one of claims 1 to 3, wherein determining the sub-programs to be optimized according to the running time duration corresponding to each sub-program comprises:
and determining the subprogram with the running time length being greater than or equal to the first threshold value as the subprogram to be optimized.
7. A program processing apparatus comprising an acquisition module, an addition module, an execution module, and a determination module, wherein:
the acquisition module is used for acquiring a first program, and the first program comprises a plurality of subprograms;
the adding module is used for adding a timing code corresponding to each subprogram in the first program to obtain a second program;
the running module is used for running the second program and acquiring the running time corresponding to each subprogram through the timing code in the running process of the second program;
the determining module is used for determining the subprogram to be optimized according to the running time length corresponding to each subprogram.
8. The apparatus of claim 7, wherein the adding module is specifically configured to:
determining a plurality of position sets in the first program, wherein the position sets comprise a plurality of adding positions;
determining a timing code corresponding to each adding position;
adding a corresponding timing code at each adding position respectively.
9. The apparatus of claim 8, wherein the set of locations comprises:
the starting position of the subprogram code;
an end position of the subroutine code;
an end position of the first program code.
10. The apparatus of claim 8 or 9, wherein the timing code comprises:
a variable assignment code;
a first variable code;
a second variable code;
the variable outputs the code.
11. The apparatus of claim 8, wherein the adding module is specifically configured to:
when the adding position is the initial position of the subprogram code, determining that the timing code corresponding to the adding position is a variable assignment code and a first variable code; or,
when the adding position is the end position of the subprogram code, determining that the timing code corresponding to the adding position is a second variable code; or,
and when the adding position is the end position of the first program code, determining that the timing code corresponding to the adding position is a variable output code.
12. The apparatus according to any one of claims 7 to 9, wherein the determining module is specifically configured to:
and determining the subprogram with the running time length being greater than or equal to the first threshold value as the subprogram to be optimized.
13. A program processing apparatus characterized by comprising: a memory for storing program instructions, a processor for calling the program instructions in the memory to perform the program processing method of any one of claims 1-6, and a communication interface.
14. A readable storage medium, characterized in that the readable storage medium has stored thereon a computer program; the computer program is for implementing a program processing method as claimed in any one of claims 1 to 6.
CN202010965658.1A 2020-09-15 2020-09-15 Program processing method, device and equipment Pending CN112083931A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010965658.1A CN112083931A (en) 2020-09-15 2020-09-15 Program processing method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010965658.1A CN112083931A (en) 2020-09-15 2020-09-15 Program processing method, device and equipment

Publications (1)

Publication Number Publication Date
CN112083931A true CN112083931A (en) 2020-12-15

Family

ID=73737061

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010965658.1A Pending CN112083931A (en) 2020-09-15 2020-09-15 Program processing method, device and equipment

Country Status (1)

Country Link
CN (1) CN112083931A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113791801A (en) * 2021-09-07 2021-12-14 浙江三维利普维网络有限公司 Application program updating method and device, storage medium and electronic device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080127067A1 (en) * 2006-09-06 2008-05-29 Matthew Edward Aubertine Method and system for timing code execution in a korn shell script
US20110055818A1 (en) * 2009-08-26 2011-03-03 Kabushiki Kaisha Toshiba Source code analyzing system and source code analyzing method
CN107480043A (en) * 2016-12-23 2017-12-15 宝沃汽车(中国)有限公司 The method of testing and system of code execution time
CN110008008A (en) * 2017-12-29 2019-07-12 广东欧珀移动通信有限公司 Applied program processing method and device, electronic equipment, computer readable storage medium
CN111414295A (en) * 2020-03-09 2020-07-14 浙江大华技术股份有限公司 CPU occupancy rate statistical method, device, equipment and medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080127067A1 (en) * 2006-09-06 2008-05-29 Matthew Edward Aubertine Method and system for timing code execution in a korn shell script
US20110055818A1 (en) * 2009-08-26 2011-03-03 Kabushiki Kaisha Toshiba Source code analyzing system and source code analyzing method
CN107480043A (en) * 2016-12-23 2017-12-15 宝沃汽车(中国)有限公司 The method of testing and system of code execution time
CN110008008A (en) * 2017-12-29 2019-07-12 广东欧珀移动通信有限公司 Applied program processing method and device, electronic equipment, computer readable storage medium
CN111414295A (en) * 2020-03-09 2020-07-14 浙江大华技术股份有限公司 CPU occupancy rate statistical method, device, equipment and medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113791801A (en) * 2021-09-07 2021-12-14 浙江三维利普维网络有限公司 Application program updating method and device, storage medium and electronic device

Similar Documents

Publication Publication Date Title
RU2010139459A (en) AGGREGATION OF REPEATED PLANS TO OPTIMIZE RESOURCE CONSUMPTION
CN106055409A (en) Allocation method for processor resources and mobile terminal
CN110888658B (en) Method and device for dynamically changing function modules in application program and storage medium
CN113645262A (en) Cloud computing service system and method
CN112667405A (en) Information processing method, device, equipment and storage medium
CN112083931A (en) Program processing method, device and equipment
CN111399868B (en) Software updating method, microprocessor, domain controller and readable storage medium
CN109657317B (en) CPLD pin allocation method, system and equipment
CN109032685A (en) A kind of method and terminal accelerating Android system starting
CN110008020A (en) EMS memory management process, device, electronic equipment and computer readable storage medium
CN109408225B (en) Resource capacity expansion method, device, computer equipment and storage medium
CN115237455B (en) Application management method and related equipment
CN104090747A (en) Method for optimizing Linux intelligent terminal through real-time scheduling optimizer
CN113196232A (en) Neural network scheduling method and device, computer equipment and readable storage medium
CN114741172B (en) Operator scheduling method, device and equipment of artificial intelligent model and storage medium
CN116126937A (en) Job scheduling method, job scheduling device, electronic equipment and storage medium
CN113468442A (en) Resource bit flow distribution method, computing device and computer storage medium
CN111290850B (en) Data storage method, device and equipment
CN109753291A (en) A kind of intelligent terminal, its application management method, device and storage medium
CN110333870B (en) Simulink model variable distribution processing method, device and equipment
CN113098960A (en) Service operation method, device, server and storage medium
CN118410998B (en) Method, device, storage medium and program product for determining number of uninterrupted shop operation and maintenance vehicles
CN117493003B (en) Resource scheduling method, device, terminal equipment and readable storage medium
CN110602187A (en) Terminal sharing method, device and equipment
CN105988804B (en) Software transfer method and terminal

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