CN109634822A - A kind of function time-consuming statistical method, device, storage medium and terminal device - Google Patents

A kind of function time-consuming statistical method, device, storage medium and terminal device Download PDF

Info

Publication number
CN109634822A
CN109634822A CN201811423786.2A CN201811423786A CN109634822A CN 109634822 A CN109634822 A CN 109634822A CN 201811423786 A CN201811423786 A CN 201811423786A CN 109634822 A CN109634822 A CN 109634822A
Authority
CN
China
Prior art keywords
function
time
default
execution
executing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201811423786.2A
Other languages
Chinese (zh)
Other versions
CN109634822B (en
Inventor
何兵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201811423786.2A priority Critical patent/CN109634822B/en
Publication of CN109634822A publication Critical patent/CN109634822A/en
Application granted granted Critical
Publication of CN109634822B publication Critical patent/CN109634822B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3409Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment
    • G06F11/3419Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment by assessing time
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present invention relates to technical field of software development more particularly to a kind of function time-consuming statistical method, device, storage medium and terminal devices.The described method includes: jumping to when executing default execution function and executing presetting message forwarding function;It forwards function call to obtain function at the first time by presetting message, obtains at the first time;After first time acquisition function is finished, function call target corresponding with default execution function is forwarded to execute function by presetting message, target execution function be used to carry out the default reduction execution for executing function;After target execution function is finished, passes through presetting message and the second time of function call is forwarded to obtain function, obtained for the second time;According to first time and the second time, it is time-consuming that statistics obtains the default function for executing function, to carry out the statistics of function time-consuming, the accuracy rate and efficiency of raising function time-consuming statistics in the case where not invading default execution function source code, not needing and bury point in default execution function.

Description

A kind of function time-consuming statistical method, device, storage medium and terminal device
Technical field
The present invention relates to technical field of software development more particularly to a kind of function time-consuming statistical methods, statistic device, calculating Machine readable storage medium storing program for executing and terminal device.
Background technique
For application developer, for the quality for guaranteeing application program, optimize, the function of application program, It generally requires to be tested for the property application program, come perfect, optimization application, to survey in performance based on the performance test results In examination, then the function generally required in statistics application program is time-consuming, i.e. the execution duration of function, to analyze according to duration is executed The quality of application program, so that convenient improved or optimized to application program.
In the prior art, statistical function time-consuming needs bury a little before and after the execution of the function, to obtain in function operation Correlation time information, to calculate according to acquired temporal information function time-consuming, i.e., statistical function is held in the prior art When row duration, the source code for invading each function is generally required, that is, needs to be inserted into correlation function in each function source code to obtain Temporal information, and be inserted into correlation function in function source code and then will affect the performance of application program, to will lead to statistics Function time-consuming is inaccurate, and reduces the accuracy rate of function time-consuming statistics.In addition, because of the source code for needing to invade each function, from And make when source code can not be obtained, then it can not carry out the statistics of function time-consuming.
Summary of the invention
The embodiment of the invention provides a kind of function time-consuming statistical method, statistic device, computer readable storage medium and Terminal device can carry out the statistics of function time-consuming in the case where not invading default execution function source code, function can be improved The accuracy rate and efficiency of time-consuming statistics.
The embodiment of the present invention in a first aspect, providing a kind of function time-consuming statistical method, comprising:
When executing default execution function, jumps to and execute presetting message forwarding function;
It forwards function call to obtain function at the first time by the presetting message, obtains at the first time;
Obtained after function is finished in the first time, by the presetting message forward function call with it is described pre- If executing the corresponding target of function executes function, the target executes function and be used to carry out going back for the default execution function Original executes;
After target execution function is finished, passes through the presetting message and the second time of function call is forwarded to obtain Function obtained for the second time;
According to the first time and second time, it is time-consuming that statistics obtains the default function for executing function.
The second aspect of the embodiment of the present invention provides a kind of function time-consuming statistic device, comprising:
Execution module is jumped, executes presetting message forwarding function for jumping to when executing default execution function;
Module is obtained at the first time, for forwarding function call to obtain function at the first time by the presetting message, is obtained It takes at the first time;
Execution module is restored, for passing through the presetting message and turning after first time acquisition function is finished Function call target execution function corresponding with default the executions function is sent out, the target execution function be used to carry out institute The default reduction for executing function is stated to execute;
Second time-obtaining module, for passing through the presetting message and turning after target execution function is finished The second time of function call acquisition function is sent out, obtained for the second time;
Time-consuming statistical module, for according to the first time and second time, statistics to obtain the default execution The function of function is time-consuming.
The third aspect of the embodiment of the present invention, provides a kind of computer readable storage medium, described computer-readable to deposit Storage media is stored with computer-readable instruction, and such as aforementioned first aspect is realized when the computer-readable instruction is executed by processor The step of function time-consuming statistical method.
The fourth aspect of the embodiment of the present invention, provides a kind of terminal device, including memory, processor and is stored in In the memory and the computer-readable instruction that can run on the processor, the processor executes the computer can Following steps are realized when reading instruction:
When executing default execution function, jumps to and execute presetting message forwarding function;
It forwards function call to obtain function at the first time by the presetting message, obtains at the first time;
Obtained after function is finished in the first time, by the presetting message forward function call with it is described pre- If executing the corresponding target of function executes function, the target executes function and be used to carry out going back for the default execution function Original executes;
After target execution function is finished, passes through the presetting message and the second time of function call is forwarded to obtain Function obtained for the second time;
According to the first time and second time, it is time-consuming that statistics obtains the default function for executing function.
As can be seen from the above technical solutions, the embodiment of the present invention has the advantage that
In the embodiment of the present invention, when executing default execution function, it can jump to and execute presetting message forwarding function, with It forwards function to carry out the default reduction for executing function by presetting message to execute, and is reduced execution in the default function that executes Before, presetting message forwarding function call can be first passed through and obtain function at the first time to carry out the acquisition of first time, that is, obtained pre- At the beginning of if execution function is reduced execution;Then, function call and default execution function can be forwarded by presetting message Corresponding target executes function to carry out the default reduction for executing function and execute;After objective function is finished, then it can lead to Presetting message forwarding the second time of function call acquisition function is crossed to carry out the acquisition of the second time, i.e., the default function that executes restores The time terminated is executed, so as to time-consuming according to the default function for executing function is obtained with the second time at the first time.The present invention In embodiment, the default function time-consuming for executing function be forwarded by presetting message the function call relevant time obtain function come What statistics obtained, it does not need bury in default execution function not needing to invade the default source code for executing function a little, so that The statistics of function time-consuming can also be carried out in the case where no source code, and because not needing to invade the default source code for executing function, So that will not influence the execution performance of program in the statistic processes of function time-consuming, the statistics that function time-consuming can be improved is accurate Rate and statistical efficiency.
Detailed description of the invention
It to describe the technical solutions in the embodiments of the present invention more clearly, below will be to embodiment or description of the prior art Needed in attached drawing be briefly described, it should be apparent that, the accompanying drawings in the following description is only of the invention some Embodiment for those of ordinary skill in the art without any creative labor, can also be according to these Attached drawing obtains other attached drawings.
Fig. 1 is a kind of one embodiment flow chart of function time-consuming statistical method in the embodiment of the present invention;
Fig. 2 obtains default execution letter for function time-consuming statistical method a kind of in the embodiment of the present invention under an application scenarios Several flow diagrams;
Fig. 3 carries out default execution letter for function time-consuming statistical method a kind of in the embodiment of the present invention under an application scenarios The flow diagram that several reduction executes;
Fig. 4 carries out function time-consuming guarantor for function time-consuming statistical method a kind of in the embodiment of the present invention under an application scenarios The flow diagram deposited;
Fig. 5 is a kind of one embodiment structure chart of function time-consuming statistic device in the embodiment of the present invention;
Fig. 6 is a kind of schematic diagram for terminal device that one embodiment of the invention provides.
Specific embodiment
The embodiment of the invention provides a kind of function time-consuming statistical method, statistic device, computer readable storage medium and Terminal device improves function consumption for carrying out the statistics of function time-consuming in the case where not invading default execution function source code The accuracy rate and efficiency of Shi Tongji.
In order to make the invention's purpose, features and advantages of the invention more obvious and easy to understand, below in conjunction with the present invention Attached drawing in embodiment, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that disclosed below Embodiment be only a part of the embodiment of the present invention, and not all embodiment.Based on the embodiments of the present invention, this field Those of ordinary skill's all other embodiment obtained without making creative work, belongs to protection of the present invention Range.
Referring to Fig. 1, the embodiment of the invention provides a kind of function time-consuming statistical method, function time-consuming statistics side Method, comprising:
Step S101, it when executing default execution function, jumps to and executes presetting message forwarding function;
In software development, to guarantee software quality, generally requires the split software distributed and be tested for the property, with base The perfect of software is carried out in the performance test results, it is such as statistical analysis to the function time-consuming for respectively executing function in software, with Find out page Caton reason etc., wherein execute function and refer to all kinds of corresponding functions in code.It is needing to a certain specific items Mesh is tested for the property, and when counting the function time-consuming for respectively executing function in the technical routine, need to obtain the specific items first All execution functions of purpose, therefore, as shown in Fig. 2, before executing default execution function, can wrap in the embodiment of the present invention It includes:
Step S201, the item Path of technical routine is obtained;
Step S202, it according to the item Path and default class name acquisition methods, obtains all kinds of in the technical routine With all kinds of class names;
Step S203, preset function acquisition methods and described are utilized using all kinds of class names as the first parameter respectively One parameter obtains the execution function in all kinds of, and the execution function is determined as to the default execution function of the technical routine.
For step S201 to step S203, it is to be understood that in the embodiment of the present invention, need to count letter having determined After the time-consuming technical routine of number, the item Path of the technical routine can be obtained first, such as in the specific items destination code The item Path path of the technical routine is obtained by calling dladdr function during compilation run;It then, can be by institute It states item Path path to be passed to as parameter into default class name acquisition methods, here, the default class name acquisition methods can be with For objc_copyClassNamesForImage method, can be passed to using the item Path path as parameter to objc_ In copyClassNamesForImage method, so as to by calling and executing objc_copyClassNamesForImage To get all classes that the technical routine is included, wherein the class that the accessed technical routine is included includes each The class name of class;, then can be respectively using all kinds of class names as the first parameter after getting all kinds of class names, and utilize default letter Number acquisition methods and first parameter, obtain the execution function in all kinds of, such as can successively using all kinds of class names as First parameter is passed into class_copyMethodList method, after obtaining the execution of class_copyMethodList method What is returned respectively returns the result, wherein all functions returned the result in corresponding class, and acquired function then may be used To include function name, function pointer corresponding to type function and the function etc..Here, accessed function is the finger Accessed function, can be identified as described above by the execution function for determining to need to carry out in project function time-consuming statistics Default execution function.
For example, being passed to as the first parameter into class_copyMethodList method using the class name A of class A, obtain When what class_copyMethodList method was returned after executing returns the result as [a, b, c], that is, it can determine the function in class A For a, b and c, and function a, function b, function c can be determined as respectively default to execute function a, the default function b, default of executing Execute function c;Further, it, into class_copyMethodList method, is obtained using the class name B of class B as the first parameter Returned after being executed to class_copyMethodList method when returning the result as [d, e], that is, can determine the letter in class B Counting is d and e, similarly, function d, e can be determined as default execution function d, default execution function e respectively.It successively will be all kinds of Class name is passed to respectively as the first parameter into class_copyMethodList method, obtains the function in all classes.
Further, it as shown in Fig. 2, in the embodiment of the present invention, after determining each default execution function, and is holding Before the default execution function of row, can also include:
Step a, the default first function pointer for executing function is obtained, and the first function pointer is replaced with pre- If function pointer, wherein the preset function pointer executes the presetting message forwarding function for triggering;
Step b, creation target execution function corresponding with default the executions function, and by target execution function Second function pointer be set as it is corresponding it is default execute function first function pointer.
For above-mentioned steps a, it is to be understood that when each default execution function has been determined, can get each Function pointer IMP, i.e., above-mentioned first function pointer IMP, wherein function pointer IMP corresponding to the default execution function The address of code block is implemented for function, which is directed toward the method body for realizing function, that is, is directed toward the code block for realizing function. In the embodiment of the present invention, after getting each default the first IMP for executing function, the first IMP can be replaced with All default the first IMP for executing function are such as replaced with _ objc_msgForward, so that executing by preset function pointer When each default execution function, because method body corresponding to the default execution function can not be found, so that message forwarding mechanism is triggered, The default presetting message forwarding function executed in the class of function place is executed to jump to.
For above-mentioned steps b, it should be noted that come in the case where not invading each default execution function source code It realizes that each default function time-consuming for executing function counts, in the embodiment of the present invention, before executing each default execution function, may be used also Creation target execution function corresponding with each default executions function, and the second function of the target created execution function is referred to Needle IMP is set as the corresponding default first function pointer IMP for executing function, can such as correspond to for default execution function FunA creation Target execute function PA_FunA, while setting the IMP of PA_FunA to the IMP of FunA, i.e., assign the method body of FunA PA_FunA, so that the function of FunA can be realized by the execution of PA_FunA, that is to say, that when PA_FunA is performed Function time-consuming when indicating that FunA is performed, thus can be executed by statistics PA_FunA is time-consuming come the function for obtaining FunA, So that not needing the source code of invasion FunA in entire statistic processes, not needing to be inserted into any system in the source code of FunA Code etc. is counted, to can avoid the execution of other statistics codes to influence the execution performance of FunA, with the system of influence function time-consuming Efficiency and accuracy rate are counted, the purpose of efficiently accurate geo-statistic function time-consuming is realized.
Step S102, it forwards function call to obtain function at the first time by the presetting message, obtains at the first time;
It is understood that because it is all it is default execute functions the first IMP be replaced in order to preset function pointer _ Objc_msgForward, thus during performance test, in execution to each default execution function, will all touch automatically Message forwarding mechanism is sent out, to jump to each default presetting message forwarding function executed in the class of function place " forwardInvocation: ", so as to carry out each default reduction for executing function by " forwardInvocation: " It executes, and in reduction implementation procedure, each default function time-consuming for executing function is counted.Further, passing through Before " forwardInvocation: " carries out each default reduction execution for executing function, it can pass through first " forwardInvocation: ", which is called, obtains function at the first time come at the beginning of obtaining each default executions function reduction execution Between, i.e., first time described above can such as call CACurrentMediaTime by " forwardInvocation: " () function obtains current time stamp, to obtain at the beginning of each default execution function reduction executes.
Step S103, after first time acquisition function is finished, pass through the presetting message and forward function tune Function is executed with target corresponding with the default execution function, and the target executes function and be used to carry out described default hold The reduction of line function executes;
It is understood that after first time acquisition function is finished, i.e., in CACurrentMediaTime After () function gets current time stamp, then function " forwardInvocation: " Lai Jinhang can be forwarded by presetting message The corresponding default reduction for executing function executes, and specifically, can forward function " forwardInvocation: " by presetting message The target executed that restores that be used to carry out the default execution function is called to execute function to realize going back for the default execution function Original executes.
Optionally, as shown in figure 3, described forward function call and the default execution function phase by the presetting message Corresponding target executes function, may include:
Step S301, jump to execute presetting message forwarding function when, record is performed described default before jumping Execute function and the second corresponding parameter;
Step S302, determination target corresponding with the default execution function executes function, and by second parameter The first object is passed to execute in function;
Step S303, the target after forwarding function call to be passed to second parameter by the presetting message executes letter Number.
For above-mentioned steps S301 to step S303, it is to be understood that when executing the default execution function, because of institute Default the first IMP executed in function is stated to be replaced for _ objc_msgForward, it at this time will the forwarding of automatic trigger message Mechanism, and jump to the default presetting message forwarding function for executing function place class automatically, i.e., it jumps to automatically described pre- If " forwardInvocation: " of class where executing function, wherein the class where jumping to the default execution function When " forwardInvocation: ", the default execution of message forwarding mechanism will will be triggered by being somebody's turn to do " forwardInvocation: " Function is recorded as the default execution function, and records the second parameter corresponding to the default execution function simultaneously, such as assembles One NSInvocation object corresponding with the default execution function then contains institute in the NSInvocation object State the second parameter corresponding to default execution function.
Further, when " forwardInvocation: " has determined the default execution function of triggering message forwarding mechanism After the default execution function, being somebody's turn to do " forwardInvocation: " can execute in function from the multiple targets being pre-created Determine that target corresponding with the default execution function executes function, and anti-from the NSInvocation object assembled The second parameter corresponding to the default execution function is solved, then goes to call with the second parameter that anti-solution comes out and be determined Target execute function, thus realize it is described it is default execute function reduction execute, with realize it is described it is default execute function original This function.
Step S104, it is executed after function is finished in the target, function call the is forwarded by the presetting message Two times obtained function, obtained for the second time;
It is understood that being reduced in the default execution function after target execution function is finished After execution, further it can call for the second time obtained letter by presetting message forwarding function " forwardInvocation: " Number, to obtain the execution end time that the target executes function, i.e., the second time described above, wherein second time Obtaining function can be identical as first time acquisition function, can such as be called again by " forwardInvocation: " CACurrentMediaTime () function obtains current time stamp, at the end of obtaining the execution that the target executes function Between.Certainly, the second time acquisition function can also be not identical as first time acquisition function, can be that other can Obtain any function of current time.
Step S105, according to the first time and second time, statistics obtains the default letter for executing function Number is time-consuming.
In the embodiment of the present invention, is obtaining the execution time started of the target execution function and executing the end time, i.e., After first time and the second time described above, the time difference of second time and the first time can be calculated, and institute The obtained time difference is that the function that executes when function executes of the target is time-consuming, because the target execute function be used into The corresponding default reduction for executing function of row executes, therefore the obtained time difference is that the target executes corresponding to function The default function for executing function is time-consuming, so that the function that statistics obtains each default execution function is time-consuming.
Further, in the embodiment of the present invention, according to the first time and second time, statistics obtains described After the default function for executing function is time-consuming, can also include:
Step c, the default function name for executing function and the default class name for executing function place class are obtained, and will Where the default function time-consuming for executing function and the default function name for executing function and the default execution function The class name of class is associated preservation.
For above-mentioned steps c, it is to be understood that after statistics obtains each default function time-consuming for executing function, need Each function time-consuming is saved, to facilitate developer or tester to be asked according to function time consuming analysis respective items purpose performance Topic.In the embodiment of the present invention, after obtaining function time-consuming, default execution letter corresponding to function time-consuming can be further obtained Several function names and the default class name for executing function place class, and the function time-consuming is preset to the function for executing function with this Name and this it is default execute function where class name of class be associated preservations, thus aspect developer or tester accurately, It is time-consuming to be quickly found each default function for executing function, improves performance evaluation efficiency.
It should be noted that some developers or survey can also be filtered according to specific needs in function time-consuming statistics Examination personnel think invalid data, too big to avoid data volume, influence to statistically analyze speed, further increase performance evaluation effect Rate.
Specifically, as shown in figure 4, function time-consuming statistical method provided in an embodiment of the present invention under an application scenarios into When line function time-consuming saves, may include:
Step S401, according to the first time and second time, statistics obtains the default letter for executing function Number is time-consuming;
Step S402, the pre-set preset duration threshold value of user is obtained;
Step S403, judge whether the default function time-consuming for executing function is greater than the preset duration threshold value;
If step S404, it is described it is default execute function function time-consuming be greater than the preset duration threshold value, obtain described in The default function name for executing function and the default class name for executing function place class;
Step S405, by the default function time-consuming for executing function and the default function name for executing function and institute It states the default class name for executing function place class and is associated preservation.
It is understood that developer or tester are according to specific needs when carrying out the preservation of function time-consuming Corresponding duration threshold value is preset, as the preset duration threshold value, to filter its some undesired statistical result, is reduced The data volume of statistical analysis facilitates developer or tester to be quickly found out the reason of influencing software performance.
Above-mentioned steps S401 is similar to above-mentioned steps S105, and principle is essentially identical, and for simplicity, details are not described herein.
For above-mentioned steps S402, it is to be understood that developer or tester, can when carrying out performance survey analysis Preset duration threshold value is preset according to specific needs, such as 100 milliseconds can be set by the preset duration threshold value, to find out letter The time-consuming default execution function more than 100 milliseconds of number.
For above-mentioned steps S403 to step S405, it is to be understood that according to first time and the second time, statistics After obtaining a certain default function time-consuming for executing function, it can first judge whether the function time-consuming is greater than the preset duration threshold value, If judged whether the function time-consuming is greater than 100 milliseconds, if being said if the function time-consuming is greater than 100 milliseconds of preset duration threshold value The bright default function that executes is function needed for developer or tester's progress performance evaluation, at this point, can further obtain The class name of class where function name of the default execution function and the default execution function, and the function time-consuming can be preset with this and be held The function name of line function and the default class name for executing function place class are associated preservation, to facilitate developer or survey Examination personnel carry out performance evaluation to the corresponding default function that executes according to the function time-consuming saved.
In the embodiment of the present invention, when executing default execution function, it can jump to and execute presetting message forwarding function, with It forwards function to carry out the default reduction for executing function by presetting message to execute, and is reduced execution in the default function that executes Before, presetting message forwarding function call can be first passed through and obtain function at the first time to carry out the acquisition of first time, that is, obtained pre- At the beginning of if execution function is reduced execution;Then, function call and default execution function can be forwarded by presetting message Corresponding target executes function to carry out the default reduction for executing function and execute;After objective function is finished, then it can lead to Presetting message forwarding the second time of function call acquisition function is crossed to carry out the acquisition of the second time, i.e., the default function that executes restores The time terminated is executed, so as to time-consuming according to the default function for executing function is obtained with the second time at the first time.The present invention In embodiment, the default function time-consuming for executing function be forwarded by presetting message the function call relevant time obtain function come What statistics obtained, it does not need bury in default execution function not needing to invade the default source code for executing function a little, so that The statistics of function time-consuming can also be carried out in the case where no source code, and because not needing to invade the default source code for executing function, So that will not influence the execution performance of program in the statistic processes of function time-consuming, the statistics that function time-consuming can be improved is accurate Rate and statistical efficiency.
It should be understood that the size of the serial number of each step is not meant that the order of the execution order in above-described embodiment, each process Execution sequence should be determined by its function and internal logic, the implementation process without coping with the embodiment of the present invention constitutes any limit It is fixed.
A kind of function time-consuming statistical method is essentially described above, a kind of function time-consuming statistic device will be carried out below detailed Thin description.
Fig. 5 shows a kind of one embodiment structure chart of function time-consuming statistic device in the embodiment of the present invention.Such as Fig. 5 institute Show, the function time-consuming statistic device, comprising:
Execution module 501 is jumped, executes presetting message forwarding function for jumping to when executing default execution function;
Module 502 is obtained at the first time, for forwarding function call to obtain function at the first time by the presetting message, It obtains at the first time;
Execution module 503 is restored, for passing through the presetting message after first time acquisition function is finished Function call target execution function corresponding with default the executions function is forwarded, the target execution function be used to carry out The default reduction for executing function executes;
Second time-obtaining module 504, for passing through the presetting message after target execution function is finished It forwards the second time of function call to obtain function, obtained for the second time;
Time-consuming statistical module 505, for according to the first time and second time, statistics to obtain described preset and holds The function of line function is time-consuming.
Further, the function time-consuming statistic device may include:
Path obtains module, for obtaining the item Path of technical routine;
Class name obtains module, for obtaining the technical routine according to the item Path and default class name acquisition methods In all kinds of and all kinds of class names;
Function obtains module, for respectively using all kinds of class names as the first parameter, using preset function acquisition methods with And first parameter, the execution function in all kinds of is obtained, and the execution function is determined as the default of the technical routine Execute function.
Preferably, the function time-consuming statistic device can also include:
Pointer replacement module, for obtaining the default first function pointer for executing function, and by the first function Pointer replaces with preset function pointer, wherein the preset function pointer executes the presetting message forwarding function for triggering;
Target executes function creation module, for creating target execution function corresponding with the default execution function, And the corresponding default first function pointer for executing function is set by the second function pointer that the target executes function.
Optionally, the reduction execution module 503 may include:
Function recording unit, for when jumping to execution presetting message forwarding function, record to jump performed before The default execution function and the second corresponding parameter;
Target executes function determination unit, for determining target execution function corresponding with the default execution function, And second parameter is passed to the target and is executed in function;
Execution unit is restored, for the target after forwarding function call to be passed to second parameter by the presetting message Execute function.
Further, the function time-consuming statistic device can also include:
Function time-consuming preserving module, for obtaining the default function name for executing function and the default execution function institute In the class name of class, and by the default function time-consuming for executing function and the default execution function name of function and described pre- If the class name of class is associated preservation where executing function.
Preferably, the function time-consuming preserving module, comprising:
Duration threshold value acquiring unit, for obtaining the pre-set preset duration threshold value of user;
Function time-consuming judging unit, when for judging whether the default function time-consuming for executing function is greater than described default Long threshold value;
Function name class name acquiring unit, if being greater than the preset duration threshold for the default function time-consuming for executing function Value then obtains the default function name for executing function and the default class name for executing function place class;
Function time-consuming storage unit, for by the default function time-consuming for executing function and described default executing function Function name and the default class name for executing function place class are associated preservation.
Fig. 6 is a kind of schematic diagram for terminal device that one embodiment of the invention provides.As shown in fig. 6, the end of the embodiment End equipment 6 includes: processor 60, memory 61 and is stored in the memory 61 and can run on the processor 60 Computer-readable instruction 62, such as function time-consuming statistics program.The processor 60 executes the computer-readable instruction 62 Step in the above-mentioned each function time-consuming statistical method embodiment of Shi Shixian, such as step S101 shown in FIG. 1 to step S105. Alternatively, the processor 60 realizes each module/unit in above-mentioned each Installation practice when executing the computer-readable instruction 62 Function, such as module shown in fig. 5 501 is to the function of module 505.
Illustratively, the computer-readable instruction 62 can be divided into one or more module/units, one Or multiple module/units are stored in the memory 61, and are executed by the processor 60, to complete the present invention.Institute Stating one or more module/units can be the series of computation machine readable instruction section that can complete specific function, the instruction segment For describing implementation procedure of the computer-readable instruction 62 in the terminal device 6.
The terminal device 6 can be the calculating such as desktop PC, notebook, palm PC and cloud server and set It is standby.The terminal device may include, but be not limited only to, processor 60, memory 61.It will be understood by those skilled in the art that Fig. 6 The only example of terminal device 6 does not constitute the restriction to terminal device 6, may include than illustrating more or fewer portions Part perhaps combines certain components or different components, such as the terminal device can also include input-output equipment, net Network access device, bus etc..
The processor 60 can be central processing unit (Central Processing Unit, CPU), can also be Other general processors, digital signal processor (Digital Signal Processor, DSP), specific integrated circuit (Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field- Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic, Discrete hardware components etc..General processor can be microprocessor or the processor is also possible to any conventional processor Deng.
The memory 61 can be the internal storage unit of the terminal device 6, for example, terminal device 6 hard disk or Memory.The memory 61 is also possible to the External memory equipment of the terminal device 6, such as is equipped on the terminal device 6 Plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, Flash card (Flash Card) etc..Further, the memory 61 can also both include the storage inside of the terminal device 6 Unit also includes External memory equipment.The memory 61 is for storing the computer-readable instruction and the terminal device Other required programs and data.The memory 61 can be also used for temporarily storing the number that has exported or will export According to.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unit It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list Member both can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated unit is realized in the form of SFU software functional unit and sells or use as independent product When, it can store in a computer readable storage medium.Based on this understanding, technical solution of the present invention is substantially The all or part of the part that contributes to existing technology or the technical solution can be in the form of software products in other words It embodies, which is stored in a storage medium, including some instructions are used so that a computer Equipment (can be personal computer, server or the network equipment etc.) executes the complete of each embodiment the method for the present invention Portion or part steps.And storage medium above-mentioned includes: USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic or disk etc. are various can store journey The medium of sequence code.
The above, the above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although referring to before Stating embodiment, invention is explained in detail, those skilled in the art should understand that: it still can be to preceding Technical solution documented by each embodiment is stated to modify or equivalent replacement of some of the technical features;And these It modifies or replaces, the spirit and scope for technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution.

Claims (10)

1. a kind of function time-consuming statistical method characterized by comprising
When executing default execution function, jumps to and execute presetting message forwarding function;
It forwards function call to obtain function at the first time by the presetting message, obtains at the first time;
After first time acquisition function is finished, function call and described preset is forwarded to hold by the presetting message The corresponding target of line function executes function, and the target execution function be used to carry out the default reduction for executing function and hold Row;
After target execution function is finished, passes through the presetting message and the second time of function call is forwarded to obtain letter Number obtained for the second time;
According to the first time and second time, it is time-consuming that statistics obtains the default function for executing function.
2. function time-consuming statistical method according to claim 1, which is characterized in that before executing default execution function, Include:
Obtain the item Path of technical routine;
According to the item Path and default class name acquisition methods, all kinds of and all kinds of class names in the technical routine are obtained;
Respectively using all kinds of class names as the first parameter, using preset function acquisition methods and first parameter, obtain each Execution function in class, and the execution function is determined as the default execution function of the technical routine.
3. function time-consuming statistical method according to claim 1, which is characterized in that before executing default execution function, Include:
The default first function pointer for executing function is obtained, and the first function pointer is replaced with into preset function and is referred to Needle, wherein the preset function pointer executes the presetting message forwarding function for triggering;
Creation target execution function corresponding with default the executions function, and by the second function of target execution function Pointer is set as the corresponding default first function pointer for executing function.
4. function time-consuming statistical method according to claim 3, which is characterized in that described to be forwarded by the presetting message Function call target corresponding with the default execution function executes function, comprising:
When jumping to execution presetting message forwarding function, the record default execution function and institute performed before jumping Corresponding second parameter;
Determining target execution function corresponding with the default execution function, and second parameter is passed to the target and is held In line function;
Target after forwarding function call to be passed to second parameter by the presetting message executes function.
5. function time-consuming statistical method according to any one of claim 1 to 4, which is characterized in that according to described One time and second time, statistics obtain after the default function time-consuming for executing function, comprising:
The default function name for executing function and the default class name for executing function place class are obtained, and described preset is held The function time-consuming of line function and it is described it is default execute function function name and it is described it is default execute function where class class name into Row association saves.
6. function time-consuming statistical method according to claim 5, which is characterized in that described to obtain the default execution function Function name and it is described it is default execute function where class class name, and by it is described it is default execute function function time-consuming with it is described pre- If the function name and the default class name for executing function place class that execute function are associated preservation, comprising:
Obtain the pre-set preset duration threshold value of user;
Judge whether the default function time-consuming for executing function is greater than the preset duration threshold value;
If the default function time-consuming for executing function is greater than the preset duration threshold value, the default execution function is obtained Function name and the default class name for executing function place class;
By the default function time-consuming for executing function and the default function name for executing function and the default execution letter The class name of class is associated preservation where number.
7. a kind of function time-consuming statistic device characterized by comprising
Execution module is jumped, executes presetting message forwarding function for jumping to when executing default execution function;
Module is obtained at the first time, for forwarding function call to obtain function, acquisition the at the first time by the presetting message One time;
Execution module is restored, for passing through the presetting message and forwarding letter after first time acquisition function is finished Number calls target execution function corresponding with default the executions function, and the target execution function be used to carry out described pre- If the reduction for executing function executes;
Second time-obtaining module, for passing through the presetting message and forwarding letter after target execution function is finished Number called for the second time obtained function, obtained for the second time;
Time-consuming statistical module, for according to the first time and second time, statistics to obtain the default execution function Function it is time-consuming.
8. a kind of computer readable storage medium, the computer-readable recording medium storage has computer-readable instruction, special Sign is, realizes that function is time-consuming as described in any one of claims 1 to 6 when the computer-readable instruction is executed by processor The step of statistical method.
9. a kind of terminal device, including memory, processor and storage are in the memory and can be on the processor The computer-readable instruction of operation, which is characterized in that the processor realizes following step when executing the computer-readable instruction It is rapid:
When executing default execution function, jumps to and execute presetting message forwarding function;
It forwards function call to obtain function at the first time by the presetting message, obtains at the first time;
After first time acquisition function is finished, function call and described preset is forwarded to hold by the presetting message The corresponding target of line function executes function, and the target execution function be used to carry out the default reduction for executing function and hold Row;
After target execution function is finished, passes through the presetting message and the second time of function call is forwarded to obtain letter Number obtained for the second time;
According to the first time and second time, it is time-consuming that statistics obtains the default function for executing function.
10. terminal device according to claim 9, which is characterized in that before executing default execution function, comprising:
Obtain the item Path of technical routine;
According to the item Path and default class name acquisition methods, all kinds of and all kinds of class names in the technical routine are obtained;
Respectively using all kinds of class names as the first parameter, using preset function acquisition methods and first parameter, obtain each Execution function in class, and the execution function is determined as the default execution function of the technical routine.
CN201811423786.2A 2018-11-27 2018-11-27 Function time consumption statistical method and device, storage medium and terminal equipment Active CN109634822B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811423786.2A CN109634822B (en) 2018-11-27 2018-11-27 Function time consumption statistical method and device, storage medium and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811423786.2A CN109634822B (en) 2018-11-27 2018-11-27 Function time consumption statistical method and device, storage medium and terminal equipment

Publications (2)

Publication Number Publication Date
CN109634822A true CN109634822A (en) 2019-04-16
CN109634822B CN109634822B (en) 2023-04-14

Family

ID=66069234

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811423786.2A Active CN109634822B (en) 2018-11-27 2018-11-27 Function time consumption statistical method and device, storage medium and terminal equipment

Country Status (1)

Country Link
CN (1) CN109634822B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110580219A (en) * 2019-07-16 2019-12-17 许昌许继软件技术有限公司 Embedded device function performance online test method and device and storage medium
CN110908869A (en) * 2019-11-27 2020-03-24 北京博睿宏远数据科技股份有限公司 Application program data monitoring method, device, equipment and storage medium
CN112000587A (en) * 2020-10-29 2020-11-27 四川新网银行股份有限公司 Test man-hour automatic statistical method based on associated object operation statistics

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070150236A1 (en) * 2005-12-28 2007-06-28 Kanji Warizaya Life prediction and monitoring apparatus, life prediction and monitoring method, and life prediction and monitoring program
CN103927193A (en) * 2013-01-15 2014-07-16 中兴通讯股份有限公司 Loading method and server side virtual machine used in migration running of Java application program functions
CN105701004A (en) * 2014-11-28 2016-06-22 深圳市腾讯计算机系统有限公司 Application test method and apparatus
CN106055462A (en) * 2016-05-20 2016-10-26 腾讯科技(深圳)有限公司 Method and device for duration acquisition
CN108021357A (en) * 2017-11-20 2018-05-11 北京奇虎科技有限公司 The optimization method and device of routine call
CN108197004A (en) * 2018-01-23 2018-06-22 武汉斗鱼网络科技有限公司 The method of IOS applications takes, loads monitoring method and system that view takes

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070150236A1 (en) * 2005-12-28 2007-06-28 Kanji Warizaya Life prediction and monitoring apparatus, life prediction and monitoring method, and life prediction and monitoring program
CN103927193A (en) * 2013-01-15 2014-07-16 中兴通讯股份有限公司 Loading method and server side virtual machine used in migration running of Java application program functions
CN105701004A (en) * 2014-11-28 2016-06-22 深圳市腾讯计算机系统有限公司 Application test method and apparatus
CN106055462A (en) * 2016-05-20 2016-10-26 腾讯科技(深圳)有限公司 Method and device for duration acquisition
CN108021357A (en) * 2017-11-20 2018-05-11 北京奇虎科技有限公司 The optimization method and device of routine call
CN108197004A (en) * 2018-01-23 2018-06-22 武汉斗鱼网络科技有限公司 The method of IOS applications takes, loads monitoring method and system that view takes

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110580219A (en) * 2019-07-16 2019-12-17 许昌许继软件技术有限公司 Embedded device function performance online test method and device and storage medium
CN110908869A (en) * 2019-11-27 2020-03-24 北京博睿宏远数据科技股份有限公司 Application program data monitoring method, device, equipment and storage medium
CN112000587A (en) * 2020-10-29 2020-11-27 四川新网银行股份有限公司 Test man-hour automatic statistical method based on associated object operation statistics

Also Published As

Publication number Publication date
CN109634822B (en) 2023-04-14

Similar Documents

Publication Publication Date Title
CN106933733B (en) Method and device for determining memory leak position
US8612944B2 (en) Code evaluation for in-order processing
CN109634822A (en) A kind of function time-consuming statistical method, device, storage medium and terminal device
US9740541B2 (en) Information processing apparatus and method of collecting performance analysis data
CN107315961A (en) Bug detection method and device, computing device, storage medium
KR101979329B1 (en) Method and apparatus for tracking security vulnerable input data of executable binaries thereof
US9639451B2 (en) Debugger system, method and computer program product for utilizing hardware breakpoints for debugging instructions
CN117195568B (en) Simulation engine performance analysis method and device based on discrete event
CN113127314A (en) Method and device for detecting program performance bottleneck and computer equipment
CN113778890B (en) Code testing method and device, electronic equipment and storage medium
US9971670B2 (en) Detecting uninitialized memory references
CN109582574A (en) A kind of code coverage statistical method, device, storage medium and terminal device
CN116820567A (en) Method, system, electronic device and storage medium for determining instruction consumption information
CN111352838A (en) Package file generation method, package file generation device and electronic equipment
GB2551574A (en) An apparatus and method for generating and processing a trace stream indicative of instruction execution by processing circuitry
CN114153712A (en) Exception handling method, device, equipment and storage medium
JP5024252B2 (en) Trace information acquisition device, trace information acquisition program, and trace information acquisition method
CN115904857A (en) Bottleneck node screening method and device and computer equipment
CN110781079B (en) Data processing flow debugging method and device and electronic equipment
US20160266995A1 (en) Detecting uninitialized memory references
CN113806231A (en) Code coverage rate analysis method, device, equipment and medium
CN112363915A (en) Method and device for page performance test, terminal equipment and storage medium
CN111381836A (en) Switching method and device of application program deployment environment
US20080307395A1 (en) Providing Registration of a Communication
CN109885402B (en) Method for testing function output data overflow, terminal 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
GR01 Patent grant
GR01 Patent grant