CN103577304A - Method and device for dynamically analyzing code - Google Patents

Method and device for dynamically analyzing code Download PDF

Info

Publication number
CN103577304A
CN103577304A CN201210285223.8A CN201210285223A CN103577304A CN 103577304 A CN103577304 A CN 103577304A CN 201210285223 A CN201210285223 A CN 201210285223A CN 103577304 A CN103577304 A CN 103577304A
Authority
CN
China
Prior art keywords
calling
code
progress
calls
crucial moment
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
CN201210285223.8A
Other languages
Chinese (zh)
Other versions
CN103577304B (en
Inventor
栾涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201210285223.8A priority Critical patent/CN103577304B/en
Publication of CN103577304A publication Critical patent/CN103577304A/en
Application granted granted Critical
Publication of CN103577304B publication Critical patent/CN103577304B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention provides a method and a device for dynamically analyzing a code. The method for dynamically analyzing the code comprises the following steps: A, inserting a monitor at the module call position of the code, wherein the monitor is used for outputting log information relevant to a call when the call of the module call position occurs; B, running the code after the monitor is inserted so as to output a log file which consists of at least one piece of log information; C, determining the analysis result of the code according to the log file, wherein the analysis result of the code is used for showing a module call relation when the code runs. By adopting the mode, the method and the device for dynamically analyzing the code provided by the invention can be used for effectively monitoring the module call condition when the code runs, and therefore, the code quality is improved, and the difficulty of code maintenance is lowered.

Description

A kind of method of code performance analysis and device
[technical field]
The present invention relates to the technology of code analysis, particularly a kind of method of code performance analysis and device.
[background technology]
Development along with software engineering, software product is when offering convenience for people, also become and become increasingly complex, especially the various softwares of enterprise-level, its size of code is huge, this has increased developer and has grasped the integrally-built difficulty of software, and the reason that also makes the defect in software produce is not easy to be found, thereby has caused the difficulty in software maintenance.In order better software to be monitored and to be safeguarded, prior art has proposed software code to carry out the method for static analysis.By software code is carried out to static analysis, though can understand the relation of interdependence between the module of code, situation when this Static Analysis Method cannot be to code dynamic operation is monitored.Be appreciated that, when the initial input difference of software systems, software systems are probably moved different branches, and move different branches, can cause different results, under the program branches having, the operation of code is perhaps normal, and under the program branches having, the operation of code likely just there will be extremely.This mistake causing during due to code dynamic operation can not be found by code static analysis, that is to say, and existing code Static Analysis Technology, the mistake occurring in the time of cannot effectively grasping code dynamic operation, has increased the difficulty of software supervision and maintenance.
[summary of the invention]
Technical matters to be solved by this invention is to provide a kind of method and device of code performance analysis, to solve the software supervision that exists in prior art and problem difficult in maintenance.
The present invention is a kind of method that technical scheme that technical solution problem adopts is to provide code performance analysis, comprise: A. inserts audiomonitor at the module place of calling of code, wherein said audiomonitor calls relevant log information for output when calling of this place occurs to this time; B. the code after audiomonitor is inserted in operation, to export the journal file consisting of one or more log information; C. according to described journal file, determine the analysis result of described code, the module call relation when analysis result of wherein said code is used for representing described code operation.
The preferred embodiment one of according to the present invention, described step C comprises: according to the homophony module of each log information recording in described journal file and by mode transfer piece, drafting is from homophony module to by the line of mode transfer piece, to obtain the module call graph of described code during whole service, and the analysis result using described module call graph as described code.
The preferred embodiment one of according to the present invention, described step C comprises: C1. is according to each log information in described journal file, draws described code and calls progress chart picture frame at each crucial moment of run duration; That C2. utilizes each crucial moment calls progress chart picture frame, generate dynamic image document, and the analysis result using described dynamic image document as described code, wherein said dynamic image document description described code in the module of a plurality of times of running, call progress.
The preferred embodiment one of according to the present invention, described step C1 comprises: C11. extracts zero hour of calling of recording in each log information and at least one crucial moment at run duration as described code constantly in the finish time; C12. for each crucial moment, determine calling of simultaneously carrying out this crucial moment, each that calculate in calling of simultaneously carrying out is invoked at the progress at this crucial moment, and the progress of calling according to each draw this crucial moment call progress chart picture frame.
The preferred embodiment one of according to the present invention, in described step C12, determine that the step of calling that crucial moment, T carried out simultaneously comprises: judge whether the closed interval forming zero hour of calling of recording in each log information and the finish time covers T, if so, corresponding the calling in closed interval that covers T extracted as one that at crucial moment, T carries out in calling simultaneously.
The preferred embodiment one of according to the present invention, in described step C12, calculating the step that each in calling of simultaneously carrying out be invoked at the progress of T at crucial moment comprises: according to the thread identification recording in each log information, any one in definite calling of simultaneously carrying out called all sons of X in same thread and called, all sons by X in same thread call according to the time sequencing of calling and arrange, and obtain the sub-calling sequence of X; Utilize the sub-calling sequence of X to calculate X in the progress of T at crucial moment, wherein: when the zero hour that first son of X calls, to be greater than crucial moment during T, to determine that X belongs to journey and calls, and go the progress that journey is called to adopt following formula to calculate:
Figure BDA00001997499300031
wherein go represents that progress, key_time that journey is called represent that T at crucial moment, x_stime represent the zero hour, the call of X 1_ stime represents first zero hour that son calls of X; When crucial moment, T was greater than the finish time that last height of X calls, determine that X belongs to return and calls, and the progress that return is called adopts following formula to calculate:
Figure BDA00001997499300032
wherein back represents the progress that return calls, the finish time, the call that x_etime represents X n_ etime represents the finish time that last height of X calls.
The preferred embodiment one of according to the present invention, described dynamic image document comprises: lantern slide document, animation document or video documents.
The preferred embodiment one of according to the present invention, in described steps A, at least inserts audiomonitor at the module place of calling with one of Types Below: service access type calls or event notice type calls.
The present invention also provides a kind of device of code performance analysis, comprising: plug-in unit, for the module place of calling at code, insert audiomonitor, and wherein said audiomonitor calls relevant log information for output when calling of this place occurs to this time; Output unit, for moving the code inserting after audiomonitor, to export the journal file consisting of one or more log information; Determining unit, for determine the analysis result of described code according to described journal file, the module call relation when analysis result of wherein said code is used for representing described code operation.
The preferred embodiment one of according to the present invention, described determining unit comprises: figure generation unit, be used for according to the homophony module of described each log information recording of journal file and by mode transfer piece, drafting is from homophony module to by the line of mode transfer piece, to obtain the module call graph of described code during whole service, and the analysis result using described module call graph as described code.
The preferred embodiment one of according to the present invention, described determining unit comprises: picture frame generation unit, for according to each log information of described journal file, draw described code and call progress chart picture frame at each crucial moment of run duration; Document generation unit, for what utilize each crucial moment, call progress chart picture frame, generate dynamic image document, and the analysis result using described dynamic image document as described code, wherein said dynamic image document description described code in the module of a plurality of times of running, call progress.
The preferred embodiment one of according to the present invention, described picture frame generation unit comprises: crucial moment determining unit, for extracting zero hour of calling that each log information records and at least one crucial moment at run duration as described code constantly in the finish time; Progress drawing unit, be used for for each crucial moment, determine calling of simultaneously carrying out this crucial moment, calculate that in calling of simultaneously carrying out, each is invoked at the progress at this crucial moment, and the progress of calling according to each draw this crucial moment call progress chart picture frame.
The preferred embodiment one of according to the present invention, described progress drawing unit determines that the mode of calling that crucial moment, T carried out simultaneously comprises: judge whether the closed interval forming zero hour of calling of recording in each log information and the finish time covers T, if so, corresponding the calling in closed interval that covers T extracted as one that at crucial moment, T carries out in calling simultaneously.
The preferred embodiment one of according to the present invention, described progress drawing unit calculates the mode that each in calling of simultaneously carrying out be invoked at the progress of T at crucial moment and comprises: according to the thread identification recording in each log information, any one in definite calling of simultaneously carrying out called all sons of X in same thread and called, all sons by X in same thread call according to the time sequencing of calling and arrange, and obtain the sub-calling sequence of X; Utilize the sub-calling sequence of X to calculate X in the progress of T at crucial moment, wherein: when the zero hour that first son of X calls, to be greater than crucial moment during T, to determine that X belongs to journey and calls, and go the progress that journey is called to adopt following formula to calculate:
Figure BDA00001997499300041
wherein go represents that progress, key_time that journey is called represent that T at crucial moment, x_stime represent the zero hour, the call of X 1_ stime represents first zero hour that son calls of X; When crucial moment, T was greater than the finish time that last height of X calls, determine that X belongs to return and calls, and the progress that return is called adopts following formula to calculate:
Figure BDA00001997499300042
wherein back represents the progress that return calls, the finish time, the call that x_etime represents X n_ etime represents the finish time that last height of X calls.
The preferred embodiment one of according to the present invention, described dynamic image document comprises: lantern slide document, animation document or video documents.
The preferred embodiment one of according to the present invention, described plug-in unit at least inserts audiomonitor at the module place of calling with one of Types Below: service access type calls or event notice type calls.
As can be seen from the above technical solutions, in the present invention, by the module place of calling at code, insert audiomonitor, can after code entire run, obtain calling relevant journal file to the module of code generation in service, by this journal file, the code analysis result of module call relation in the time of can obtaining reflecting code operation, the code analysis result obtaining by the present invention, module in the time of can effectively moving code is called situation and is monitored, contribute to person skilled to find in time the mass defect of code, thereby raising code quality, reduce the difficulty of code maintenance.
[accompanying drawing explanation]
Fig. 1 is the schematic flow sheet of the method for code performance analysis in the present invention;
Fig. 2 is a schematic diagram of the module call graph in the present invention;
Fig. 3 is the schematic diagram of the embodiment who calls progress chart picture frame in the present invention;
Fig. 4 is the schematic diagram of another embodiment that calls progress chart picture frame in the present invention;
Fig. 5 is the structural representation block diagram of the device of code performance analysis in the present invention;
Fig. 6 is the structural representation block diagram of an embodiment of determining unit in the present invention;
Fig. 7 is the structural representation block diagram of another embodiment of determining unit in the present invention;
Fig. 8 is the structural representation block diagram of the embodiment of picture frame generation unit in the present invention.
[embodiment]
In order to make the object, technical solutions and advantages of the present invention clearer, below in conjunction with the drawings and specific embodiments, describe the present invention.
Please refer to Fig. 1, Fig. 1 is the schematic flow sheet of the method for code performance analysis in the present invention.As shown in Figure 1, the method comprises:
Step S101: the module place of calling at code inserts audiomonitor, this audiomonitor calls relevant log information for output when calling of this place occurs to this time.
Step S102: the code after audiomonitor is inserted in operation, to export the journal file consisting of one or more log information.
Step S103: determine the analysis result of code according to journal file, module call relation when wherein the analysis result of code is used for representing code operation.
Below by specific embodiment, above-mentioned steps is described.
Embodiment mono-:
As those skilled in the art should understand that, module is abstract to function, and a module can be understood as the encapsulation of certain function, and module can be with different granularity division, for example from smaller granularity, understand, the function of having realized certain function is exactly a module.The function of a program is mutually to call realization by modules in code.In the present invention, the module recalls information occurring in dynamic operation in order to get code, in step S101, need to insert audiomonitor at the module place of calling of code, those skilled in the art should understand that, so-called audiomonitor is exactly the code of having realized snoop logic, and in the present invention, needing the event of monitoring is that module is called, when this event occurs, audiomonitor can be exported and call specifically relevant log information.In code, insert audiomonitor, can by various existing techniques in realizing, for example, by the detours technology of Microsoft, just can in code, insert at an easy rate audiomonitor, certainly the technological means by other also can realize and in code, insert audiomonitor, and this instructions does not repeat them here.
In step S102, the code after audiomonitor is inserted in operation, in this process, module occurs at every turn and call and will export one and call relevant log information to this time, therefore, after code end of run, can obtain a journal file consisting of log information.
In step S103, by journal file is processed, just can determine the analysis result of code.In the present embodiment, the analysis result of code is module call graph.For convenient, understand, below in conjunction with a kind of schematic construction of log information, step S103 is described, should be appreciated that, this does not form the restriction of the journal entry that log information in the present invention is contained.
In the present embodiment, article one, log information is expressed as (call sign, homophony module, by mode transfer piece), wherein call the call relation of sign for representing that this log information represents, and homophony module with by mode transfer piece, represented respectively promoter and the recipient that this time called.For example log information is expressed as (5, count, rank), and its implication is that label is 5 calls, and is the calling rank module of being initiated by count module.
According to above-mentioned log information, in the present embodiment, step S103 comprises particularly: according to the homophony module of each log information recording in journal file and by mode transfer piece, draw from homophony module to by the line of mode transfer piece, obtain the module call graph of code during whole service.Please refer to Fig. 2, Fig. 2 is a schematic diagram of the module call graph in the present invention.
As can be seen from Figure 2, at current code in service, there is modules A to the calling of module D, B, C, wherein in modules A, in the calling of module B, also there is calling from module B to module E, F.In Fig. 2, the line direction of arrow has represented that homophony is to the relation of being adjusted, but should be appreciated that, this is a kind of signal, and in fact homophony and the relation adjusted also can be distinguished as word, color etc. by other modes, should be using this as limitation of the present invention.
Code is carried out to static analysis, can not reflect that code is at the module call relation of the actual generation of run duration, and the present invention carries out the method for performance analysis to code, can reflect well the call relation that code occurs at run duration.As those skilled in the art should understand that, in the static code of program, may there are a plurality of logic branches, in the middle of the actual execution of code, according to different initial input values, the module occurring is called and is likely different, in the program code that example figure as shown in Figure 2 represents, may also there is the calling logic of modules A to module G, but in this actual motion of code, but there is not such calling, visible, by the present invention, code is carried out the method for performance analysis, can be according to different initial input values, obtain likely different, the module call relation relevant to this initial input value, this more contributes to related personnel to monitor code, when there is defect in code, related personnel more easily finds, therefore method of the present invention contributes to improve code quality.
Embodiment bis-:
In the present embodiment, the embodiment of step S101 and step S102 and embodiment mono-are basic identical, but the code analysis result obtaining in step S103, is a dynamic image document, this dynamic image document description code in the module of a plurality of times of running, call progress.
Particularly, step S103 comprises:
Step S1031: according to each log information in journal file, draw code and call progress chart picture frame at each crucial moment of run duration.
Step S1032: that utilizes each crucial moment calls progress chart picture frame, generates dynamic image document.
For convenient, understand equally, below in conjunction with the schematic construction of another kind of log information, step S1031 and S1032 are described.Same, this signal does not form the restriction of the journal entry that log information in the present invention is contained.
In the present embodiment, article one, log information be expressed as (call sign, call place thread identification, homophony module, by mode transfer piece, call the zero hour, the finish time of calling), wherein call place thread identification for representing to carry out the thread code name call, call the zero hour and call and represent respectively that start-stop that this time call generation constantly the finish time.For example log information is expressed as (5, TRD3, count, rank, 3:12:34,3:12:45), its implication is that label is 5 calls, during generation, place thread number is TRD3, to be initiated, to the calling of rank module, to be respectively the zero hour of calling and the finish time 3:12:34 and 3:12:45 by count module.
In conjunction with the schematic construction of above-mentioned log information, particularly, step S1031 comprises:
Step S1031_1: extract zero hour of calling of recording in each log information and at least one crucial moment at run duration as code constantly in the finish time.
Step S1031_2: for each crucial moment, determine calling of simultaneously carrying out this crucial moment, each that calculate in calling of simultaneously carrying out is invoked at the progress at this crucial moment, and the progress of calling according to each draw this crucial moment call progress chart picture frame.
Every log information has all recorded two moment, it is respectively the zero hour and the finish time that this log information correspondence is called, in the present embodiment, the strategy of determining crucial moment is: at least one in the zero hour of every log information or the finish time extracted constantly, these that extract all can be used as the crucial moment in the present invention constantly, rely on these crucial moments, what can in step S1031_2, obtain each crucial moment calls progress chart picture frame.The definite strategy that is appreciated that crucial moment can also have other modes, and for example that in the middle of the zero hour and the finish time also extracts as crucial moment etc. constantly, and this instructions repeats no more.As preferably, in the present embodiment, the zero hour of calling of recording in each log information and the finish time are all extracted to the crucial moment at run duration as code.
In step S1031_2, calling of simultaneously carrying out crucial moment, by just judging the zero hour and the finish time of recording in each log information.Particularly, determine that the step of calling that crucial moment, T carried out simultaneously comprises:
Judge whether the closed interval forming zero hour of calling of recording in each log information and the finish time covers T, if so, corresponding the calling in closed interval that covers T extracted as one that T carries out at crucial moment in calling simultaneously.For example, to 3:12:20 at crucial moment, article one, are respectively the zero hour of log information and the finish time 3:12:10 and 3:12:50, due to [3:12:10,3:12:50] covered 3:12:20, so [3:12:10,3:12:50] corresponding to be called and is exactly and corresponding call call (T is exactly certain zero hour of calling or finish time because of crucial moment) of carrying out crucial moment simultaneously.Be appreciated that the ability that has concurrent execution due to computing machine, therefore a plurality of calling may operate in different threads, thereby may appear at synchronization, has a plurality of situations about calling of simultaneously carrying out.
In step S1031_2, obtain that crucial moment, T carried out simultaneously call after, also need to calculate each in calling of several that simultaneously carry out and be invoked at the progress of T at crucial moment.Particularly, can adopt following manner to realize:
According to the thread identification recording in each log information, any one in definite calling of simultaneously carrying out called all sons of X in same thread and called, all sons by X in same thread call according to the time sequencing of calling and arrange, and obtain the sub-calling sequence of X; Utilize the sub-calling sequence of X to calculate X in the progress of T at crucial moment, wherein:
When the zero hour that first son of X calls, be greater than crucial moment during T, determine that X belongs to journey and calls, and go the progress that journey is called to adopt following formula to calculate:
Figure BDA00001997499300091
wherein go represents that progress, key_time that journey is called represent that T at crucial moment, x_stime represent the zero hour, the call of X 1_ stime represents first zero hour that son calls of X; When crucial moment, T was greater than the finish time that last height of X calls, determine that X belongs to return and calls, and the progress that return is called adopts following formula to calculate:
Figure BDA00001997499300092
wherein back represents the progress that return calls, the finish time, the call that x_etime represents X n_ etime represents the finish time that last height of X calls.
Schematic construction in conjunction with the log information lifted above, can find out, the sign of a place thread has all been recorded in every corresponding calling of log information, log information is traveled through, can determine with X( carry out simultaneously call in any one call) belong to all of same thread and call, during these call, the son that calling of being caused by X is X calls.For example call X and be modules A to the calling of B, call (this calls as Y) to C by module B occurred again in this calls, think that Y is that the son of X calls.If in same thread, what X initiated successively according to time sequencing calls as Y, Z, W, calls the sub-calling sequence that Y, Z, W have just formed X.
Be appreciated that a module is to the calling of another module, should be from sending call signal, to receiving, call return signal and finish.For example modules A, to the calling of module B, is sent from modules A to module B call signal, and the return signal of calling that receives module B to modules A finishes.Wherein modules A is sent call signal to module B and is belonged to the journey of going of calling, module B returns to call signal to modules A and belongs to the return of calling, going journey to call with return calls and has reflected and call the stage of living in, particularly, adopt above-mentioned progress algorithm, can also obtain at T at crucial moment, go journey to call or progress that return is called.
If at T at crucial moment, that carries out calls X(modules A calling to module B simultaneously), Y(module C calling to module D), Z(module E calling to module F), and call X to go journey to call progress be that 0(represents that this calls just and starts), call Y to go journey to call progress be 0.5, call Z to go journey to call progress be 0.7, that can draw T at crucial moment calls progress chart picture frame as shown in Figure 3.In Fig. 3, arrow present position has represented the progress of calling, variation along with crucial moment, the position of calling arrow in progress chart picture frame that each obtaining is relevant to crucial moment also can change, should be appreciated that, this is a kind of schematic explanation, in the middle of reality, can also adopt the modes such as different colors, line weight to identify calling progress.As another kind of embodiment, the image shown in Fig. 3 can also with embodiment mono-in module call graph combine as calling progress chart picture frame, please refer to Fig. 4, Fig. 4 is the schematic diagram of another embodiment that calls progress chart picture frame in the present invention.In this execution of the code shown in Fig. 4, occurred altogether modules A to B, module C to D, module E to F, module F to G, module G calls to H's, but at T at crucial moment, ongoing calling only has modules A to call and module E calling to F to D's to the calling of B, module C.
Obtain each crucial moment call progress chart picture frame after, in step S1032, can utilize the progress chart picture frame that calls at each crucial moment to generate dynamic image document.In the present embodiment, dynamic image document can be video documents, for example adopt video smoothing technique, utilize the progress chart picture frame that calls at adjacent crucial moment to generate transition frames, then by crucial moment call progress chart picture frame and transition frames is connected in turn, just can obtain dynamic video documents.In addition, dynamic image document in the present embodiment can also be lantern slide document or animation document, as PPT document or Flash document, lower of this mode need to obtain crucial moment calls progress chart picture frame and is connected in turn and just can have accessed dynamic image document.
By embodiment bis-, the analysis result that the present invention obtains has not only reflected the module call relation of code when operation, but also reflected that code calls progress in the module of a plurality of times of running, the Dynamic Execution situation that can reflect better code, compare with static code analysis methods, the present invention has good code monitoring ability, can effectively help developer to improve code quality, or helps code maintenance personnel to safeguard code.
No matter be worth special instruction, be in embodiment mono-or embodiment bis-, in step S101, all can call or event notice pattern piece at least one the type place of calling insertion audiomonitor in calling at service access pattern piece.Wherein service access pattern piece calls, referring to a module is in order to realize the function of another module to calling of another module, calling function B in function A for example, exactly in order to realize the function of function B, and event notice pattern piece calls, refer to a module and send event notice, thereby the module of this event of triggering care is carried out respective handling, has also just realized notification module calling notified module.
Adopt method of the present invention, a kind of in can only calling the module of above-mentioned two types analyzes separately or the module of two types called all and analyzed.Call analyze in the situation that service access pattern piece being called with event notice pattern piece simultaneously, only need in log information, add the journal entry relevant to call type, just can in the analysis result finally obtaining, the module of above two types be called and be distinguished, to reflect better the operating situation of code.
Please refer to Fig. 5, Fig. 5 is the structural representation block diagram of the device of code performance analysis in the present invention.As shown in Figure 5, the device 200 of code performance analysis comprises: plug-in unit 201, output unit 202, determining unit 203.
Wherein plug-in unit 201, for the module place of calling at code, insert audiomonitor, and wherein audiomonitor calls relevant log information for output when calling of this place occurs to this time.In the present invention, plug-in unit 201 at least inserts audiomonitor at the module place of calling with one of Types Below: service access type calls or event notice type calls.
Output unit 202, for moving the code inserting after audiomonitor, to export the journal file consisting of one or more log information.
Determining unit 203, for determine the analysis result of code according to journal file, module call relation when wherein the analysis result of code is used for representing code operation.
Please refer to Fig. 6, Fig. 6 is the structural representation block diagram of an embodiment of determining unit in the present invention.In this embodiment, determining unit 203 comprises figure generation unit 2031, figure generation unit 2031 for according to the homophony module of each log information recording of journal file with by mode transfer piece, drafting is from homophony module to by the line of mode transfer piece, to obtain the module call graph of code during whole service, and the analysis result using module call graph as code.
Please refer to Fig. 7, Fig. 7 is the structural representation block diagram of another embodiment of determining unit in the present invention.In this embodiment, determining unit 203 comprises picture frame generation unit 203a and document generation unit 203b.Wherein picture frame generation unit 203a is for according to each log information of journal file, draws code and calls progress chart picture frame at each crucial moment of run duration.Document generation unit 203b calls progress chart picture frame for what utilize each crucial moment, generate dynamic image document, and the analysis result using dynamic image document as code, wherein dynamic image document description code in the module of a plurality of times of running, call progress.In the present invention, dynamic image document comprises: lantern slide document, animation document or video documents.
Please refer to Fig. 8, Fig. 8 is the structural representation block diagram of the embodiment of picture frame generation unit in the present invention.As shown in Figure 8, picture frame generation unit 203a comprises: crucial moment determining unit 203a_1 and progress drawing unit 203a_2.Wherein crucial moment, determining unit 203a_1 was for extracting zero hour of calling that each log information records and at least one crucial moment at run duration as code constantly in the finish time.Progress drawing unit 203a_2 was used for for each crucial moment, determine calling of simultaneously carrying out this crucial moment, each that calculate in calling of simultaneously carrying out is invoked at the progress at this crucial moment, and the progress of calling according to each draw this crucial moment call progress chart picture frame.
In the present embodiment, progress drawing unit 203a_2 determines that the mode of calling that crucial moment, T carried out simultaneously comprises:
Judge whether the closed interval forming zero hour of calling of recording in each log information and the finish time covers T, if so, corresponding the calling in closed interval that covers T extracted as one that T carries out at crucial moment in calling simultaneously.
In the present embodiment, progress drawing unit 203a_2 calculates the mode that each in calling of simultaneously carrying out be invoked at the progress of T at crucial moment and comprises:
According to the thread identification recording in each log information, any one in definite calling of simultaneously carrying out called all sons of X in same thread and called, all sons by X in same thread call according to the time sequencing of calling and arrange, and obtain the sub-calling sequence of X;
Utilize the sub-calling sequence of X to calculate X in the progress of T at crucial moment, wherein:
When the zero hour that first son of X calls, be greater than crucial moment during T, determine that X belongs to journey and calls, and go the progress that journey is called to adopt following formula to calculate: wherein go represents that progress, key_time that journey is called represent that T at crucial moment, x_stime represent the zero hour, the call of X 1_ stime represents first zero hour that son calls of X; When crucial moment, T was greater than the finish time that last height of X calls, determine that X belongs to return and calls, and the progress that return is called adopts following formula to calculate:
Figure BDA00001997499300132
wherein back represents the progress that return calls, the finish time, the call that x_etime represents X n_ etime represents the finish time that last height of X calls.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of making, be equal to replacement, improvement etc., within all should being included in the scope of protection of the invention.

Claims (16)

1. a method for code performance analysis, comprising:
A. at the module place of calling of code, insert audiomonitor, wherein said audiomonitor calls relevant log information for output when calling of this place occurs to this time;
B. the code after audiomonitor is inserted in operation, to export the journal file consisting of one or more log information;
C. according to described journal file, determine the analysis result of described code, the module call relation when analysis result of wherein said code is used for representing described code operation.
2. method according to claim 1, is characterized in that, described step C comprises:
According to the homophony module of each log information recording in described journal file and by mode transfer piece, drafting is from homophony module to by the line of mode transfer piece, to obtain the module call graph of described code during whole service, and the analysis result using described module call graph as described code.
3. method according to claim 1, is characterized in that, described step C comprises:
C1. according to each log information in described journal file, draw described code and call progress chart picture frame at each crucial moment of run duration;
That C2. utilizes each crucial moment calls progress chart picture frame, generate dynamic image document, and the analysis result using described dynamic image document as described code, wherein said dynamic image document description described code in the module of a plurality of times of running, call progress.
4. method according to claim 3, is characterized in that, described step C1 comprises:
C11. extract zero hour of calling of recording in each log information and at least one crucial moment at run duration as described code constantly in the finish time;
C12. for each crucial moment, determine calling of simultaneously carrying out this crucial moment, each that calculate in calling of simultaneously carrying out is invoked at the progress at this crucial moment, and the progress of calling according to each draw this crucial moment call progress chart picture frame.
5. method according to claim 4, is characterized in that, in described step C12, determines that the step of calling that crucial moment, T carried out simultaneously comprises:
Judge whether the closed interval forming zero hour of calling of recording in each log information and the finish time covers T, if so, corresponding the calling in closed interval that covers T extracted as one that T carries out at crucial moment in calling simultaneously.
6. method according to claim 4, is characterized in that, in described step C12, calculates the step that each in calling of simultaneously carrying out be invoked at the progress of T at crucial moment and comprises:
According to the thread identification recording in each log information, any one in definite calling of simultaneously carrying out called all sons of X in same thread and called, all sons by X in same thread call according to the time sequencing of calling and arrange, and obtain the sub-calling sequence of X;
Utilize the sub-calling sequence of X to calculate X in the progress of T at crucial moment, wherein:
When the zero hour that first son of X calls, be greater than crucial moment during T, determine that X belongs to journey and calls, and go the progress that journey is called to adopt following formula to calculate:
Figure FDA00001997499200021
wherein go represents that progress, key_time that journey is called represent that T at crucial moment, x_stime represent the zero hour, the call of X 1_ stime represents first zero hour that son calls of X; When crucial moment, T was greater than the finish time that last height of X calls, determine that X belongs to return and calls, and the progress that return is called adopts following formula to calculate:
Figure FDA00001997499200022
wherein back represents the progress that return calls, the finish time, the call that x_etime represents X n_ etime represents the finish time that last height of X calls.
7. method according to claim 3, is characterized in that, described dynamic image document comprises: lantern slide document, animation document or video documents.
8. method according to claim 1, is characterized in that, in described steps A, at least at the module place of calling with one of Types Below, inserts audiomonitor: service access type calls or event notice type calls.
9. a device for code performance analysis, comprising:
Plug-in unit, inserts audiomonitor for the module place of calling at code, and wherein said audiomonitor calls relevant log information for output when calling of this place occurs to this time;
Output unit, for moving the code inserting after audiomonitor, to export the journal file consisting of one or more log information;
Determining unit, for determine the analysis result of described code according to described journal file, the module call relation when analysis result of wherein said code is used for representing described code operation.
10. device according to claim 9, is characterized in that, described determining unit comprises:
Figure generation unit, be used for according to the homophony module of described each log information recording of journal file and by mode transfer piece, drafting is from homophony module to by the line of mode transfer piece, to obtain the module call graph of described code during whole service, and the analysis result using described module call graph as described code.
11. devices according to claim 9, is characterized in that, described determining unit comprises:
Picture frame generation unit, for according to each log information of described journal file, draws described code and calls progress chart picture frame at each crucial moment of run duration;
Document generation unit, for what utilize each crucial moment, call progress chart picture frame, generate dynamic image document, and the analysis result using described dynamic image document as described code, wherein said dynamic image document description described code in the module of a plurality of times of running, call progress.
12. devices according to claim 11, is characterized in that, described picture frame generation unit comprises:
Crucial moment determining unit, for extracting zero hour of calling that each log information records and at least one crucial moment at run duration as described code constantly in the finish time;
Progress drawing unit, be used for for each crucial moment, determine calling of simultaneously carrying out this crucial moment, calculate that in calling of simultaneously carrying out, each is invoked at the progress at this crucial moment, and the progress of calling according to each draw this crucial moment call progress chart picture frame.
13. devices according to claim 12, is characterized in that, described progress drawing unit determines that the mode of calling that crucial moment, T carried out simultaneously comprises:
Judge whether the closed interval forming zero hour of calling of recording in each log information and the finish time covers T, if so, corresponding the calling in closed interval that covers T extracted as one that T carries out at crucial moment in calling simultaneously.
14. devices according to claim 12, is characterized in that, described progress drawing unit calculates the mode that each in calling of simultaneously carrying out be invoked at the progress of T at crucial moment and comprises:
According to the thread identification recording in each log information, any one in definite calling of simultaneously carrying out called all sons of X in same thread and called, all sons by X in same thread call according to the time sequencing of calling and arrange, and obtain the sub-calling sequence of X;
Utilize the sub-calling sequence of X to calculate X in the progress of T at crucial moment, wherein:
When the zero hour that first son of X calls, be greater than crucial moment during T, determine that X belongs to journey and calls, and go the progress that journey is called to adopt following formula to calculate:
Figure FDA00001997499200041
wherein go represents that progress, key_time that journey is called represent that T at crucial moment, x_stime represent the zero hour, the call of X 1_ stime represents first zero hour that son calls of X; When crucial moment, T was greater than the finish time that last height of X calls, determine that X belongs to return and calls, and the progress that return is called adopts following formula to calculate:
Figure FDA00001997499200042
wherein back represents the progress that return calls, the finish time, the call that x_etime represents X n_ etime represents the finish time that last height of X calls.
15. devices according to claim 11, is characterized in that, described dynamic image document comprises: lantern slide document, animation document or video documents.
16. devices according to claim 9, is characterized in that, described plug-in unit at least inserts audiomonitor at the module place of calling with one of Types Below: service access type calls or event notice type calls.
CN201210285223.8A 2012-08-10 2012-08-10 A kind of method and device of code dynamic analysis Active CN103577304B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210285223.8A CN103577304B (en) 2012-08-10 2012-08-10 A kind of method and device of code dynamic analysis

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210285223.8A CN103577304B (en) 2012-08-10 2012-08-10 A kind of method and device of code dynamic analysis

Publications (2)

Publication Number Publication Date
CN103577304A true CN103577304A (en) 2014-02-12
CN103577304B CN103577304B (en) 2018-11-09

Family

ID=50049132

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210285223.8A Active CN103577304B (en) 2012-08-10 2012-08-10 A kind of method and device of code dynamic analysis

Country Status (1)

Country Link
CN (1) CN103577304B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104615919A (en) * 2015-02-10 2015-05-13 北京润科通用技术有限公司 File source code License control method and device
CN107122426A (en) * 2017-04-11 2017-09-01 上海众开信息科技有限公司 The monitoring acquisition methods and device of Operation Log information based on database
CN107733710A (en) * 2017-10-17 2018-02-23 平安科技(深圳)有限公司 Construction method, device, computer equipment and the storage medium of link call relation
CN109359028A (en) * 2018-08-22 2019-02-19 平安科技(深圳)有限公司 Code quality monitoring method, device, computer equipment and storage medium
CN111954058A (en) * 2020-08-13 2020-11-17 北京达佳互联信息技术有限公司 Image processing method, image processing apparatus, electronic device, and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5313616A (en) * 1990-09-18 1994-05-17 88Open Consortium, Ltd. Method for analyzing calls of application program by inserting monitoring routines into the executable version and redirecting calls to the monitoring routines
CN101320350A (en) * 2008-07-17 2008-12-10 金蝶软件(中国)有限公司 Performance monitoring method and device
CN101788949A (en) * 2010-03-10 2010-07-28 中兴通讯股份有限公司 Method and device for realizing embedded type system function monitoring
CN101876938A (en) * 2009-11-11 2010-11-03 北京神州泰岳软件股份有限公司 Message queue-based application software response time measuring method
CN102053906A (en) * 2009-10-30 2011-05-11 国际商业机器公司 System and method for collecting program runtime information
CN102360328A (en) * 2011-09-29 2012-02-22 用友软件股份有限公司 Programmed monitoring device and programmed monitoring method
CN102521543A (en) * 2011-12-23 2012-06-27 中国人民解放军国防科学技术大学 Method for information semantic analysis based on dynamic taint analysis

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5313616A (en) * 1990-09-18 1994-05-17 88Open Consortium, Ltd. Method for analyzing calls of application program by inserting monitoring routines into the executable version and redirecting calls to the monitoring routines
CN101320350A (en) * 2008-07-17 2008-12-10 金蝶软件(中国)有限公司 Performance monitoring method and device
CN102053906A (en) * 2009-10-30 2011-05-11 国际商业机器公司 System and method for collecting program runtime information
CN101876938A (en) * 2009-11-11 2010-11-03 北京神州泰岳软件股份有限公司 Message queue-based application software response time measuring method
CN101788949A (en) * 2010-03-10 2010-07-28 中兴通讯股份有限公司 Method and device for realizing embedded type system function monitoring
CN102360328A (en) * 2011-09-29 2012-02-22 用友软件股份有限公司 Programmed monitoring device and programmed monitoring method
CN102521543A (en) * 2011-12-23 2012-06-27 中国人民解放军国防科学技术大学 Method for information semantic analysis based on dynamic taint analysis

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
杜晓东: "面向嵌入式系统的测试工具研究", 《中国优秀硕士学位论文全文数据库信息科技辑》 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104615919A (en) * 2015-02-10 2015-05-13 北京润科通用技术有限公司 File source code License control method and device
CN104615919B (en) * 2015-02-10 2017-09-29 北京润科通用技术有限公司 A kind of file source code License control method and device
CN107122426A (en) * 2017-04-11 2017-09-01 上海众开信息科技有限公司 The monitoring acquisition methods and device of Operation Log information based on database
CN107733710A (en) * 2017-10-17 2018-02-23 平安科技(深圳)有限公司 Construction method, device, computer equipment and the storage medium of link call relation
CN109359028A (en) * 2018-08-22 2019-02-19 平安科技(深圳)有限公司 Code quality monitoring method, device, computer equipment and storage medium
CN109359028B (en) * 2018-08-22 2024-05-03 平安科技(深圳)有限公司 Code quality monitoring method, device, computer equipment and storage medium
CN111954058A (en) * 2020-08-13 2020-11-17 北京达佳互联信息技术有限公司 Image processing method, image processing apparatus, electronic device, and storage medium
CN111954058B (en) * 2020-08-13 2023-11-21 北京达佳互联信息技术有限公司 Image processing method, device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN103577304B (en) 2018-11-09

Similar Documents

Publication Publication Date Title
CN111723727A (en) Cloud monitoring method and device based on edge computing, electronic equipment and storage medium
CN103577304A (en) Method and device for dynamically analyzing code
US11502930B2 (en) Method and system for generating alerts using parameter based network monitoring for alert conditions
CN109214290A (en) A kind of shops's client management method and device based on recognition of face
CN110245056A (en) O&M alarm information processing method and device
CN107209825A (en) The data flow tracking monitored via memory
CN111985504B (en) Copying detection method, device, equipment and medium based on artificial intelligence
US20120251001A1 (en) Electronic device with function of separating panels of digital comic strip and method thereof
CN106528281A (en) Satellite telemetry data offline unified rapid processing system
CN113806183B (en) Application clamping and processing method, device, equipment, storage medium and program product
CN109167979A (en) The processing method and system of multi-path monitoring video artefacts' intellectual analysis
CN115952544A (en) Intelligent storage system based on big data
CN114169303A (en) Method, device, equipment and medium for editing table based on vue.js
CN201707722U (en) Intelligent high-efficiency pedestrian flow diversion system
CN102387289A (en) Reconfigurable operation apparatus, data compression apparatus and reconfigurable operation
CN116361791A (en) Malicious software detection method based on API packet reconstruction and image representation
CN110362470A (en) Test data collection method, device, electronic equipment and storage medium
CN115471215A (en) Business process processing method and device
CN105516793A (en) Method and apparatus of lapse monitoring
CN114039279A (en) Control cabinet monitoring method and system in rail transit station
CN105117323B (en) A kind of condition detection method of terminal and its CPU or memory
CN113691390A (en) Cloud-end-coordinated edge node alarm system and method
CN111738005A (en) Named entity alignment method and device, electronic equipment and readable storage medium
CN112101191A (en) Expression recognition method, device, equipment and medium based on frame attention network
CN113128253B (en) Reconstruction method and device of three-dimensional face model

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
EXSB Decision made by sipo to initiate substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant