CN115437934A - Method and device for detecting time consumption of method in program and storage medium - Google Patents

Method and device for detecting time consumption of method in program and storage medium Download PDF

Info

Publication number
CN115437934A
CN115437934A CN202211083723.3A CN202211083723A CN115437934A CN 115437934 A CN115437934 A CN 115437934A CN 202211083723 A CN202211083723 A CN 202211083723A CN 115437934 A CN115437934 A CN 115437934A
Authority
CN
China
Prior art keywords
time
program
methods
detected
identification information
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
CN202211083723.3A
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.)
Ping An E Wallet Electronic Commerce Co Ltd
Original Assignee
Ping An E Wallet Electronic Commerce Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An E Wallet Electronic Commerce Co Ltd filed Critical Ping An E Wallet Electronic Commerce Co Ltd
Priority to CN202211083723.3A priority Critical patent/CN115437934A/en
Publication of CN115437934A publication Critical patent/CN115437934A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • G06F11/3612Software analysis for verifying properties of programs by runtime analysis

Abstract

The invention discloses a method and a device for detecting time-consuming methods in a program and a storage medium, relates to the technical field of information, and can improve the detection efficiency and the detection precision of the time-consuming methods in the program. The method comprises the following steps: receiving a method time-consuming detection instruction corresponding to a program to be tested, wherein the method time-consuming detection instruction carries first identification information corresponding to the program to be tested; determining a detection template corresponding to the program to be tested based on the first identification information; based on the detection template, second identification information corresponding to a plurality of methods to be detected in the program to be detected is obtained, and method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information are displayed; and calculating the method time consumption time respectively corresponding to a plurality of methods to be detected in the program to be tested based on the method execution starting time and the method execution ending time. The method is suitable for detecting the time consumption of the method in the program.

Description

Method and device for detecting time consumption of method in program and storage medium
Technical Field
The present invention relates to the field of information technology, and in particular, to a method and apparatus for detecting time consumption of a method in a program, and a storage medium.
Background
After the application program is developed, for example, the application program in the medical field needs to be subjected to performance test, the running speed of the application program is a necessary link in the performance test, and the time consumption of the method in the application program is an important factor for reflecting the running speed of the application program.
At present, the time consumed by each method in the program is generally determined by calling all data of the application program during running and by means of manual screening. However, the manual screening method for all the data of the program operation reduces the time-consuming detection efficiency of the method, and meanwhile, due to the fact that technical levels of workers are different, wrong data can be screened from the program operation data, and the time-consuming detection precision of the method in the program is low.
Disclosure of Invention
The invention provides a method and a device for detecting time consumption of a method in a program and a storage medium, and mainly aims to improve the detection efficiency and the detection precision of the time consumption of the method in the program.
According to a first aspect of the present invention, there is provided a method of in-process method time-consuming detection, comprising:
receiving a method time-consuming detection instruction corresponding to a program to be tested, wherein the method time-consuming detection instruction carries first identification information corresponding to the program to be tested;
determining a detection template corresponding to the program to be tested based on the first identification information;
based on the detection template, second identification information corresponding to a plurality of methods to be detected in the program to be detected is obtained, and method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information are displayed;
and calculating the method time consumption time corresponding to each of the plurality of methods to be detected in the program to be tested based on the method execution starting time and the method execution ending time.
According to a second aspect of the present invention, there is provided a time consuming method of detecting in-process errors, comprising:
the device comprises a receiving unit and a processing unit, wherein the receiving unit is used for receiving a method time-consuming detection instruction corresponding to a program to be tested, and the method time-consuming detection instruction carries first identification information corresponding to the program to be tested;
the determining unit is used for determining a detection template corresponding to the program to be tested based on the first identification information;
the display unit is used for acquiring second identification information corresponding to a plurality of methods to be detected in the program to be detected respectively based on the detection template, and displaying method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information respectively;
and the calculating unit is used for calculating the time consumed by the methods corresponding to the plurality of methods to be detected in the program to be tested based on the method execution starting time and the method execution ending time.
According to a third aspect of the present invention, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of:
receiving a method time-consuming detection instruction corresponding to a program to be tested, wherein the method time-consuming detection instruction carries first identification information corresponding to the program to be tested;
determining a detection template corresponding to the program to be tested based on the first identification information;
based on the detection template, second identification information corresponding to a plurality of methods to be detected in the program to be detected is obtained, and method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information are displayed;
and calculating the method time consumption time respectively corresponding to a plurality of methods to be detected in the program to be tested based on the method execution starting time and the method execution ending time.
According to a fourth aspect of the present invention, there is provided a computer apparatus comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the program:
receiving a method time-consuming detection instruction corresponding to a program to be tested, wherein the method time-consuming detection instruction carries first identification information corresponding to the program to be tested;
determining a detection template corresponding to the program to be tested based on the first identification information;
based on the detection template, second identification information corresponding to a plurality of methods to be detected in the program to be detected is obtained, and method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information are displayed;
and calculating the method time consumption time respectively corresponding to a plurality of methods to be detected in the program to be tested based on the method execution starting time and the method execution ending time.
According to the method, the device and the storage medium for detecting the time consumption of the method in the program, compared with the mode that the time consumption of each method is screened out from all data of program operation manually at present, the method comprises the steps of receiving a method time consumption detection instruction corresponding to a program to be tested, wherein the method time consumption detection instruction carries first identification information corresponding to the program to be tested; determining a detection template corresponding to the program to be tested based on the first identification information; meanwhile, second identification information corresponding to the plurality of methods to be detected in the program to be tested is obtained based on the detection template, and method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information are displayed; finally, method time consuming time corresponding to a plurality of methods to be detected in the program to be tested is calculated based on the method execution starting time and the method execution ending time, so that the method execution starting time and the method execution ending time corresponding to the plurality of methods to be detected are obtained by using the detection template corresponding to the program to be tested, and the method time consuming time corresponding to the plurality of methods to be detected in the program to be tested is determined based on the method execution starting time and the method execution ending time, so that the method time consuming detection efficiency is improved, meanwhile, the method time consuming detection errors caused by the fact that wrong data are screened out due to the fact that technical levels of developers are different are avoided, and the method time consuming detection accuracy is improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a flow chart illustrating a method for detecting time consumption of a method in a program according to an embodiment of the present invention;
FIG. 2 is a flow chart of a time-consuming method for detecting a method in another program according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a detection apparatus for detecting the time consumption of a method in a program according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of an alternative embodiment of a time-consuming method for detecting a device in accordance with the present invention;
fig. 5 shows a schematic physical structure diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The invention will be described in detail hereinafter with reference to the drawings and embodiments. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
At present, the time-consuming detection efficiency of the methods in the program is low due to the mode of manually screening the time-consuming conditions of all the methods in the program operation, meanwhile, due to the fact that technical levels of workers are different, wrong data can be screened from the program operation data, and the time-consuming detection precision of the methods in the program is low.
In order to solve the above problem, an embodiment of the present invention provides a time-consuming detection method for a method in a program, as shown in fig. 1, the method includes:
101. receiving a method time-consuming detection instruction corresponding to a program to be tested, wherein the method time-consuming detection instruction carries first identification information corresponding to the program to be tested.
The method comprises the steps that a program to be tested is an application program which needs to be tested after a developer finishes developing the program, such as a medical inquiry program, a registration program and the like, time consumed by the method is the time consumed by a certain method of the program from the beginning to the end of execution, first identification information is a mark used for identifying the program to be tested, different programs correspond to different identification information, the first identification information can be icon information or character information and the like, and the representation mode of the first identification information is not specifically limited.
For the embodiment of the invention, in order to solve the problems of low detection efficiency and low detection precision of the time-consuming method in the program in the prior art, the embodiment of the invention obtains the execution start time and the execution end time of the modes respectively corresponding to a plurality of methods to be detected by using the detection template corresponding to the program to be detected, and finally determines the time-consuming time of the methods respectively corresponding to the plurality of methods to be detected in the program to be detected based on the execution start time and the execution end time of the methods, so that the time-consuming detection efficiency of the methods is improved, and meanwhile, the time-consuming detection errors of the methods caused by the fact that wrong data are screened out by developers in different technical levels are avoided, thereby improving the time-consuming detection precision of the methods. The embodiment of the invention is mainly applied to a detection scene of the method time consumption in the program, and the execution main body of the embodiment of the invention is a device or equipment capable of detecting the method time consumption in the program, and can be specifically arranged at a client side or a server side.
Specifically, according to the embodiment of the present invention, a detect-method-cost plug-in is used to detect the time consumed by each method in a program, and specifically, a start command of a program to be tested may be modified, the plug-in is embedded into the start command, that is, a code for calculating time consumed is added to a code corresponding to each method in the program to be tested, and at the same time, unique corresponding identification information is set for each method in the program to be tested, and then, the time consumed by the method corresponding to each identification information is calculated by using the code for calculating time consumed and the identification information, for example, a period of try \8230, find \8230isadded to each method, and when entering a logic of try, a code "long start time = system. Recording the code execution starting time, then continuously writing the method execution ending time in the final, calculating whether the method consumed time corresponding to each method can be calculated through the method execution starting time and the method execution ending time of each method, and printing a log according to a certain log specification, wherein the log records the identification information of each method and the method consumed time corresponding to each method.
Further, when a plug-in is inserted into a starting command of a program to be tested, a time-consuming detection software is developed, when the time-consuming time of a method in the program to be tested needs to be detected, the time-consuming detection software is firstly opened, a time-consuming check button is clicked in a displayed time-consuming detection main interface, a pull-down menu appears, the program to be tested is selected from the pull-down menu, namely a method time-consuming detection instruction corresponding to the program to be tested is triggered, then a detection template corresponding to the program to be tested is determined based on first identification information corresponding to the program to be tested carried in the method time-consuming detection instruction, and then any method to be detected can be selected by utilizing the detection template. Therefore, by using the detect-method-cost.jar plug-in and the time-consuming detection software, the time-consuming time corresponding to each method in the program to be tested can be quickly detected, the time-consuming detection efficiency of the methods in the program is improved, the time-consuming condition of the methods can be displayed in the detection template, and the user can conveniently check the time-consuming condition.
102. And determining a detection template corresponding to the program to be tested based on the first identification information.
The method comprises the steps that different programs correspond to different detection templates, first identification information corresponding to the programs to be detected or information such as program names, detection dates, detection persons and departments where the detection persons are located corresponding to the programs to be detected are automatically linked in the detection templates, and meanwhile the detection templates comprise detection method title items, method execution starting time title items, method execution ending time title items and method total time consumption title items. In order to facilitate the developer to check the time consumption of the method corresponding to any method, each method has a method execution start time title item, a method execution end time title item and a method total time consumption title item corresponding to the method.
For the embodiment of the invention, the detection templates corresponding to different programs are pre-established, the mapping relation is established between the detection templates and the application program, after the program to be tested is selected in the time-consuming detection software main interface, the time-consuming detection software automatically links the detection template corresponding to the program to be tested on the position based on the mapping relation between the unused program and the different detection templates, and displays the detection template on the detection personnel terminal, so that the detection personnel at the detection personnel terminal can determine the time-consuming time of any method in the program to be tested based on the detection template. Therefore, the time-consuming detection efficiency of the method in the program can be improved, and meanwhile, the time-consuming detection error of the method caused by the fact that wrong data are screened out due to the technical level irregularity of developers can be avoided, and the time-consuming detection precision of the method is improved.
103. And acquiring second identification information corresponding to a plurality of methods to be detected in the program to be detected respectively based on the detection template, and displaying method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information respectively.
The second identification information is a mark used for identifying the method to be detected, different methods correspond to different identification information, the second identification information can be icon information or character information, and the like.
For the embodiment of the invention, after the detection template corresponding to the program to be detected is displayed on the detection personnel terminal, the detection personnel selects the second identification information corresponding to any method to be detected in the pull-down menu corresponding to the title item of the detection method in the detection template based on the detection template, and after the second identification information is selected, the method time consumption checking instruction corresponding to the method to be detected is triggered, based on the method time consumption checking instruction, the method execution starting time and the method execution ending time corresponding to the method to be detected are displayed at the corresponding positions, and meanwhile, based on the method execution starting time and the method execution ending time, the method time consumption time corresponding to the method to be detected is calculated and displayed at the corresponding positions, for example, the second identification information corresponding to the method 1 is selected in the pull-down menu corresponding to the title item of the detection method, then the second identification information corresponding to the method 1 is displayed in a blank frame corresponding to the method execution start time title item 1 under the detection method title item, and the method execution start time, while the second identification information corresponding to the method 1 is displayed in a blank frame corresponding to the method execution end time title item 1 under the method execution start time title item 1, and the method execution end time, and at the same time, displaying second identification information corresponding to the method 1 and the time consumed by the method in a blank frame corresponding to the total time consumed by the method 1 under the title item 1 of the execution ending time of the method, and if a detection person selects the method 2 in a pull-down menu corresponding to the title item of the detection method, displaying the title item of the execution starting time of the method corresponding to the method 2 in another column under the title item of the detection method, the method comprises the steps of executing a time title item and a total time consuming title item of the method, displaying the time corresponding to each title item, wherein the title items corresponding to different methods can also be displayed in a row form in parallel, and specifically, the display method of each title item corresponding to each method is not specifically limited in the embodiment of the invention, and is convenient for a detection person to check.
104. And calculating the method time consumption time corresponding to each of the plurality of methods to be detected in the program to be tested based on the method execution starting time and the method execution ending time.
For the embodiment of the invention, after any method to be detected is selected from the pull-down menu corresponding to the title item of the detection method in the detection template, the second identification information, the method execution starting time and the method execution ending time corresponding to the method to be detected are correspondingly displayed to the detection personnel terminal at the corresponding position, based on the method execution starting time and the method execution ending time, the method consumed time corresponding to the method to be detected can be calculated, and the second identification information and the method consumed time corresponding to the method to be detected are correspondingly displayed at the blank position of the title item of the total method consumed time. Therefore, the method time-consuming detection efficiency is improved by acquiring the mode execution starting time and the method execution ending time corresponding to the multiple methods to be detected respectively by using the detection template corresponding to the program to be detected, and finally determining the method time-consuming time corresponding to the multiple methods to be detected in the program to be detected respectively based on the method execution starting time and the method execution ending time.
According to the method for detecting the time consumption of the method in the program, compared with the mode that the time consumption time of each method is manually screened from all data of program operation at present, the method for detecting the time consumption of the method in the program is characterized in that a method time consumption detection instruction corresponding to the program to be tested is received, wherein the method time consumption detection instruction carries first identification information corresponding to the program to be tested; determining a detection template corresponding to the program to be tested based on the first identification information; meanwhile, second identification information corresponding to the plurality of methods to be detected in the program to be tested is obtained based on the detection template, and method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information are displayed; finally, method time consuming time corresponding to a plurality of methods to be detected in the program to be tested is calculated based on the method execution starting time and the method execution ending time, so that the method execution starting time and the method execution ending time corresponding to the plurality of methods to be detected are obtained by using the detection template corresponding to the program to be tested, and the method time consuming time corresponding to the plurality of methods to be detected in the program to be tested is determined based on the method execution starting time and the method execution ending time, so that the method time consuming detection efficiency is improved, meanwhile, the method time consuming detection errors caused by the fact that wrong data are screened out due to the fact that technical levels of developers are different are avoided, and the method time consuming detection accuracy is improved.
Further, in order to better describe the process of detecting the time consumption of the method in the program, as a refinement and an extension of the foregoing embodiment, an embodiment of the present invention provides another method for detecting the time consumption of the method in the program, as shown in fig. 2, where the method includes:
201. receiving a method time-consuming detection instruction corresponding to a program to be tested, wherein the method time-consuming detection instruction carries first identification information corresponding to the program to be tested.
Specifically, the time-consuming detection software is opened, a time-consuming detection button in a main interface of the time-consuming detection software is clicked, a program to be tested is selected from a displayed pull-down menu, namely a method time-consuming detection instruction corresponding to the program to be tested is triggered, then a detection template corresponding to the program to be tested is determined based on first identification information corresponding to the program to be tested carried in the method time-consuming detection instruction, and finally time-consuming time of a method corresponding to any method is determined through the detection template.
202. And determining a detection template corresponding to the program to be tested based on the first identification information.
For the embodiment of the present invention, in order to determine the detection template corresponding to the program to be tested, the detection template needs to be constructed first, and the specific construction method is as follows: determining various methods corresponding to different application programs, and determining second identification information corresponding to the various methods; storing each second identification information into an identification information base corresponding to the different application programs; and constructing detection templates corresponding to the different application programs, and establishing mapping relations between the different detection templates and different identification information bases.
Specifically, different applications correspond to respective methods, for example, the application 1 includes 3 methods, the application 2 includes 5 methods, and the application 3 includes 8 methods, and first, the respective methods corresponding to the different applications need to be determined, then, the second identification information corresponding to the respective methods is determined, and the respective second identification information is stored in the identification information libraries corresponding to the different applications, for example, the second identification information corresponding to the 3 methods included in the application program 1 is stored in the identification information base 1 corresponding to the application program 1, the second identification information respectively corresponding to the 5 methods contained in the application program 2 is stored in the identification information base 2 corresponding to the application program 2, storing the second identification information corresponding to the 8 methods included in the application program 3 into the identification information base 3 corresponding to the application program 3, and at the same time, establishing detection templates corresponding to different application programs, in order to select only each method included in the program to be tested in the detection template, a mapping relationship between different detection templates and different identification information bases needs to be constructed, for example, a mapping relation is established between the detection template 1 corresponding to the application program 1 and the identification information base 1, a mapping relation is established between the detection template 2 corresponding to the application program 2 and the identification information base 2, and a mapping relation is established between the detection template 3 corresponding to the application program 3 and the identification information base 3, so that the defects of long selection time and inaccurate selection caused by selecting a method corresponding to a target application program from all methods contained in all application programs are avoided, therefore, the selection efficiency of the method in the program is improved, and the time-consuming detection efficiency of the method in the program is further improved.
Further, after the detection templates corresponding to different application programs are constructed and the mapping relationships between different detection templates and different identification information bases are established, the detection template corresponding to the program to be tested can be determined based on the first identification information corresponding to the program to be tested carried in the time-consuming detection instruction, and the identification information base corresponding to the program to be tested can be automatically linked out of the detection template based on the mapping relationships between different detection templates and different identification information bases, wherein the identification information base stores second identification information corresponding to each method included in the program to be tested.
203. And acquiring second identification information respectively corresponding to a plurality of methods to be detected in the program to be detected based on the detection template.
For the embodiment of the present invention, in order to detect the time consuming situations of a plurality of methods to be detected in the program to be tested, a plurality of methods to be detected need to be selected from the detection template first, and based on this, step 203 specifically includes: determining an identification information base corresponding to the detection template based on the mapping relation between different detection templates and different identification information bases; and acquiring second identification information respectively corresponding to a plurality of methods to be detected selected by the user from the identification information base for the program to be detected.
Specifically, after different programs correspond to different detection templates, after the program to be detected is determined, an inspection template corresponding to the program to be detected is determined, and because mapping relationships exist between different detection templates and different identification information bases, an identification information base corresponding to the detection template can be determined based on the mapping relationships between the different detection templates and the different identification information bases, second identification information corresponding to each method included in the program to be detected is recorded in the identification information base, a pull-down menu is displayed by clicking a detection method title item in the detection template, all second identification information in the identification information base corresponding to the program to be detected is displayed in the pull-down menu, and second identification information corresponding to a method to be detected is selected from the second identification information, so that the method execution start time, the method execution end time and the method consumption time corresponding to the method to be detected are determined based on the second identification information.
204. Inserting a start time detection function in execution entries of the plurality of methods to be detected, and inserting an end time detection function in execution exits of the plurality of methods to be detected.
Specifically, the method for specifically determining the method execution start time and the method execution end time corresponding to the method to be detected includes inserting a start time detection function into execution entries of a plurality of methods to be detected, where the start time detection function may be a try time function, determining the method execution end time corresponding to the method to be detected by using the try time function, and simultaneously inserting an end time detection function into execution exits of the plurality of methods to be detected, where the end time function may be a final time function, and determining the method execution end time corresponding to the method to be detected by using the final time function.
205. And determining method execution starting time corresponding to the methods to be detected respectively by using the starting time detection function, determining method execution ending time corresponding to the methods to be detected respectively by using the ending time detection function, and displaying a plurality of second identification information and method execution starting time and method execution ending time corresponding to the second identification information in the detection template.
Specifically, when an execution entry corresponding to the method to be detected exists, second identification information corresponding to the method is acquired, and a try time function call code "long startTime = system. Determining method execution start time, correspondingly storing the second identification information and the method execution start time, acquiring the second identification information corresponding to the method when an execution outlet corresponding to the to-be-detected method exists, determining method execution end time corresponding to the to-be-detected method by using a finally time function, correspondingly storing the second identification information and the method execution end time, and correspondingly displaying the second identification information, the method execution start time and the method execution end time corresponding to the to-be-detected method in the to-be-detected program at corresponding positions of the detection template after determining method execution start time and method execution end time corresponding to a plurality of to-be-detected methods in the to-be-detected program.
206. And calculating the method time consumption time corresponding to each of the plurality of methods to be detected in the program to be tested based on the method execution starting time and the method execution ending time.
For the embodiment of the present invention, after determining the method execution start time and the method execution end time corresponding to a plurality of methods to be detected, calculating the time consumed by the methods corresponding to the plurality of methods to be detected in the program to be tested based on the method execution start time and the method execution end time, and based on this, step 206 specifically includes: and subtracting the method execution ending time corresponding to each of the methods to be detected from the method execution starting time corresponding to the method to be detected to obtain the method time consumption time corresponding to each of the methods to be detected.
Specifically, the method time consumption time corresponding to the method can be obtained by subtracting the method execution end time corresponding to any one of the methods to be detected from the method execution start time corresponding to the method, so that the method time consumption times corresponding to the methods to be detected can be determined, and the second identification information and the method time consumption times corresponding to the methods to be detected are correspondingly displayed at corresponding positions in the detection template.
Further, after the second identification information, the method execution start time, the method execution end time and the method time consumption time corresponding to the plurality of methods to be detected are correspondingly displayed at the corresponding positions of the detection template, in order to allow developers to view the time consumption situation of each method, the method further comprises: generating a time-consuming test list corresponding to the multiple methods to be detected based on the second identification information and the method time-consuming time corresponding to the multiple methods to be detected respectively, wherein the second identification information and the method time-consuming time corresponding to the multiple methods to be detected in the time-consuming test list are correspondingly stored; and transmitting the time-consuming test list to a developer terminal so that a developer of the developer terminal can check the time-consuming times of the methods to be detected in the program to be tested, which respectively correspond to the methods to be detected, based on the time-consuming test list.
Specifically, based on all information displayed in the detection template, a time-consuming detection list corresponding to a plurality of methods to be detected in the program to be detected is generated, and the time-consuming detection list is transmitted to the developer terminal, and specifically, the method for transmitting the time-consuming detection list to the developer terminal is as follows: generating a method time-consuming notice which corresponds to the plurality of methods to be detected based on the time-consuming detection list which corresponds to the plurality of methods to be detected; and calling a preset communication tool interface, and sending the method time-consuming notification to the developer terminal so that a developer of the developer terminal can view the time-consuming detection list based on the method time-consuming notification.
Specifically, after a time-consuming test list corresponding to a plurality of methods to be tested is generated, in order to notify a developer to view the time-consuming test list, a method time-consuming notification corresponding to the time-consuming test list needs to be generated, wherein the time-consuming notification includes a storage location of the time-consuming test list, and then a communication tool interface such as a WeChat, an email, or a short message is called, and the method time-consuming notification is sent to the developer, so that a developer at a developer terminal can view the time-consuming test list in the storage location based on the storage location recorded in the time-consuming test list, and can view the time-consuming situation of each method in a program based on the content recorded in the time-consuming test list.
According to another method for detecting the time consumption of the method in the program, compared with the mode that the time consumption of each method is screened out from all data of the program operation manually at present, the method comprises the steps of receiving a method time consumption detection instruction corresponding to the program to be tested, wherein the method time consumption detection instruction carries first identification information corresponding to the program to be tested; determining a detection template corresponding to the program to be tested based on the first identification information; meanwhile, second identification information corresponding to the plurality of methods to be detected in the program to be tested is obtained based on the detection template, and method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information are displayed; finally, method time consuming time corresponding to a plurality of methods to be detected in the program to be tested is calculated based on the method execution starting time and the method execution ending time, so that the method execution starting time and the method execution ending time corresponding to the plurality of methods to be detected are obtained by using the detection template corresponding to the program to be tested, and the method time consuming time corresponding to the plurality of methods to be detected in the program to be tested is determined based on the method execution starting time and the method execution ending time, so that the method time consuming detection efficiency is improved, meanwhile, the method time consuming detection errors caused by the fact that wrong data are screened out due to the fact that technical levels of developers are different are avoided, and the method time consuming detection accuracy is improved.
Further, as a specific implementation of fig. 1, an embodiment of the present invention provides a detection apparatus for detecting a time-consuming method in a program, where as shown in fig. 3, the apparatus includes: a receiving unit 31, a determining unit 32, a presenting unit 33 and a calculating unit 34.
The receiving unit 31 may be configured to receive a method time-consuming detection instruction corresponding to a program to be tested, where the method time-consuming detection instruction carries first identification information corresponding to the program to be tested.
The determining unit 32 may be configured to determine a detection template corresponding to the program to be tested based on the first identification information.
The display unit 33 may be configured to obtain, based on the detection template, second identification information corresponding to each of the plurality of methods to be detected in the program to be detected, and display method execution start time and method execution end time of the method to be detected corresponding to each of the plurality of second identification information.
The calculating unit 34 may be configured to calculate time consumed by the methods corresponding to the plurality of methods to be detected in the program to be tested based on the method execution start time and the method execution end time.
In a specific application scenario, in order to determine the method execution start time and the method execution end time corresponding to each of the multiple methods to be detected, as shown in fig. 4, the apparatus further includes: and a unit 35 is inserted.
The inserting unit 35 may be configured to insert a start time detection function into execution entrances of the plurality of methods to be detected, and insert an end time detection function into execution exits of the plurality of methods to be detected.
The determining unit 32 may be further configured to determine, by using the start time detection function, method execution start times corresponding to the methods to be detected respectively.
The determining unit 32 may be further configured to determine, by using the end time detection function, method execution end times corresponding to the multiple methods to be detected respectively.
In a specific application scenario, in order to obtain second identification information corresponding to each of the plurality of methods to be detected in the program to be tested, the display unit 33 includes a determining module 331 and an obtaining module 332.
The determining module 331 may be configured to determine the identification information base corresponding to the detection template based on a mapping relationship between different detection templates and different identification information bases.
The obtaining module 332 may be configured to obtain second identification information corresponding to each of the plurality of to-be-detected methods selected by the user from the identification information base for the to-be-detected program.
In a specific application scenario, in order to establish a mapping relationship between different detection templates and different identification information bases, the apparatus further includes a storage unit 36 and a construction unit 37.
The determining unit 32 may be further configured to determine various methods corresponding to different application programs, and determine second identification information corresponding to the various methods.
The storage unit 36 may be configured to store each second identification information into the identification information library corresponding to the different application programs.
The constructing unit 37 may be configured to construct detection templates corresponding to the different application programs, and establish mapping relationships between the different detection templates and the different identification information bases.
In a specific application scenario, in order to calculate the method elapsed time corresponding to each of the multiple methods to be detected in the program to be tested, the calculating unit 34 may be specifically configured to subtract the method execution ending time corresponding to each of the multiple methods to be detected from the method execution starting time corresponding to the method execution ending time, so as to obtain the method elapsed time corresponding to each of the multiple methods to be detected.
In a specific application scenario, in order to generate a time-consuming test ticket and transmit the time-consuming test ticket to a developer terminal, the apparatus further includes: a generating unit 38 and a transmitting unit 39.
The generating unit 38 may be configured to generate a time-consuming test sheet corresponding to the multiple methods to be detected based on the second identification information and the method time-consuming time that correspond to the multiple methods to be detected, respectively, where the second identification information and the method time-consuming time that correspond to the multiple methods to be detected in the time-consuming test sheet are stored correspondingly.
The transmission unit 39 may be configured to transmit the time-consuming test ticket to a developer terminal, so that a developer of the developer terminal views time-consuming times of methods respectively corresponding to the multiple methods to be detected in the program to be tested based on the time-consuming test ticket.
In a specific application scenario, in order to transmit the time-consuming test ticket to the developer terminal, the transmitting unit 39 includes a generating module 391 and a sending module 392.
The generating module 391 may be configured to generate a method time consumption notification corresponding to the multiple methods to be detected jointly based on the time consumption detection sheet corresponding to the multiple methods to be detected jointly.
The sending module 392 may be configured to call a preset communication tool interface, and send the method time-consuming notification to the developer terminal, so that a developer of the developer terminal views the time-consuming detection sheet based on the method time-consuming notification.
It should be noted that other corresponding descriptions of the functional modules involved in the detection apparatus for detecting the method time consuming in the program according to the embodiment of the present invention may refer to the corresponding descriptions of the method shown in fig. 1, and are not described herein again.
Based on the method shown in fig. 1, correspondingly, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the following steps: receiving a method time-consuming detection instruction corresponding to a program to be tested, wherein the method time-consuming detection instruction carries first identification information corresponding to the program to be tested; determining a detection template corresponding to the program to be tested based on the first identification information; based on the detection template, second identification information corresponding to a plurality of methods to be detected in the program to be detected is obtained, and method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information are displayed; and calculating the method time consumption time respectively corresponding to a plurality of methods to be detected in the program to be tested based on the method execution starting time and the method execution ending time.
Based on the above embodiments of the method shown in fig. 1 and the apparatus shown in fig. 3, an embodiment of the present invention further provides an entity structure diagram of a computer device, as shown in fig. 5, where the computer device includes: a processor 41, a memory 42, and a computer program stored on the memory 42 and executable on the processor, wherein the memory 42 and the processor 41 are each arranged on a bus 43 and the processor 41 implements the following steps when executing the program: receiving a method time-consuming detection instruction corresponding to a program to be tested, wherein the method time-consuming detection instruction carries first identification information corresponding to the program to be tested; determining a detection template corresponding to the program to be tested based on the first identification information; based on the detection template, second identification information corresponding to a plurality of methods to be detected in the program to be detected is obtained, and method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information are displayed; and calculating the method time consumption time respectively corresponding to a plurality of methods to be detected in the program to be tested based on the method execution starting time and the method execution ending time.
According to the technical scheme, the method time-consuming detection instruction corresponding to the program to be tested is received, wherein the method time-consuming detection instruction carries first identification information corresponding to the program to be tested; determining a detection template corresponding to the program to be tested based on the first identification information; meanwhile, second identification information corresponding to the plurality of methods to be detected in the program to be tested is obtained based on the detection template, and method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information are displayed; finally, method time consuming time corresponding to a plurality of methods to be detected in the program to be tested is calculated based on the method execution starting time and the method execution ending time, so that the method execution starting time and the method execution ending time corresponding to the plurality of methods to be detected are obtained by using the detection template corresponding to the program to be tested, and the method time consuming time corresponding to the plurality of methods to be detected in the program to be tested is determined based on the method execution starting time and the method execution ending time, so that the method time consuming detection efficiency is improved, meanwhile, the method time consuming detection errors caused by the fact that wrong data are screened out due to the fact that technical levels of developers are different are avoided, and the method time consuming detection accuracy is improved.
It will be apparent to those skilled in the art that the modules or steps of the present invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method of in-program method time-consuming detection, comprising:
receiving a method time-consuming detection instruction corresponding to a program to be tested, wherein the method time-consuming detection instruction carries first identification information corresponding to the program to be tested;
determining a detection template corresponding to the program to be tested based on the first identification information;
based on the detection template, second identification information corresponding to a plurality of methods to be detected in the program to be detected respectively is obtained, and method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information respectively are displayed;
and calculating the method time consumption time respectively corresponding to a plurality of methods to be detected in the program to be tested based on the method execution starting time and the method execution ending time.
2. The method according to claim 1, wherein before the method execution start time and the method execution end time of the method to be detected showing the plurality of second identification information respectively correspond to, the method further comprises:
inserting a start time detection function into execution inlets of the plurality of methods to be detected, and inserting an end time detection function into execution outlets of the plurality of methods to be detected;
determining method execution starting times corresponding to the methods to be detected respectively by using the starting time detection function;
and determining the execution end time of the methods corresponding to the methods to be detected respectively by using the end time detection function.
3. The method according to claim 1, wherein the obtaining second identification information corresponding to each of a plurality of methods to be detected in the program to be tested based on the detection template comprises:
determining an identification information base corresponding to the detection template based on the mapping relation between different detection templates and different identification information bases;
and acquiring second identification information respectively corresponding to a plurality of methods to be detected selected by the user from the identification information base for the program to be detected.
4. The method of claim 1, wherein prior to said determining a detection template corresponding to the program to be tested based on the first identification information, the method further comprises:
determining various methods corresponding to different application programs, and determining second identification information corresponding to the various methods;
storing each second identification information into an identification information base corresponding to the different application programs;
and constructing detection templates corresponding to the different application programs, and establishing mapping relations between the different detection templates and different identification information bases.
5. The method according to claim 1, wherein the calculating the time consumed by the methods respectively corresponding to the plurality of methods to be detected in the program to be tested based on the time from the beginning of the method execution and the time from the end of the method execution comprises:
and subtracting the method execution ending time corresponding to each of the methods to be detected from the method execution starting time corresponding to the method to be detected to obtain the method time consumption time corresponding to each of the methods to be detected.
6. The method according to claim 1, wherein after determining the time consumed by the method corresponding to each of the plurality of methods to be tested in the program to be tested based on the method execution start time and the method execution end time, the method further comprises:
generating a time-consuming test list corresponding to the multiple methods to be tested based on second identification information and method time-consuming time corresponding to the multiple methods to be tested respectively, wherein the second identification information and the method time-consuming time corresponding to the multiple methods to be tested in the time-consuming test list are stored correspondingly;
and transmitting the time-consuming test list to a developer terminal so that a developer of the developer terminal can check the time-consuming times of the methods to be detected in the program to be tested, which respectively correspond to the methods to be detected, based on the time-consuming test list.
7. The method of claim 6, wherein transmitting the time-consuming test ticket to a developer terminal comprises:
generating a method time-consuming notice which corresponds to the plurality of methods to be detected based on the time-consuming detection list which corresponds to the plurality of methods to be detected;
and calling a preset communication tool interface, and sending the method time-consuming notification to the developer terminal so that a developer of the developer terminal can view the time-consuming detection sheet based on the method time-consuming notification.
8. A time-consuming method in a program detection device, comprising:
the device comprises a receiving unit and a processing unit, wherein the receiving unit is used for receiving a method time-consuming detection instruction corresponding to a program to be tested, and the method time-consuming detection instruction carries first identification information corresponding to the program to be tested;
the determining unit is used for determining a detection template corresponding to the program to be tested based on the first identification information;
the display unit is used for acquiring second identification information corresponding to a plurality of methods to be detected in the program to be detected respectively based on the detection template, and displaying method execution starting time and method execution ending time of the methods to be detected corresponding to the plurality of second identification information respectively;
and the calculating unit is used for calculating the time consumed by the methods corresponding to the plurality of methods to be detected in the program to be tested based on the method execution starting time and the method execution ending time.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
10. A computer arrangement comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the computer program realizes the steps of the method of any one of claims 1 to 7 when executed by the processor.
CN202211083723.3A 2022-09-06 2022-09-06 Method and device for detecting time consumption of method in program and storage medium Pending CN115437934A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211083723.3A CN115437934A (en) 2022-09-06 2022-09-06 Method and device for detecting time consumption of method in program and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211083723.3A CN115437934A (en) 2022-09-06 2022-09-06 Method and device for detecting time consumption of method in program and storage medium

Publications (1)

Publication Number Publication Date
CN115437934A true CN115437934A (en) 2022-12-06

Family

ID=84246529

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211083723.3A Pending CN115437934A (en) 2022-09-06 2022-09-06 Method and device for detecting time consumption of method in program and storage medium

Country Status (1)

Country Link
CN (1) CN115437934A (en)

Similar Documents

Publication Publication Date Title
CN105830037B (en) For showing the process of Test coverage data during code inspection
US7624340B2 (en) Key command functionality in an electronic document
CN108959059B (en) Test method and test platform
WO2019062331A1 (en) Consumable management method, sample analysis system, and computer readable storage medium
CN110503151B (en) Image processing method and system
CN112650670A (en) Application testing method, device, system, electronic equipment and storage medium
JP2021060831A (en) Inspection support system and inspection support method
CN114266539A (en) File flow processing method, system, device and computer readable storage medium
CN109240928A (en) A kind of test method, device, equipment and storage medium
CN113342692A (en) Test case automatic generation method and device, electronic equipment and storage medium
EP3764291B1 (en) Method of examining a product inspection
CN115437934A (en) Method and device for detecting time consumption of method in program and storage medium
CN108291954A (en) The establishment system and its control method of wave condition map
JP2008097119A (en) Question rating system and method
CN110866492B (en) Baseline branch identification method and device and computer system
CN114371974A (en) Buried point data checking method and electronic equipment
CN112905722B (en) Behavior recognition method and device and storage medium
CN115735368A (en) Device registration method and device, electronic device and storage medium
CN108228841B (en) Method, apparatus, storage medium and the computer equipment of intelligent aggregation information
CN112559368A (en) Interface automation test method and its use case generation method, equipment and storage medium
US20190279127A1 (en) Information processing apparatus, workflow test apparatus, and non-transitory computer readable medium
CN112014580A (en) Reagent racking method and device
CN112416735A (en) Application program detection method and device, terminal equipment and storage medium
CN111026665B (en) Test range analysis method, device and equipment
CN115033497B (en) Kernel function testing method, device, equipment and storage medium

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