CN110457196A - The acquisition methods and device of function timing - Google Patents

The acquisition methods and device of function timing Download PDF

Info

Publication number
CN110457196A
CN110457196A CN201910757322.3A CN201910757322A CN110457196A CN 110457196 A CN110457196 A CN 110457196A CN 201910757322 A CN201910757322 A CN 201910757322A CN 110457196 A CN110457196 A CN 110457196A
Authority
CN
China
Prior art keywords
api
detection module
time detection
objective function
time
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
CN201910757322.3A
Other languages
Chinese (zh)
Other versions
CN110457196B (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910757322.3A priority Critical patent/CN110457196B/en
Publication of CN110457196A publication Critical patent/CN110457196A/en
Application granted granted Critical
Publication of CN110457196B publication Critical patent/CN110457196B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

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

Landscapes

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

Abstract

The present invention provides a kind of acquisition methods of function timing and devices, this method comprises: obtaining the first call request, wherein, first call request is for calling first object application programming interfaces API, it include time detection module and pending objective function in first object API, for time detection module in the state being performed is forbidden before first object API is called, time detection module is used to obtain the execution time of objective function;It responds the first call request and the state of time detection module is positioned to allow for the state being performed;Time detection module and objective function are executed, the execution time of objective function is obtained.Solve in the related technology by deterministic analyzer cProfile analyze api interface time-consuming data when, due to need existing all api interfaces will be opened in the case where, cause API apply service performance reduce the technical issues of.

Description

The acquisition methods and device of function timing
Technical field
The present invention relates to application programming interfaces API performance test fields, in particular to a kind of function timing Acquisition methods and device.
Background technique
In the prior art, by the way that there are two types of modes to obtain application programming interfaces API (Application Programming Interface) time-consuming performance data.Wherein, mode one: by printing api interface time-consuming log mode, Mode two: api interface time-consuming data are analyzed by deterministic analyzer cProfile.
It should be noted that employing mode one obtains the time-consuming performance data of api interface, as shown in Figure 1, passing through printing Api interface time-consuming log mode obtains the schematic diagram of the time-consuming performance data of api interface.Employing mode one, developer need It is inserted into corresponding execution time code in original api interface, carries out interface code to be cut into different moulds by rough Then block obtains the time-consuming information of modules, these information are finally printed to log, or return by interface.I.e. In mode one: it needs to make the work of the code block of insertion datetime for specific interface, can not guarantee the pure of code, And it needs to read source code.
Employing mode two analyzes api interface time-consuming performance data by cProfile, as shown in Fig. 2, passing through cProfile Analyze the schematic diagram of api interface time-consuming data.Employing mode two can by cProfile program analysis api interface time-consuming data Guarantee the pure of api interface code to reach, reduces the purpose of invasion, but in mode two, if all to all api interfaces It opens, it will seriously affect the service performance of application.
By above-mentioned explanation it is recognised that at present scheme the main problems are as follows: need to read source code, and And modularization segmentation is carried out to code, and certain assessment is made to source code, time-consuming long module may be needed again Secondary deep segmentation and analysis.2) source code is invaded, it, will certainly be dirty because having made certain modification to the code in api interface Contaminate source code.3) needing to do some api interface time-consuming performance data analysis, and other api interfaces do not need to carry out time-consuming When performance data analysis, it cannot switch at any time.
For in the prior art, when analyzing api interface time-consuming data by deterministic analyzer cProfile, due to needing In the case where will being opened to existing all api interfaces, cause API apply service performance reduce the technical issues of.Mesh Before there is no effective solution scheme.
Summary of the invention
The embodiment of the invention provides a kind of acquisition methods of function timing and devices, at least to solve the relevant technologies In by deterministic analyzer cProfile analyze api interface time-consuming data when, due to need to existing all api interfaces In the case where will opening, cause API apply service performance reduce the technical issues of.
According to one embodiment of present invention, a kind of acquisition methods of function timing are provided, comprising: obtain first Call request, wherein first call request is for calling first object application programming interfaces API, the first object API In include time detection module and pending objective function, the time detection module is called in the first object API Preceding to be in the state for forbidding being performed, the time detection module is used to obtain the execution time of the objective function;Response institute It states the first call request and the state of the time detection module is positioned to allow for the state being performed;Execute the time detection Module and the objective function obtain the execution time of the objective function.
Further, after executing the time detection module and the objective function, the method also includes: by institute The state for stating the time detection module in first object API is set as described and forbids the state being performed.
Further, before the first call request of the acquisition, the method also includes: increase in the first initial API Add the time detection module, obtain the first object API, wherein includes described pending in the first initial API Objective function.
Further, the time detection module and the objective function are executed, when obtaining the execution of the objective function Between include: during obtaining the execution time of the objective function, by institute in the first object application programming interfaces API There is the execution time of objective function to generate log, and the log is saved in the database.
Further, after and the log being saved in the database, the method also includes: it is obtained according to the log All objective functions in the first object API are taken to execute the function that the time is more than first threshold, and more than first threshold Call relation between function;The function is adjusted according to the call relation, when execution to reduce the objective function Between.
According to another embodiment of the invention, a kind of acquisition device of function timing is provided, comprising: obtain single Member obtains the first call request, wherein first call request is described for calling first object application programming interfaces API It include time detection module and pending objective function in first object API, the time detection module is in first mesh In the state being performed is forbidden before mark API is called, the time detection module is used to obtain the execution of the objective function Time;Response unit is used for;Unit is obtained, for executing the time detection module and the objective function, obtains the mesh The execution time of scalar functions.
Further, described device further include: setting unit, for executing the time detection module and the target After function, sets described for the state of the time detection module in the first object API and forbid the shape being performed State.
Further, described device further include: adding unit, for before the first call request of the acquisition, the Increase the time detection module in one initial API, obtain the first object API, wherein is wrapped in the first initial API Include the pending objective function.
According to still another embodiment of the invention, a kind of storage medium is additionally provided, meter is stored in the storage medium Calculation machine program, wherein the computer program is arranged to execute the acquisition side of any of the above-described function timing when operation Step in method embodiment.
According to still another embodiment of the invention, a kind of electronic device, including memory and processor are additionally provided, it is described Computer program is stored in memory, the processor is arranged to run the computer program to execute any of the above-described Step in the acquisition methods embodiment of function timing.
Through the invention, the first call request is obtained, wherein the first call request is for calling first object application program It include time detection module and pending objective function in interface API, first object API, time detection module is in the first mesh In the state being performed is forbidden before mark API is called, time detection module is used to obtain the execution time of objective function;Response The state of time detection module is positioned to allow for the state being performed by the first call request;Execute time detection module and target Function obtains the execution time of objective function.It solves in the related technology through cProfile program analysis api interface time-consuming number According to when, due to need existing all api interfaces will be opened in the case where, cause API apply service performance reduce The technical issues of.
Detailed description of the invention
The drawings described herein are used to provide a further understanding of the present invention, constitutes part of this application, this hair Bright illustrative embodiments and their description are used to explain the present invention, and are not constituted improper limitations of the present invention.In the accompanying drawings:
Fig. 1 is the time-consuming performance data for obtaining api interface by printing api interface time-consuming log mode in the prior art Schematic diagram;
Fig. 2 is the schematic diagram for analyzing api interface time-consuming data by cProfile in the prior art;
Fig. 3 is a kind of hardware configuration frame of the mobile terminal of the acquisition methods of function timing of the embodiment of the present invention Figure;
Fig. 4 is a kind of flow chart of the acquisition methods of function timing according to an embodiment of the present invention;
It is time consuming nature that a kind of specified api interface that Fig. 5 is provided in preferred embodiments according to the present invention carries out cProfile analysis The structural framing schematic diagram of energy data;
Fig. 6 is the api interface short time consumption file that some cProfile analysis saves in preferred embodiments according to the present invention Schematic diagram;
Fig. 7 is that provide in preferred embodiments according to the present invention a kind of carries out cProfile analysis to specified api interface The flow diagram of time-consuming performance data;
Fig. 8 is the structural block diagram of the acquisition device of function timing according to an embodiment of the present invention.
Specific embodiment
Hereinafter, the present invention will be described in detail with reference to the accompanying drawings and in combination with Examples.It should be noted that not conflicting In the case of, the features in the embodiments and the embodiments of the present application can be combined with each other.
It should be noted that description and claims of this specification and term " first " in above-mentioned attached drawing, " Two " etc. be to be used to distinguish similar objects, without being used to describe a particular order or precedence order.
Embodiment 1
The acquisition methods embodiment of function timing provided by the embodiment of the present application one can be in mobile terminal, calculating It is executed in machine terminal or similar arithmetic unit.For running on mobile terminals, Fig. 3 is one kind of the embodiment of the present invention The hardware block diagram of the mobile terminal of the acquisition methods of function timing.As shown in figure 3, mobile terminal 10 may include one (processor 102 can include but is not limited to Micro-processor MCV or can compile a or multiple (one is only shown in Fig. 3) processor 102 The processing unit of journey logical device FPGA etc.) and memory 104 for storing data, optionally, above-mentioned mobile terminal may be used also To include transmission device 106 and input-output equipment 108 for communication function.Those of ordinary skill in the art can manage Solution, structure shown in Fig. 3 are only to illustrate, and do not cause to limit to the structure of above-mentioned mobile terminal.For example, mobile terminal 10 is also It may include more perhaps less component or with the configuration different from shown in Fig. 3 than shown in Fig. 3.
Memory 104 can be used for storing computer program, for example, the software program and module of application software, such as this hair The corresponding computer program of the acquisition methods of function timing in bright embodiment, processor 102 are stored in by operation Computer program in reservoir 104 realizes above-mentioned method thereby executing various function application and data processing.Storage Device 104 may include high speed random access memory, may also include nonvolatile memory, as one or more magnetic storage device, Flash memory or other non-volatile solid state memories.In some instances, memory 104 can further comprise relative to processing The remotely located memory of device 102, these remote memories can pass through network connection to mobile terminal 10.The reality of above-mentioned network Example includes but is not limited to internet, intranet, local area network, mobile radio communication and combinations thereof.
Transmitting device 106 is used to that data to be received or sent via a network.Above-mentioned network specific example may include The wireless network that the communication providers of mobile terminal 10 provide.In an example, transmitting device 106 includes a Network adaptation Device (Network Interface Controller, referred to as NIC), can be connected by base station with other network equipments to It can be communicated with internet.In an example, transmitting device 106 can for radio frequency (Radio Frequency, referred to as RF) module is used to wirelessly be communicated with internet.
Fig. 4 is a kind of flow chart of the acquisition methods of function timing according to an embodiment of the present invention, as shown in figure 4, The acquisition methods process of the function timing includes the following steps:
Step S402 obtains the first call request, wherein the first call request is for calling first object application program to connect It include time detection module and pending objective function in mouth API, first object API, the time, detection module was in first object In the state being performed is forbidden before API is called, time detection module is used to obtain the execution time of objective function.
Wherein it is possible to obtain the first call request by way of input order.Time detection module can be CProfile performance analysis tool.
It should be noted that the above method can also include: in the first initial API before obtaining the first call request Middle increase time detection module, obtains first object API, wherein includes pending objective function in the first initial API.
It should also be noted that, time detection module is in the state for forbidding being performed before first object API is called, Therefore, the case where api interface is switched on is avoided, and then leads to the reduction of AIP service performance.
The state of time detection module is positioned to allow for the state being performed by step S404, the first call request of response.
Step S406 executes time detection module and objective function, obtains the execution time of objective function.
It should be noted that executing time detection module and objective function, the execution time for obtaining objective function can wrap It includes: during obtaining the execution time of objective function, by all objective functions in first object application programming interfaces API Time generation log is executed, and log is saved in the database.Therefore, the objective function of api interface can be obtained in real time The execution time, and then according to real time data carry out function timing adjustment, to improve the performance of the api interface.
Wherein, after and log being saved in the database, the above method can also include: according to the first mesh of log acquisition It marks all objective functions in API and executes the function that the time is more than first threshold, and more than the tune between the function of first threshold With relationship;According to call relation Tuning function, to reduce the execution time of objective function.
It should also be noted that, by step S402 to step S406 it is found that obtaining the letter in first object api interface When number executes the time, the state of acquisition time detection module is needed, as long as allowing to be performed in time detection module state When state, time detection module and objective function can be just executed, and then obtains the execution time of objective function.It realizes and does not have to Api interface source code is read, does not have to modification source code, and can control with plug-in, carries out time-consuming performance evaluation for needs The method analyzed of API.Further, accomplish that api interface goes wrong on line, can be connect immediately for specified API Mouth opens cProfile performance evaluation, is then shut off cProfile performance evaluation, does not influence user experience on line.
Through the above steps, the first call request is obtained, wherein the first call request is for calling first object application journey It include time detection module and pending objective function in sequence interface API, first object API, the time, detection module was first In the state being performed is forbidden before target API is called, time detection module is used to obtain the execution time of objective function;It rings Answer the first call request that the state of time detection module is positioned to allow for the state being performed;Execute time detection module and mesh Scalar functions obtain the execution time of objective function.It solves time-consuming by cProfile program analysis api interface in the related technology When data, in the case where needing that existing all api interfaces will be opened, the service performance for causing API to apply drops Low technical problem.
Optionally, the executing subject of above-mentioned steps can for server, terminal etc., but not limited to this.
Through the above description of the embodiments, those skilled in the art can be understood that according to above-mentioned implementation The method of example can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but it is very much In the case of the former be more preferably embodiment.Based on this understanding, technical solution of the present invention is substantially in other words to existing The part that technology contributes can be embodied in the form of software products, which is stored in a storage In medium (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal device (can be mobile phone, calculate Machine, server or network equipment etc.) execute method described in each embodiment of the present invention.
Embodiment 2
In conjunction with above-described embodiment, a kind of preferred embodiments are additionally provided in the present embodiment, which is a kind of Based on api interface performance data acquisition methods in cProfile plug-in position line.
The preferred embodiments, mainly solve on webpage line or (API wherein, handled in preferred embodiment is equal by API under line Write by Python) orientation problem of interface time-consuming performance data.
In the preferred embodiments, propose to analyze the time consuming nature of api interface to be detected by cProfile tool for processing Energy data, and pass through the interaction flow of a set of plug-in, it not only can be convenient developer's offline analysis, most importantly can When realizing that interface occur on line takes long time, special interface can be analyzed come targeted come specified interface by plug-in Time-consuming performance data, and the mode of performance data flow path visual is greatly improved into developer for developer's orientation problem Reparation problem efficiency, while the detection scheme has no effect to environment on line, guarantees that environment operates normally on line.
As shown in figure 5, a kind of specified api interface provided in the preferred embodiments, which carries out cProfile, analyzes time-consuming performance The structural framing schematic diagram of data.
Shown in fig. 5, there are multiple applications for client layer, for example, using 1, using 2, using 3 etc..Routing layer has more A api interface, for example, API1, API2, API3 etc..Cache layer Redis, wherein judge whether out in cache layer Redis Open cProfile.By judging to need to be implemented specified API cProfile analysis, and the time-consuming data of api interface are analyzed As a result asynchronous to be stored in File Store layer.The file of storage can also be subjected to API visualization, API2 visualization in visualization layer Etc..
Wherein, to visualization layer, detailed description are as follows:
To the file being stored on file storage S3 platform, it can pull and be further analyzed, for example obtain debugging In API, the submodule of top10 before time-consuming obtains the calling hierarchical relationship etc. in API between modules.Also it is done for the work One flow scheme, the program are to be realized by pstats+gprof2dot, and built corresponding Visualization Platform.Such as Fig. 6 institute Show, the schematic diagram for the api interface short time consumption file that some cProfile analysis saves.Specifically it is described as follows.
In Fig. 6 it is found that the output of the execution time of some API is as a result, output result explanation: sharing 34330 function tune With;Ncalls: the called number of function, tottime function amount to runing time, and percall function operation is primary to be averaged Time, equal to tottime/ncalls, the time that cumtime function total is run, the function operation time containing calling, Filename, the line number of function, function number where filenname:lineno (function) function.Output shown in Fig. 6 As a result, can clearly know the time that each function executes.Function can be ranked up according to the time is executed, check execution Time longer function, and then further progress adjusts.
According to the submodule function for the time-consuming top10 that the file that exports in Fig. 5 of preservation get after secondary analysis, And the calling hierarchical relationship in API between modules.
It should be noted that carrying out centralized maintenance pipe to the api interface for needing to initiate cProfile analysis in the embodiment Reason, administrator can configure these API from the background, and the API for needing cProfile to analyze of configuration is synchronized to Redis and cached by program In;It is put down by judging to need to be implemented specified API cProfile analysis, and to the asynchronous file storage S3 that is stored in of analysis result Platform facilitates subsequent visualization layer analysis to show.By this set configurableization, the scheme of plug type, both ensure that on line Interface carry out performance adjustment purpose, also ensure pure pollution-free, interface the safety of interface.
As shown in fig. 7, a kind of time-consuming for carrying out cProfile analysis to specified api interface provided in the preferred embodiments The flow diagram of performance data.It should be noted that the realization of the process is based on the structural framing figure in Fig. 5.
Step S701 starts.
Step S702, user initiate URL request, enter specified api interface after routing from the background.
Step S703 when entering specified api interface, needs to judge whether the interface has and opens cProfile performance tune Examination, enters step S804 if cProfile performance adjustment is not turned on, if opening cProfile performance adjustment, into Enter step S805.
Step S704 executes api interface content.
Step S705 is executed if opening cProfile performance adjustment and is opened cProfile.
Step S706 executes api interface content.
Step S707 finally terminates to close cProfile debugging.
Obtained performance adjustment data are saved in backstage S3 (used here as the S3 platform built), after doing by step S708 Phase, which is analysed in depth, to be used.
Step S709 terminates.
One is proposed primarily directed to deterministic analyzer cProfile performance analysis tool by the preferred embodiments The scheme of interface capability bottleneck in complete plug type and switch control position line is covered, if using other analysis tools And can achieve purpose, for example, APM (application performance management).
Embodiment 3
A kind of acquisition device of function timing is additionally provided in the present embodiment, and the device is for realizing above-mentioned implementation Example and preferred embodiment, the descriptions that have already been made will not be repeated.As used below, term " module " may be implemented pre- Determine the combination of the software and/or hardware of function.Although device described in following embodiment is preferably realized with software, The realization of the combination of hardware or software and hardware is also that may and be contemplated.
Fig. 8 is the structural block diagram of the acquisition device of function timing according to an embodiment of the present invention, as shown in figure 8, should The acquisition device of function timing includes: acquiring unit 81, response unit 83, obtains unit 85.It is described in detail below.
Acquiring unit 81, for obtaining the first call request, wherein first call request is for calling first object It include time detection module and pending objective function, the time in application programming interfaces API, the first object API Detection module is in the state being performed is forbidden before the first object API is called, and the time detection module is for obtaining Take the execution time of the objective function.
Response unit 83 responds first call request and is positioned to allow for being held by the state of the time detection module Capable state.
Unit 85 is obtained, is positioned to allow for the state of the time detection module for responding first call request The state being performed.
By above-mentioned apparatus, acquiring unit 81 obtains the first call request, wherein first call request is for calling In first object application programming interfaces API, the first object API include time detection module and pending objective function, For the time detection module in the state being performed is forbidden before the first object API is called, the time detects mould Block is used to obtain the execution time of the objective function;Response unit 83 responds first call request and detects the time The state of module is positioned to allow for the state being performed;It obtains unit 85 and responds first call request detecting the time The state of module is positioned to allow for the state being performed.It solves in the related technology through deterministic analyzer cProfile scheme When analyzing api interface time-consuming data, in the case where needing that existing all api interfaces will be opened, API is caused to answer The technical issues of service performance reduces
It should be noted that above-mentioned modules can be realized by software or hardware, for the latter, Ke Yitong Following manner realization is crossed, but not limited to this: above-mentioned module is respectively positioned in same processor;Alternatively, above-mentioned modules are with any Combined form is located in different processors.
Embodiment 4
The embodiments of the present invention also provide a kind of storage medium, computer program is stored in the storage medium, wherein The computer program is arranged to execute the step in any of the above-described embodiment of the method when operation.
Optionally, in the present embodiment, above-mentioned storage medium can be set to store by executing based on following steps Calculation machine program:
S1 obtains the first call request, wherein and the first call request is used to call first object application programming interfaces API, It include time detection module and pending objective function in first object API, time detection module is adjusted in first object API With preceding in the state being performed is forbidden, time detection module is used to obtain the execution time of objective function;
The state of time detection module is positioned to allow for the state being performed by S2, the first call request of response;
S3 executes time detection module and objective function, obtains the execution time of objective function.
Optionally, in the present embodiment, above-mentioned storage medium can include but is not limited to: USB flash disk, read-only memory (Read- Only Memory, referred to as ROM), it is random access memory (Random Access Memory, referred to as RAM), mobile hard The various media that can store computer program such as disk, magnetic or disk.
The embodiments of the present invention also provide a kind of electronic device, including memory and processor, stored in the memory There is computer program, which is arranged to run computer program to execute the step in any of the above-described embodiment of the method Suddenly.
Optionally, above-mentioned electronic device can also include transmission device and input-output equipment, wherein the transmission device It is connected with above-mentioned processor, which connects with above-mentioned processor.
Optionally, in the present embodiment, above-mentioned processor can be set to execute following steps by computer program:
S1 obtains the first call request, wherein and the first call request is used to call first object application programming interfaces API, It include time detection module and pending objective function in first object API, time detection module is adjusted in first object API With preceding in the state being performed is forbidden, time detection module is used to obtain the execution time of objective function;
The state of time detection module is positioned to allow for the state being performed by S2, the first call request of response;
S3 executes time detection module and objective function, obtains the execution time of objective function.
Optionally, the specific example in the present embodiment can be with reference to described in above-described embodiment and optional embodiment Example, details are not described herein for the present embodiment.
Obviously, those skilled in the art should be understood that each module of the above invention or each step can be with general Computing device realize that they can be concentrated on a single computing device, or be distributed in multiple computing devices and formed Network on, optionally, they can be realized with the program code that computing device can perform, it is thus possible to which they are stored It is performed by computing device in the storage device, and in some cases, it can be to be different from shown in sequence execution herein Out or description the step of, perhaps they are fabricated to each integrated circuit modules or by them multiple modules or Step is fabricated to single integrated circuit module to realize.In this way, the present invention is not limited to any specific hardware and softwares to combine.
The foregoing is only a preferred embodiment of the present invention, is not intended to restrict the invention, for the skill of this field For art personnel, the invention may be variously modified and varied.It is all within principle of the invention, it is made it is any modification, etc. With replacement, improvement etc., should all be included in the protection scope of the present invention.

Claims (10)

1. a kind of acquisition methods of function timing characterized by comprising
Obtain the first call request, wherein first call request is for calling first object application programming interfaces API, institute Stating in first object API includes time detection module and pending objective function, and the time detection module is described first In the state being performed is forbidden before target API is called, the time detection module is for obtaining holding for the objective function The row time;
It responds first call request and the state of the time detection module is positioned to allow for the state being performed;
The time detection module and the objective function are executed, the execution time of the objective function is obtained.
2. the method according to claim 1, wherein executing the time detection module and the objective function Later, the method also includes:
It sets described for the state of the time detection module in the first object API and forbids the state being performed.
3. the method according to claim 1, wherein before the first call request of the acquisition, the method Further include:
Increase the time detection module in the first initial API, obtain the first object API, wherein described first is initial It include the pending objective function in API.
4. the method according to claim 1, wherein execute the time detection module and the objective function, The execution time for obtaining the objective function includes:
During obtaining the execution time of the objective function, will own in the first object application programming interfaces API The execution time of objective function generates log, and the log is saved in the database.
5. according to the method described in claim 4, it is characterized in that, and save in the database after, the method also includes:
The function that the time is more than first threshold is executed according to objective functions all in first object API described in the log acquisition, And more than the call relation between the function of first threshold;
The function is adjusted according to the call relation, to reduce the execution time of the objective function.
6. a kind of acquisition device of function timing characterized by comprising
Acquiring unit obtains the first call request, wherein first call request is for calling first object application program to connect It include time detection module and pending objective function in mouth API, the first object API, the time detection module exists In the state being performed is forbidden before the first object API is called, the time detection module is for obtaining the target The execution time of function;
The state of the time detection module is positioned to allow for being performed by response unit for responding first call request State;
Unit is obtained, for executing the time detection module and the objective function, when obtaining the execution of the objective function Between.
7. device according to claim 6, which is characterized in that described device further include:
Setting unit is used for after executing the time detection module and the objective function, will be in the first object API The state of the time detection module be set as described and forbid the state being performed.
8. device according to claim 6, which is characterized in that described device further include:
Adding unit, for before the first call request of the acquisition, increasing the time detection mould in the first initial API Block obtains the first object API, wherein includes the pending objective function in the first initial API.
9. a kind of storage medium, which is characterized in that be stored with computer program in the storage medium, wherein the computer Program is arranged to execute method described in any one of claim 1 to 5 when operation.
10. a kind of electronic device, including memory and processor, which is characterized in that be stored with computer journey in the memory Sequence, the processor are arranged to run the computer program to execute side described in any one of claim 1 to 5 Method.
CN201910757322.3A 2019-08-16 2019-08-16 Method and device for acquiring function execution time Active CN110457196B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910757322.3A CN110457196B (en) 2019-08-16 2019-08-16 Method and device for acquiring function execution time

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910757322.3A CN110457196B (en) 2019-08-16 2019-08-16 Method and device for acquiring function execution time

Publications (2)

Publication Number Publication Date
CN110457196A true CN110457196A (en) 2019-11-15
CN110457196B CN110457196B (en) 2023-10-24

Family

ID=68486993

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910757322.3A Active CN110457196B (en) 2019-08-16 2019-08-16 Method and device for acquiring function execution time

Country Status (1)

Country Link
CN (1) CN110457196B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111625302A (en) * 2020-05-29 2020-09-04 北京字节跳动网络技术有限公司 Function time consumption tracking method, device and storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070294673A1 (en) * 2006-06-16 2007-12-20 Microsoft Corporation Automated method and system for collecting and reporting API performance profiles
JP2014222384A (en) * 2013-05-13 2014-11-27 日本電気株式会社 Function execution time measuring device, function execution time measuring method, and function execution time measuring program
CN104866416A (en) * 2014-02-25 2015-08-26 腾讯科技(深圳)有限公司 Method and device for performance analysis of application program
US20160011955A1 (en) * 2014-07-09 2016-01-14 Microsoft Corporation Extracting Rich Performance Analysis from Simple Time Measurements
US20160019102A1 (en) * 2014-07-15 2016-01-21 International Business Machines Corporation Application pattern discovery
CN107957931A (en) * 2017-11-23 2018-04-24 泰康保险集团股份有限公司 A kind of method and device for monitoring run time
CN108037926A (en) * 2017-12-26 2018-05-15 网易(杭州)网络有限公司 Optimization method, device, storage medium, processor and the terminal of bytecode
US20180157571A1 (en) * 2015-06-12 2018-06-07 dSPACE digital signal processing and control engineering Method for the realistic estimation of function run times in pil simulation
CN109783161A (en) * 2018-12-11 2019-05-21 北京三快在线科技有限公司 The operation information of application program determines method, apparatus in iOS system
CN109947624A (en) * 2019-03-25 2019-06-28 深圳市腾讯信息技术有限公司 Method for monitoring state and device

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070294673A1 (en) * 2006-06-16 2007-12-20 Microsoft Corporation Automated method and system for collecting and reporting API performance profiles
JP2014222384A (en) * 2013-05-13 2014-11-27 日本電気株式会社 Function execution time measuring device, function execution time measuring method, and function execution time measuring program
CN104866416A (en) * 2014-02-25 2015-08-26 腾讯科技(深圳)有限公司 Method and device for performance analysis of application program
US20160011955A1 (en) * 2014-07-09 2016-01-14 Microsoft Corporation Extracting Rich Performance Analysis from Simple Time Measurements
US20160019102A1 (en) * 2014-07-15 2016-01-21 International Business Machines Corporation Application pattern discovery
US20180157571A1 (en) * 2015-06-12 2018-06-07 dSPACE digital signal processing and control engineering Method for the realistic estimation of function run times in pil simulation
CN107957931A (en) * 2017-11-23 2018-04-24 泰康保险集团股份有限公司 A kind of method and device for monitoring run time
CN108037926A (en) * 2017-12-26 2018-05-15 网易(杭州)网络有限公司 Optimization method, device, storage medium, processor and the terminal of bytecode
CN109783161A (en) * 2018-12-11 2019-05-21 北京三快在线科技有限公司 The operation information of application program determines method, apparatus in iOS system
CN109947624A (en) * 2019-03-25 2019-06-28 深圳市腾讯信息技术有限公司 Method for monitoring state and device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111625302A (en) * 2020-05-29 2020-09-04 北京字节跳动网络技术有限公司 Function time consumption tracking method, device and storage medium

Also Published As

Publication number Publication date
CN110457196B (en) 2023-10-24

Similar Documents

Publication Publication Date Title
US10452843B2 (en) Self-adaptive application programming interface level security monitoring
EP3471344B1 (en) System and method for selecting proxy computer
US10567398B2 (en) Method and apparatus for remote malware monitoring
CN111290958B (en) Method and device for debugging intelligent contract
CN109471845A (en) Blog management method, server and computer readable storage medium
CN110336790A (en) A kind of method and system of website detection
CN104281520A (en) Tracking and debugging method, device and system
CN108491321A (en) test case range determining method, device and storage medium
CN105630662B (en) Internal-memory detection method and device
CN113159145A (en) Characteristic engineering arrangement method and device
CN106055609A (en) nginx log monitoring method and apparatus, message distribution system and information processing apparatus
CN115698941A (en) Efficient packaging of components
CN105592061A (en) Attack rule closure method and device
US11985029B2 (en) Pico-base station configuration method and apparatus, storage medium and electronic apparatus
CN110457196A (en) The acquisition methods and device of function timing
US20100293262A1 (en) Automated system management process
CN111193631B (en) Information processing method, system, and computer-readable storage medium
CN112637223A (en) Application protocol identification method and device, computer equipment and storage medium
CN117349618A (en) Method and medium for constructing malicious encryption traffic detection model of network information system
CN111917848A (en) Data processing method based on edge computing and cloud computing cooperation and cloud server
US20200213203A1 (en) Dynamic network health monitoring using predictive functions
CN112445692B (en) Case testing method and terminal
CN107342917A (en) Method and apparatus for detecting performance of network equipments
CN110544182B (en) Power distribution communication network fusion control method and system based on machine learning technology
CN109902831B (en) Service decision processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant