CN109491884A - Code method for testing performance, device, computer equipment and medium - Google Patents

Code method for testing performance, device, computer equipment and medium Download PDF

Info

Publication number
CN109491884A
CN109491884A CN201811123390.6A CN201811123390A CN109491884A CN 109491884 A CN109491884 A CN 109491884A CN 201811123390 A CN201811123390 A CN 201811123390A CN 109491884 A CN109491884 A CN 109491884A
Authority
CN
China
Prior art keywords
code
performance
detection
character
target character
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201811123390.6A
Other languages
Chinese (zh)
Inventor
肖伟平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management 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 Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN201811123390.6A priority Critical patent/CN109491884A/en
Publication of CN109491884A publication Critical patent/CN109491884A/en
Pending legal-status Critical Current

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/362Software debugging
    • G06F11/366Software debugging using diagnostics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3628Software debugging of optimised code

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

This application involves a kind of code method for testing performance, device, computer equipment and storage mediums based on research and development management.The described method includes: obtaining object code, the object code is split as multiple code blocks;Obtain performance detection table;The performance detection table has recorded multiple target characters and the associated detection logic of each target character and performance description;Multiple code blocks are scanned to obtain target character respectively according to the performance detection table, performance issue whether there is according to the associated detection logic judgment respective code block of the target character;Performance issue if it exists carries out performance indicia to respective code block based on the associated performance description of the target character.Code performance detection efficiency can be improved using this method, and then improve software product optimization efficiency.

Description

Code method for testing performance, device, computer equipment and medium
Technical field
This application involves field of computer technology, set more particularly to a kind of code method for testing performance, device, computer Standby and medium.
Background technique
Software product has application in every profession and trade field, in order to preferably control the q&r of software product, needs A variety of tests, such as performance test are carried out to software product.Performance test refers to a variety of just by the testing tool simulation of automation Often, peak value and exceptional condition test the performance indexes of software product.There are many softwares on the market at present Energy detection instrument, such as Jmeter, OpenSTA, these tools can provide the examining report comprising several software performance parameter. But examining report usually only provides software product, and there are also the test results which aspect needs to be improved.For developer, It then needing to improve and optimizate numerous and jumbled software code according to general test result, this undoubtedly increases developer's workload, Also reduce software product optimization efficiency.
Summary of the invention
Based on this, it is necessary to which in view of the above technical problems, providing one kind can be improved code performance detection efficiency, Jin Erti Code method for testing performance, device, computer equipment and the medium of high software product optimization efficiency.
A kind of code method for testing performance, which comprises obtain object code, the object code is split as more A code block;Obtain performance detection table;The performance detection table has recorded multiple target characters and each target character Associated detection logic and performance description;Multiple code blocks are scanned to obtain target word respectively according to the performance detection table Symbol whether there is performance issue according to the associated detection logic judgment respective code block of the target character;Performance is asked if it exists Topic carries out performance indicia to respective code block based on the associated performance description of the target character.
It is described in one of the embodiments, that the object code is split as multiple code blocks, comprising: to the target Code is traversed, and identifies the function keyword in the object code;The function keyword root is set with according to preset rules Priority level;Obtain the corresponding fractionation expression formula of each function keyword;According to the priority level of the function keyword, utilize The corresponding expression formula that splits repeatedly splits the object code, obtains multiple code segments;The code segment is traversed, Identify the fractionation character in each code segment;The fractionation character is set with priority level according to preset rules;Acquisition is each torn open Divide the corresponding fractionation expression formula of character;According to the priority level for splitting character, using the corresponding expression formula that splits to the generation Code section is repeatedly split, and multiple code blocks are obtained.
It is described in one of the embodiments, that respective code block is carried out based on the target character associated performance description Performance indicia, comprising: identify location information of the target character in the object code;Based on the location information and The associated detection logic of the target character and performance description, generate performance label;By the way that the performance label is added to institute The position in object code where respective objects character is stated, performance indicia is carried out to respective code block.
In one of the embodiments, the method also includes: identify each target character respectively in the object code In location information;Based on the corresponding location information of target character each in object code and associated detection logic sum Performance description generates detection log.
In one of the embodiments, the method also includes: receive configuring request;The configuring request carries code Language identification;Corresponding code detection table is obtained according to code language mark;The code detection table includes multiple detections Item and the corresponding detection logic of each detection;The configuration page is generated according to the code detection table, shows the configuration page Face;Change is obtained to the change operation of the corresponding detection logic of one or more detections in the configuration page based on user Code detection information afterwards;Respective code detection table is updated according to the code detection information after the change.
The code detection information after the change includes JSON character string in one of the embodiments,;It is described according to institute Code detection information after stating change is updated respective code detection table, comprising: will be described by the first regular expression JSON character string is split as multistage node character string;The second regular expression is obtained, second regular expression includes one Or multiple target strings with change mark;Determine the traversal direction of multistage node character string;According to the traversal direction Multistage node character string is traversed respectively, according to the target string in second regular expression, to multistage node The character string accordingly changed in character string is screened;Based on the multiple character strings filtered out to respective code detection table into Row updates.
A kind of code device for detecting performance, described device includes: that code splits module, for obtaining object code, by institute It states object code and is split as multiple code blocks;Performance detection module, for obtaining performance detection table;The performance detection table record Multiple target characters and the description of the associated detection logic of each target character and performance;According to the performance detection table Multiple code blocks are scanned to obtain target character respectively, according to the associated detection logic judgment of the target character corresponding generation Code block whether there is performance issue;Performance indicia module is based on the associated property of the target character for performance issue if it exists It can describe to carry out performance indicia to respective code block.
The code splits module and is also used to traverse the object code in one of the embodiments, identifies Function keyword in the object code;The function keyword root is set with priority level according to preset rules;It obtains each The corresponding fractionation expression formula of function keyword;According to the priority level of the function keyword, expression formula pair is split using corresponding The object code is repeatedly split, and multiple code segments are obtained;The code segment is traversed, is identified in each code segment Fractionation character;The fractionation character is set with priority level according to preset rules;Obtain the corresponding fractionation of each fractionation character Expression formula;According to the priority level for splitting character, the code segment is repeatedly split using the corresponding expression formula that splits, Obtain multiple code blocks.
A kind of computer equipment, including memory and processor, the memory are stored with computer program, the processing Device realizes the step of code method for testing performance provided in any one embodiment of the application when executing the computer program.
A kind of computer readable storage medium, is stored thereon with computer program, and the computer program is held by processor The step of code method for testing performance provided in any one embodiment of the application is provided when row.
Above-mentioned code method for testing performance, device, computer equipment and storage medium, split object code, can To obtain multiple code blocks;Multiple code blocks are scanned respectively, can be examined according to the performance for having recorded multiple target characters Survey table extracts target character in each code block;According to each of recording the associated inspection of the target character in performance detection table Survey logic, it can be determined that respective code block whether there is performance issue;Performance issue if it exists, can be according in performance detection table The associated different corresponding performances of logic that detect of each of the record target character describe, can be to respective code block progressive It can label.According to preset performance detection table, performance issue existing for object code not only can detecte out, also to performance issue Positioning problems are carried out, determine appearance position of the performance issue in object code, and carry out performance mark directly in object code Note, developer can quickly carry out positioning problems according to the performance indicia in object code, and then improve code optimization efficiency.
Detailed description of the invention
Fig. 1 is the application scenario diagram of code method for testing performance in one embodiment;
Fig. 2 is the flow diagram of code method for testing performance in one embodiment;
Fig. 3 is the flow diagram of object code splitting step in one embodiment;
Fig. 4 is the structural block diagram of code device for detecting performance in one embodiment;
Fig. 5 is the internal structure chart of computer equipment in one embodiment.
Specific embodiment
It is with reference to the accompanying drawings and embodiments, right in order to which the objects, technical solutions and advantages of the application are more clearly understood The application is further elaborated.It should be appreciated that specific embodiment described herein is only used to explain the application, not For limiting the application.
Code method for testing performance provided by the present application, can be applied in application environment as shown in Figure 1.Wherein, eventually End 102 is communicated with server 104 by network.Wherein, terminal 102 can be, but not limited to be various personal computers, pen Remember this computer, smart phone, tablet computer and portable wearable device, server 104 can with independent server or It is the server cluster of multiple server compositions to realize.If being mounted with code capabilities detection tools in terminal 102 (hereinafter referred to as " detection instrument "), when user needs to carry out performance detection to the corresponding code file of application program (hereinafter referred to as " object code ") When, object code to be detected can be uploaded to detection instrument, object code is split by detection instrument, is obtained multiple Code block.The detection instrument has been pre-stored " performance detection table ".Performance detection table has recorded multiple target characters and each mark The detection logic and performance of character association describe.Detection instrument is scanned multiple code blocks according to performance detection table respectively To target character, performance issue whether there is according to the associated detection logic judgment respective code block of target character.Property if it exists Energy problem then carries out performance indicia to respective code block based on the associated performance description of target character.It is readily appreciated that, detection instrument Also it may be mounted at server 104, it, can be by terminal 102 by mesh when user needs to carry out performance detection to object code Mark code is uploaded to server 104, carries out performance detection to object code according to above scheme by server 104, and will test The detection log generated afterwards is back to terminal 102.Above-mentioned code performance testing process, according to preset performance detection table, not only It can detecte out performance issue existing for object code, positioning problems also carried out to performance issue, determine performance issue in target Appearance position in code, and performance indicia is carried out directly in object code, developer can be according in object code Performance indicia quickly carries out positioning problems, and then improves code optimization efficiency.
In one embodiment, as shown in Fig. 2, providing a kind of code method for testing performance, it is applied to Fig. 1 in this way In terminal for be illustrated, comprising the following steps:
Step 202, object code is obtained, object code is split as multiple code blocks.
Detection instrument has been run in terminal.Detection instrument can exist with independent application forms, the detection at this time Tool is integrated with the operation carrier of the code of different programming languages in advance, such as nodejs (JavaScript literal translation formula scripting language Operation carrier) etc., the object code of a variety of programming languages is directly run in the detection instrument.The detection instrument It can be present in code running tool in the form of plug-in unit.It, can be with when user needs to carry out performance detection to object code The plug-in unit is installed in code running tool, i.e., is stored plug-in unit into the project structure where object code.Different programming languages The corresponding different code running environment of speech, and the plug-in unit can support a variety of programming languages, user can be in code running tool In unrestricted choice as needed.
When user needs to carry out performance detection to object code, object code can be uploaded to detection instrument.Detection Object code is split as being able to carry out the granularity of performance indicia by tool.Specifically, detection instrument obtains preset multiple fractionations The corresponding fractionation expression formula of character.Splitting character can be function keyword, such as if, for, else, elseif.Split character It is also possible to other customized characters or character string, such as " (" ") " " " " " " [" "] ".Split expression formula include to comprising The fractionation rule of the corresponding front and back code for splitting character, for example, function keyword for passes through left bracket and right parenthesis quantity Matching Realize loop body identification.Detection instrument traverses object code, identifies the fractionation character in object code, and utilization is preset The corresponding corresponding fractionation expression formula of character that splits splits object code, obtains multiple code blocks.Code block can be one A expression formula is also possible to other kinds of code statement.Object code is split as multiple code blocks, convenient for subsequent to multiple Code block synchronizes detection, can also improve detection efficiency with code.
Step 204, performance detection table is obtained;Performance detection table has recorded multiple target characters and each target character closes The detection logic and performance of connection describe.
Performance detection table is that the code regulation based on different programming languages constructs, have recorded multiple target characters with And the associated detection logic of each target character and performance description.Target character can be function keyword, be also possible to other Self-defining character, such as logical operator "+" "=" "-".Detection logic can be illustrated with code literary style lack of standardization, can also be advised The citing of model code literary style.Each target character can have a variety of corresponding detection logics.Performance description refers to if the target Character correspond to code segment the reason of belonging to preset code literary style lack of standardization, then performance may be caused to influence object code and As a result.For example, the corresponding one of detection of self-defining character "=" is patrolled when detecting logic is that code literary style lack of standardization is illustrated Collecting may is that
H=$ (' #element') .height ();
$('#element').css('height',h-20);
This kind of code literary style lack of standardization needs constantly to carry out DOM traversal, since DOM traversal needs persistently to occupy a large amount of codes Resource is executed, corresponding performance description can be " not to element caching is reused, waste code executes resource ".
Step 206, multiple code blocks are scanned to obtain target character respectively according to performance detection table, according to target word Associated detection logic judgment respective code block is accorded with the presence or absence of performance issue.
Step 208, performance issue if it exists carries out performance to respective code block based on the associated performance description of target character Label.
Checking tool be based on each target character preset corresponding detection logic, based on detection logic to different code block into Row performance detection.It is then which time reference is united in object code to the variable as there is variable in above-mentioned code block Meter carries out performance indicia to the code block according to preset mark format if belonging to second of reference.Preset mark format can be with It is " code position, performance description ".Wherein, code position can be target character or code block first character in target generation Line number in code.For example, the content of performance indicia can be " 177, variable is repeatedly quoted, committed memory ".
In the present embodiment, object code is split, available multiple code blocks;Multiple code blocks are carried out respectively Scanning, can extract target character in each code block according to the performance detection table for having recorded multiple target characters;According to property The associated detection logic of each target character recorded in table can be detected, it can be determined that respective code block is asked with the presence or absence of performance Topic;Performance issue if it exists, can be according to the associated different detection logics pair of each target character recorded in performance detection table The performance description answered can carry out performance indicia to respective code block.According to preset performance detection table, not only can detecte out Performance issue existing for object code also carries out positioning problems to performance issue, determines performance issue going out in object code Existing position, and performance indicia is carried out directly in object code, developer can be fast according to the performance indicia in object code Speed carries out positioning problems, and then improves code optimization efficiency.
In one embodiment, as shown in figure 3, object code is split as multiple code blocks, i.e. object code is split Step, comprising:
Step 302, object code is traversed, identifies the function keyword in object code;Function keyword root evidence Preset rules are set with priority level.
Step 304, the corresponding fractionation expression formula of each function keyword is obtained.
Step 306, multiple to object code progress using the corresponding expression formula that splits according to the priority level of function keyword It splits, obtains multiple code segments.
Step 308, code segment is traversed, identifies the fractionation character in each code segment;Character is split according to default Rule settings have priority level.
Step 310, the corresponding fractionation expression formula of each fractionation character is obtained.
Step 312, according to the priority level for splitting character, code segment is repeatedly torn open using the corresponding expression formula that splits Point, obtain multiple code blocks.
Detection instrument is based on multiple function keywords and other split character and are preset with corresponding fractionation expression formula respectively.Letter The priority level of number keyword is higher than other and splits character.Detection instrument is using the fractionation expression formula of different priority levels to target Code carries out multi-layer fractionation.Specifically, detection instrument traverses object code, identify that the function in object code is crucial Word.Each function keyword root is set with priority level according to preset rules.The function that detection instrument obtains TP top priority closes The corresponding fractionation expression formula of key word, splits object code based on the fractionation expression formula got, obtains generation among multistage Code, is denoted as first code.Detection instrument obtains the corresponding fractionation expression formula of function keyword of time high precedence, based on acquisition To fractionation expression formula multistage first code is split, further obtain multistage intermediate code, so recycle, until obtain The corresponding multistage intermediate code of the function keyword of lowest priority, is denoted as code segment.
Detection instrument obtains the corresponding fractionation expression formula of fractionation character of TP top priority, based on the split table got Each code segment is split up to formula, multistage intermediate code is obtained, is denoted as second code.Detection instrument obtains time high precedence The corresponding fractionation expression formula of fractionation character, second code is split based on the fractionation expression formula got, obtains multistage Intermediate code so recycles, until the corresponding intermediate code of fractionation character of lowest priority, is denoted as code block.
It in the present embodiment, is realized according to function keyword and preset characters and the multi-layer of object code is split, can incited somebody to action Object code is split to the granularity that can carry out performance detection and performance indicia.
In one embodiment, performance indicia, packet are carried out to respective code block based on the associated performance description of target character It includes: location information of the identification target character in object code;Based on location information and the associated detection logic of target character It is described with performance, generates performance label;By the way that performance label to be added to the position in object code where respective objects character, Performance indicia is carried out to respective code block.
When code block existence energy problem, detection instrument obtains code position of the code block in object code.Generation Code position can according to code block first character in object code or object code target character in object code Location information determines, for example, can using the line number of target character or code block first character in object code as Code position of the code block in object code.Detection instrument is according to the associated property of target character in code position and the code block It can describe, generate the corresponding performance label of the code block.For example, performance label can be, " 177, variable is repeatedly quoted, in occupancy It deposits ".Detection instrument code position where respective code block in object code is inserted into the performance label.
In the present embodiment, based on multidimensional such as the location informations, questions and prospect, problem result for the code block of performance issue occur It spends information and generates performance label, comprehensively understand the performance condition of each code segment in time convenient for developer;By performance label It is quickly fixed that addition carries out the corresponding code issue of performance issue near the code block for performance issue occur, convenient for developer Code optimization efficiency is improved in position.
In one embodiment, method further include: identify location information of each target character respectively in object code; It is described based on the corresponding location information of target character each in object code and associated detection logic and performance, generates detection Log.
When code block existence energy problem, detection instrument determines generation of the code block in object code in the manner described above Code position.There are target characters in the corresponding code position of the code block of performance issue and the code block to close by each for detection instrument The performance description record extremely detection log of connection.Detection log includes multiple there are the target character of performance issue and each mesh Marking-up accords with corresponding code position and performance indicia.Detection log can be presented in the form of a list, so that the property of object code Energy problem is very clear.
In another embodiment, there are performances to ask also directed to each in detection log or performance label for detection instrument The code block of topic provides reputable code literary style example and it is excellent to further increase code so that developer understands prioritization scheme in time Change efficiency.For example, the corresponding reputable code literary style example of code block may is that in the example above
$ element=$ (' #element');
H=$ element.height ();
$element.css('height',h-20);
In reputable code literary style example, the variable repeatedly quoted first uses a variable to go assignment, then by using assignment Variable afterwards does other references, can reduce DOM to avoid single DOM node is inquired repeatedly and traverse number, and then can subtract Few code executes the waste of resource.
In the present embodiment, by all properties problem log existing for object code into detection log, facilitate developer Globality understanding is made to the performance condition of object code.
In one embodiment, this method further include: receive configuring request;Configuring request carries code language mark; Corresponding code detection table is obtained according to code language mark;Code detection table includes multiple detections and each detection pair The detection logic answered;The configuration page is generated according to code detection table, shows the configuration page;Based on user to one in the configuration page The change operation of the corresponding detection logic of a or multiple detections, the code detection information after obtaining change;According to the generation after change Code detection information is updated respective code detection table.
Code literary style lack of standardization is difficult to expect completely, to need each target word to recording in code detection table Corresponding detection logic is accorded with constantly to be expanded.When carrying out detection logic expansion, detection instrument receives user and passes through end Hold the configuring request to code detection table of triggering.Configuring request carries programming language classification.Code detection table can be direct It stores to terminal, also can store to server.When code detection table is stored in terminal local, detection instrument is according to programming language It saying that classification obtains corresponding code detection table, and shows code detection table, user can directly modify code detection table, To realize configuration change.In order to improve the safety of code detection table, the copy of code detection table can be only shown, based on use Family is updated the modification of copy to the code detection table being locally stored.
When code detection table is stored in server, the configuring request that terminal is triggered according to user is matched to server transmission Request is set, server obtains corresponding code detection table according to programming language classification, and code detection table is mapped as including more The configuration page is back to terminal and is shown by the configuration page of a detection.Configuration page face includes multiple detections and every The corresponding detection logic of a detection and performance description.Each detection can correspond to a target character.User can match It sets page progress target character and corresponding detection logic and performance describes the operation newly such as to be increased, deleted or changed.Detect work Tool saves instruction according to the configuration that user triggers, and obtains whole code detection information in the configuration page, code detection information is sent out It send to server.Server screens the part code detection information changed from whole code detection information, is based on The code detection information of change is updated code detection table.
Traditional code detection tool does not support that user is customized to detection logic, when user needs alteration detection logic When need to contact the developer of code detection tool and rewrite corresponding detection logical code so that detection logic alternative effect Rate reduces.The present embodiment records detection logic in code detection table in a manner of natural language, expands when carrying out detection logic When filling, detection logic and/or the performance description of respective objects character need to only be changed in code detection table, without writing Code can be realized detection logic it is customized, reduce detection the customized threshold of logic.
In one embodiment, the code detection information after change includes JSON character string;According to the code inspection after change Measurement information is updated respective code detection table, comprising: JSON character string is split as multistage by the first regular expression Node character string;The second regular expression is obtained, the second regular expression includes one or more targets with change mark Character string;Determine the traversal direction of multistage node character string;Multistage node character string is traversed respectively according to traversal direction, According to the target string in the second regular expression, the character string accordingly changed in multistage node character string is sieved Choosing;Respective code detection table is updated based on the multiple character strings filtered out.
When code detection table is stored in server, user can carry out target character and corresponding detection in the configuration page Logic and performance describe the configurations operation newly such as to be increased, deleted or changed, and are added in corresponding detection according to configuration operation Change mark.Change mark is a kind of label to the detection being changed.Change mark can be in detection predeterminated position The preset characters or preset characters string of insertion.It is JSON that terminal, which will configure whole code detection information preservations in the page, A kind of (JavaScript Object Notation, data transmission format) object.JSON object includes multiple nodes.Each section The corresponding detection of point.
It is JSON (JavaScript Object that terminal, which will configure whole code detection information preservations in the page, Notation, a kind of data transmission format) object.For improve data transfer rate, JSON object is converted to JSON by terminal JSON object is sent to server by character string.
Server has been pre-stored the first regular expression, and the first regular expression includes origin identification symbol and end of identification Symbol.JSON character string is split as multistage node character string by the first regular expression of server by utilizing.Each node character string pair Answer a detection.Traditional carries out data extraction in the data of JSON format, and server needs to convert JSON character string For JSON object, data are extracted in JSON object.But when the data volume of JSON data is very big, data transfer time is long, drop The low screening efficiency to JSON data.The present embodiment since JSON character string is split as multistage by the first regular expression so that It is not necessary that JSON character string is converted to JSON object, data extraction can be carried out directly in JSON character string.
It is operated since different user can carry out different configurations to code detection logic, to need in corresponding node character The character string extracted of going here and there is also different.Thus server has preset multiple second regular expressions.Each second regular expression packet Include one or more target strings with change mark.Since terminal mark in the detection being changed by addition change Know, thus the second regular expression can be and automatically generate according to preset rules, so as to reducing because of manual compiling second Character string selection efficiency can be improved to the screening time of character string in regular expression.
Server respectively traverses multiple node character strings according to determining traversal direction.In ergodic process, clothes The target string that business device includes according to corresponding second regular expression, is searched and target string phase in node character string The character string matched.The character string to match refers to the corresponding character string of key-value pair for having identical key name with target string.It mentions The character string obtained is based on the detection changed.Server carries out code detection table based on obtained character string is extracted It updates.
In the present embodiment, since JSON character string is directly split as multistage by the first regular expression, so that being not necessarily to will JSON character string is converted to JSON object, can carry out detection using the second regular expression directly in JSON character string It extracts, extracts the efficiency of the detection changed in JSON data so as to improve, and then improve the screening of JSON data Efficiency.
It should be understood that although each step in the flow chart of Fig. 2 and Fig. 3 is successively shown according to the instruction of arrow, But these steps are not that the inevitable sequence according to arrow instruction successively executes.Unless expressly state otherwise herein, these There is no stringent sequences to limit for the execution of step, these steps can execute in other order.Moreover, in Fig. 2 and Fig. 3 At least part step may include that perhaps these sub-steps of multiple stages or stage are not necessarily same to multiple sub-steps One moment executed completion, but can execute at different times, and the execution in these sub-steps or stage sequence is also not necessarily Be successively carry out, but can at least part of the sub-step or stage of other steps or other steps in turn or Alternately execute.
In one embodiment, as shown in figure 4, providing a kind of code device for detecting performance, comprising: code splits module 402, performance detection module 404 and performance indicia module 406, in which:
Code splits module 402 and object code is split as multiple code blocks for obtaining object code.
Performance detection module 404, for obtaining performance detection table;Performance detection table has recorded multiple target characters and every The associated detection logic of a target character and performance description;Multiple code blocks are scanned to obtain respectively according to performance detection table Target character whether there is performance issue according to the associated detection logic judgment respective code block of target character.
Performance indicia module 406, for performance issue if it exists, based on the associated performance description of target character to corresponding generation Code block carries out performance indicia.
In one embodiment, code splits module 402 and is also used to traverse object code, identifies in object code Function keyword;Function keyword root is set with priority level according to preset rules;Obtain that each function keyword is corresponding to be torn open Divide expression formula;According to the priority level of function keyword, object code is repeatedly split using the corresponding expression formula that splits, is obtained To multiple code segments;Code segment is traversed, identifies the fractionation character in each code segment;Character is split according to preset rules It is set with priority level;Obtain the corresponding fractionation expression formula of each fractionation character;According to split character priority level, using pair Expression formula should be split, code segment is repeatedly split, obtain multiple code blocks.
In one embodiment, performance indicia module 406 is also used to identify position letter of the target character in object code Breath;It is described based on the associated detection logic of location information and target character and performance, generates performance label;By by performance mark Label are added to the position in object code where respective objects character, carry out performance indicia to respective code block.
In one embodiment, which further includes log generation module 408, and each target character exists respectively for identification Location information in object code;It is patrolled based on the corresponding location information of target character each in object code and associated detection It collects and performance description, generation detects log.
In one embodiment, which further includes logic configuration module 410, for receiving configuring request;Configuring request Carry code language mark;Corresponding code detection table is obtained according to code language mark;Code detection table includes multiple inspections Survey item and the corresponding detection logic of each detection;The configuration page is generated according to code detection table, shows the configuration page;It is based on Code detection of the user in the configuration page to the change operation of the corresponding detection logic of one or more detections, after obtaining change Information;Respective code detection table is updated according to the code detection information after change.
In one embodiment, the code detection information after change includes JSON character string;Logic configuration module 410 is also used In JSON character string is split as multistage node character string by the first regular expression;Obtain the second regular expression, second Regular expression includes one or more target strings with change mark;Determine the traversal side of multistage node character string To;Multistage node character string is traversed respectively according to traversal direction, according to the target string in the second regular expression, The character string accordingly changed in multistage node character string is screened;Based on the multiple character strings filtered out to corresponding generation Code detection table is updated.
Specific about code device for detecting performance limits the limit that may refer to above for code method for testing performance Fixed, details are not described herein.Modules in above-mentioned code device for detecting performance can fully or partially through software, hardware and its Combination is to realize.Above-mentioned each module can be embedded in the form of hardware or independently of in the processor in computer equipment, can also be with It is stored in the memory in computer equipment in a software form, in order to which processor calls the above modules of execution corresponding Operation.
In one embodiment, a kind of computer equipment is provided, which can be terminal, internal structure Figure can be as shown in Figure 5.The computer equipment includes processor, the memory, network interface, display connected by system bus Screen and input unit.Wherein, the processor of the computer equipment is for providing calculating and control ability.The computer equipment is deposited Reservoir includes non-volatile memory medium, built-in storage.The non-volatile memory medium is stored with operating system and computer journey Sequence.The built-in storage provides environment for the operation of operating system and computer program in non-volatile memory medium.The calculating The network interface of machine equipment is used to communicate with external terminal by network connection.When the computer program is executed by processor with Realize a kind of code method for testing performance.The display screen of the computer equipment can be liquid crystal display or electric ink is shown Screen, the input unit of the computer equipment can be the touch layer covered on display screen, be also possible on computer equipment shell Key, trace ball or the Trackpad of setting can also be external keyboard, Trackpad or mouse etc..
It will be understood by those skilled in the art that structure shown in Fig. 5, only part relevant to application scheme is tied The block diagram of structure does not constitute the restriction for the computer equipment being applied thereon to application scheme, specific computer equipment It may include perhaps combining certain components or with different component layouts than more or fewer components as shown in the figure.
A kind of computer readable storage medium is stored thereon with computer program, when computer program is executed by processor The step of code method for testing performance provided in any one embodiment of the application is provided.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with Instruct relevant hardware to complete by computer program, computer program to can be stored in a non-volatile computer readable It takes in storage medium, the computer program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein, this Shen Please provided by any reference used in each embodiment to memory, storage, database or other media, may each comprise Non-volatile and/or volatile memory.Nonvolatile memory may include read-only memory (ROM), programming ROM (PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM) or flash memory.Volatile memory may include Random access memory (RAM) or external cache.By way of illustration and not limitation, RAM is available in many forms, Such as static state RAM (SRAM), dynamic ram (DRAM), synchronous dram (SDRAM), double data rate sdram (DDRSDRAM), enhancing Type SDRAM (ESDRAM), synchronization link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic ram (DRDRAM) and memory bus dynamic ram (RDRAM) etc..
Each technical characteristic of above embodiments can be combined arbitrarily, for simplicity of description, not to above-described embodiment In each technical characteristic it is all possible combination be all described, as long as however, the combination of these technical characteristics be not present lance Shield all should be considered as described in this specification.
Above embodiments only express the several embodiments of the application, and the description thereof is more specific and detailed, but can not Therefore it is construed as limiting the scope of the patent.It should be pointed out that for those of ordinary skill in the art, Under the premise of not departing from the application design, various modifications and improvements can be made, these belong to the protection scope of the application. Therefore, the scope of protection shall be subject to the appended claims for the application patent.

Claims (10)

1. a kind of code method for testing performance, which comprises
Object code is obtained, the object code is split as multiple code blocks;
Obtain performance detection table;The performance detection table has recorded multiple target characters and is associated with each target character Detection logic and performance description;
Multiple code blocks are scanned to obtain target character respectively according to the performance detection table, are closed according to the target character The detection logic judgment respective code block of connection whether there is performance issue;
Performance issue if it exists carries out performance indicia to respective code block based on the associated performance description of the target character.
2. the method according to claim 1, wherein described be split as multiple code blocks for the object code, Include:
The object code is traversed, identifies the function keyword in the object code;The function keyword root evidence Preset rules are set with priority level;
Obtain the corresponding fractionation expression formula of each function keyword;According to the priority level of the function keyword, correspondence is utilized It splits expression formula repeatedly to split the object code, obtains multiple code segments;
The code segment is traversed, identifies the fractionation character in each code segment;The fractionation character is according to preset rules It is set with priority level;
Obtain the corresponding fractionation expression formula of each fractionation character;According to the priority level for splitting character, split using corresponding Expression formula repeatedly splits the code segment, obtains multiple code blocks.
3. the method according to claim 1, wherein described based on the associated performance description pair of the target character Respective code block carries out performance indicia, comprising:
Identify location information of the target character in the object code;
It is described based on the location information and the associated detection logic of the target character and performance, generates performance label;
By the way that the performance label is added to the position in the object code where respective objects character, to respective code block Carry out performance indicia.
4. the method according to claim 1, wherein the method also includes:
Identify location information of each target character respectively in the object code;
It is described based on the corresponding location information of target character each in object code and associated detection logic and performance, Generate detection log.
5. the method according to claim 1, wherein the method also includes:
Receive configuring request;The configuring request carries code language mark;
Corresponding code detection table is obtained according to code language mark;The code detection table include multiple detections and The corresponding detection logic of each detection;
The configuration page is generated according to the code detection table, shows the configuration page;
Change is obtained to the change operation of the corresponding detection logic of one or more detections in the configuration page based on user Code detection information afterwards;
Respective code detection table is updated according to the code detection information after the change.
6. according to the method described in claim 5, it is characterized in that, the code detection information after the change includes JSON character String;The code detection information according to after the change is updated respective code detection table, comprising: passes through the first canonical The JSON character string is split as multistage node character string by expression formula;
The second regular expression is obtained, second regular expression includes one or more target characters with change mark String;
Determine the traversal direction of multistage node character string;
Multistage node character string is traversed respectively according to the traversal direction, according to the mesh in second regular expression Character string is marked, the character string accordingly changed in multistage node character string is screened;
Respective code detection table is updated based on the multiple character strings filtered out.
7. a kind of code device for detecting performance, described device include:
Code splits module and the object code is split as multiple code blocks for obtaining object code;
Performance detection module, for obtaining performance detection table;The performance detection table has recorded multiple target characters and each The associated detection logic of the target character and performance description;Multiple code blocks are swept respectively according to the performance detection table It retouches to obtain target character, performance issue whether there is according to the associated detection logic judgment respective code block of the target character;
Performance indicia module, for performance issue if it exists, based on the associated performance description of the target character to respective code Block carries out performance indicia.
8. device according to claim 7, which is characterized in that the code splits module and is also used to the object code It is traversed, identifies the function keyword in the object code;The function keyword root is set with preferentially according to preset rules Grade;Obtain the corresponding fractionation expression formula of each function keyword;According to the priority level of the function keyword, correspondence is utilized It splits expression formula repeatedly to split the object code, obtains multiple code segments;The code segment is traversed, is identified Fractionation character in each code segment;The fractionation character is set with priority level according to preset rules;Obtain each fractionation word Accord with corresponding fractionation expression formula;According to the priority level for splitting character, using the corresponding expression formula that splits to the code segment It is repeatedly split, obtains multiple code blocks.
9. a kind of computer equipment, including memory and processor, the memory are stored with computer program, feature exists In the step of processor realizes any one of claims 1 to 6 the method when executing the computer program.
10. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer program The step of method described in any one of claims 1 to 6 is realized when being executed by processor.
CN201811123390.6A 2018-09-26 2018-09-26 Code method for testing performance, device, computer equipment and medium Pending CN109491884A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811123390.6A CN109491884A (en) 2018-09-26 2018-09-26 Code method for testing performance, device, computer equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811123390.6A CN109491884A (en) 2018-09-26 2018-09-26 Code method for testing performance, device, computer equipment and medium

Publications (1)

Publication Number Publication Date
CN109491884A true CN109491884A (en) 2019-03-19

Family

ID=65689942

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811123390.6A Pending CN109491884A (en) 2018-09-26 2018-09-26 Code method for testing performance, device, computer equipment and medium

Country Status (1)

Country Link
CN (1) CN109491884A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110309050A (en) * 2019-05-22 2019-10-08 深圳壹账通智能科技有限公司 Detection method, device, server and the storage medium of code specification
CN112860564A (en) * 2021-02-24 2021-05-28 深圳海付移通科技有限公司 Code detection method, server, user terminal, computer device and storage medium
CN113835990A (en) * 2020-06-23 2021-12-24 中科寒武纪科技股份有限公司 Detection method, detection device, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107015813A (en) * 2017-04-19 2017-08-04 网易(杭州)网络有限公司 Method, device and electronic equipment that code is repaired
CN107678957A (en) * 2017-09-25 2018-02-09 中国银行股份有限公司 A kind of Net silver code automatic checking method and device
CN107908405A (en) * 2017-11-17 2018-04-13 苏州蜗牛数字科技股份有限公司 The static examination & verification device and method of code
CN107967216A (en) * 2017-12-18 2018-04-27 网易(杭州)网络有限公司 Code detection method and device, equipment, computer-readable recording medium
CN108363587A (en) * 2018-03-07 2018-08-03 平安普惠企业管理有限公司 Application program operation and monitoring method, device, computer equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107015813A (en) * 2017-04-19 2017-08-04 网易(杭州)网络有限公司 Method, device and electronic equipment that code is repaired
CN107678957A (en) * 2017-09-25 2018-02-09 中国银行股份有限公司 A kind of Net silver code automatic checking method and device
CN107908405A (en) * 2017-11-17 2018-04-13 苏州蜗牛数字科技股份有限公司 The static examination & verification device and method of code
CN107967216A (en) * 2017-12-18 2018-04-27 网易(杭州)网络有限公司 Code detection method and device, equipment, computer-readable recording medium
CN108363587A (en) * 2018-03-07 2018-08-03 平安普惠企业管理有限公司 Application program operation and monitoring method, device, computer equipment and storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110309050A (en) * 2019-05-22 2019-10-08 深圳壹账通智能科技有限公司 Detection method, device, server and the storage medium of code specification
CN113835990A (en) * 2020-06-23 2021-12-24 中科寒武纪科技股份有限公司 Detection method, detection device, computer equipment and storage medium
CN113835990B (en) * 2020-06-23 2024-01-30 中科寒武纪科技股份有限公司 Detection method, detection device, computer equipment and storage medium
CN112860564A (en) * 2021-02-24 2021-05-28 深圳海付移通科技有限公司 Code detection method, server, user terminal, computer device and storage medium

Similar Documents

Publication Publication Date Title
CN106598574B (en) Page rendering method and device
CN108491199B (en) Method and terminal for automatically generating interface
CN102804147B (en) Perform the code check executive system of the code check of ABAP source code
EP3866028A2 (en) Method and apparatus for constructing quality evaluation model, device and storage medium
CN108614707A (en) Static code inspection method, device, storage medium and computer equipment
CN106874256A (en) Name the method and device of entity in identification field
CN102467497B (en) Method and system for text translation in verification program
CN109491884A (en) Code method for testing performance, device, computer equipment and medium
CN112328489B (en) Test case generation method and device, terminal equipment and storage medium
CN105335246B (en) A kind of program crashing defect self-repairing method based on question and answer web analytics
CN104391796A (en) Method for parsing test cases
CN110377516A (en) Test method, device, electronic equipment and computer readable storage medium
CN104268163A (en) Method and system for acquiring network management network element configuration interface
CN103235757B (en) Several apparatus and method that input domain tested object is tested are made based on robotization
CN109325217B (en) File conversion method, system, device and computer readable storage medium
CN110162299A (en) Web program and its Quick Development Framework, development approach and relevant device
CN107784055A (en) Transaction methods and device based on non-relational database
CN109634569A (en) Process implementation method, device, equipment and readable storage medium storing program for executing based on note
CN110058849A (en) Generation method, device, computer equipment and the storage medium of flow chart
CN109885583A (en) Data query method, apparatus, equipment and storage medium based on block chain
CN102193789B (en) Method and equipment for realizing configurable skip link
CN105653273A (en) Personalized customizing method for client function under B/S architecture
CN111414404A (en) Data visualization device and method
CN108614692A (en) Edit model method, apparatus, server and medium
CN107741905B (en) Test case, analytic model thereof, execution method, storage medium and processor

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