Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be clearly and completely described below with reference to specific embodiments of the present application and corresponding drawings. It will be apparent that the described embodiments are only some, but not all, embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The following describes in detail the technical solutions provided by the embodiments of the present application with reference to the accompanying drawings.
Fig. 1 is a flowchart of an application running state monitoring method according to an exemplary embodiment of the present application. As shown in fig. 1, the method includes:
101. Starting a timer when starting the hybrid mobile application, wherein the timer circularly times according to a set duration threshold, and the hybrid mobile application comprises a plurality of objective functions for responding to the page request;
102. Sequentially executing the triggered objective functions in a single-thread mode during each timing period of the timer, and recording the execution time and identification information of the objective functions by using the record codes inserted in the objective functions;
103. When the timer is called back each time, acquiring actual timing time length of the timer each time, if the actual timing time length is larger than a time length threshold value, determining identification information of the objective function executed in the actual timing time length according to the recorded execution time of each objective function;
104. and outputting the identification information of the objective function executed in the actual timing time length which is larger than the time length threshold value for analyzing the page response state of the hybrid mobile application.
The mobile terminal can run the hybrid mobile application, and the type of the mobile terminal is not limited, for example, the mobile terminal is a smart phone, a notebook computer or a desktop computer. The type of hybrid mobile application is also not limited, e.g., gaming applications, financial applications, real estate applications may be rental-sales applications, viewing applications, etc. The hybrid mobile application is developed by a cross-platform mobile application development framework, and in the application embodiment, the hybrid mobile application can be developed based on the REACT NATIVE development framework, but is not limited thereto.
In this embodiment, the hybrid mobile application includes functions for implementing various functions, including system functions and non-system functions developed by REACT NATIVE development framework. Among these non-system functions, some are for responding to page requests and some are responsible for underlying logic processing, such as functions that interact with the server. For convenience of distinction, in the present embodiment, a function for responding to a page request included in the hybrid mobile application is referred to as an objective function. The objective function may be one or more, and these objective functions are all developed by the developer based on REACT NATIVE development frameworks and are not system functions. Among other things, the hybrid mobile application may provide various pages to the user during runtime, such as a head page, a login page, and various specific business pages, etc. One or more interactive controls are arranged on the pages and used for users to initiate interactive operation. The interactive control may be any control form capable of responding to a user trigger operation and converting the user trigger operation into a specific page request, for example, may be a window, a text box, a button, a drop-down menu, etc. It should be noted that, the functions and types of the pages are different, and the interactive controls set on the pages are also different, which is not limited by the embodiment of the present application. For the user, a page request may be initiated to the hybrid mobile application through any interaction control on any page provided by the hybrid mobile application. That is, the page request is generated during runtime by the hybrid mobile application in response to user-triggered operation of the interaction controls on the various pages provided by the hybrid mobile application. And finally, acquiring an execution result of the objective function or/and intermediate state data generated in the execution process, and outputting the execution result and/or the intermediate state data to a user as response data corresponding to the page request. Optionally, for convenience of description and distinction, the page from which the user initiates the page request is denoted as the first page, and the response data may be directly displayed on the first page as embedded content on the first page, or the response data may be displayed on the first page in a floating window or a floating layer form, or the response data may be displayed as new page data on the second page associated with the first page, and the embodiment of the present application is not limited with respect to the manner of outputting the response data.
In this embodiment, taking the mixed mobile application as an example, the house watching application has one or more functions, each function corresponds to an objective function, such as house classification, searching, and the like, correspondingly, controls such as "classification", "searching" and the like are displayed on a page of the house watching application, when a user has a requirement, the controls such as "classification", "searching" and the like can be triggered to generate page requests corresponding to the controls such as "classification", "searching" and the like, and the mixed mobile application can respectively execute the corresponding objective functions, such as house classification functions "," searching functions ", in response to the page requests corresponding to the controls such as" classification "," searching "and the like, and display house list information after classifying houses or house list information meeting searching conditions on related pages so as to realize the functions such as" classification "," searching "of the house watching application. In addition, it should be noted that, the hybrid mobile application of the embodiment supports single-thread running, that is, only one function occupies the processor resource at the same time in the running process of the hybrid application, and is executed by the processor to be in a running state, and the functions are sequentially executed in sequence.
During the running of the hybrid mobile application, page stuck may occur. The phenomenon of page stuck refers to that the response time of the page request exceeds a set duration threshold, wherein the response time of the page request refers to the time from the time when the user triggers the page request to the time when response data is output to the user, and once the response time exceeds the set duration threshold, the response time exceeds the waiting time which can be born by the user, and the user has obvious stuck feeling, namely the phenomenon of page stuck occurs. In this embodiment, each page request in the same hybrid mobile application may correspond to the same duration threshold. In the embodiment of the application, the duration threshold value can reflect the maximum waiting time which can be born by the user from the time when the user triggers the page request to the time when the response data is output to the user. The duration threshold may be determined by a test, and specifically, the duration threshold may be determined according to a maximum waiting time that a large number of users can trigger various page requests and obtain a maximum waiting time that the large number of users consider that no obvious katon feel is generated from the time of triggering various page requests to the time of returning response data to the users. For example, the average time may be taken as the duration threshold by averaging the maximum waiting times that can be sustained by a large number of users, or the maximum or minimum waiting time among all the maximum waiting times may be taken as the duration threshold. In addition, it should be noted that the test procedure may be a test initiated by the hybrid mobile application itself, that is, a large number of users trigger various page requests through the pages provided by the hybrid mobile application, but is not limited thereto. For example, the testing process may be performed for multiple applications supporting man-machine interaction, that is, different users may trigger a page request through pages provided by different applications, and further determine the duration threshold according to the obtained maximum waiting time that a large number of users can endure. For example, assuming that the duration threshold is 1s after the above test procedure, after the user triggers a control on the page, the user waits for 1s, and the page still does not respond, or the page still does not return correct page data, but is always in a request or waiting state, which is called a page stuck phenomenon. The reason for the page-stuck phenomenon may be that development of some objective functions in the hybrid mobile application is not reasonable enough, for example, code redundancy is large, running time-out is caused, or code logic is not reasonable enough, dead loops are caused, etc.
Therefore, during the running of the hybrid mobile application, the running state of each objective function in the hybrid mobile application needs to be monitored, and the code position causing the page jam of the hybrid mobile application is positioned so as to improve the running performance of the hybrid mobile application by optimizing the code, thereby solving the problem of the page jam.
Further, in the embodiment of the present application, in order to monitor the running state of each objective function in the hybrid mobile application and improve the page stuck problem, on one hand, in the development process of the hybrid mobile application, referring to the watchdog program, a timer is implemented, and the timer is started along with the start of the hybrid mobile application, and is used for periodically and circularly timing according to the above-mentioned set duration threshold. The starting of the timer needs to occupy CPU resources, and the timer can be suspended, i.e. the CPU resources can be released, and the CPU can execute other functions during the timing period after the starting of the timer, wherein the CPU resources refer to the CPU resources of the mobile terminal running the hybrid mobile application. During the period that the timer is suspended, if the interactive control on the page provided by the hybrid mobile application is triggered by a user (for example, the interactive control is clicked, long pressed or double clicked, etc.), the CPU responds to the triggering operation of the interactive control on the page, generates a page request corresponding to the triggered interactive control, and executes an objective function corresponding to the page request, that is, the CPU executes the objective function until the running of the objective function is completed, and the CPU resource is not released.
It should be noted that, if the timer reaches the set duration threshold, but the CPU resource is not released, the timer will be in a suspended state because the CPU resource cannot be obtained, and will not be called back until the CPU resource can be obtained again. However, the timer may be continuously timed during the suspension period, which may happen when the actual timing time of the timer is longer than the set duration threshold, some functions or events bound with the timer may be executed when the timer is called back, and of course, the timer may not be bound with other events or functions, in this embodiment, when the timer is called back, the timer may end the task of the present round of timing and continue to perform the next round of timing, thereby realizing cycle timing, and by means of cycle timing, it may be continuously monitored during the running period of the hybrid mobile application, which objective functions are executed when the execution of each objective function may cause page jam. It should be noted that, the execution body of the hybrid mobile application state monitoring method provided in this embodiment may be a mobile terminal running the hybrid mobile application, or may be a test mobile terminal, or may be a development end of the hybrid mobile application, that is, after the hybrid mobile application is obtained, no matter in which stage, any device capable of running the hybrid mobile application may monitor the running state of the hybrid mobile application by using the method provided in the embodiment of the present application.
Specifically, when the hybrid mobile application is started, a timer is started, and the timer is cycled and timed according to a set duration threshold. The CPU of the mobile terminal may sequentially execute functions included in the hybrid mobile application in a single-threaded manner, and the sequentially executed functions include a timer and an objective function. Alternatively, the timer may belong to a function included in the hybrid mobile application, but not to a system function, in which case the timer would start with the start of the hybrid mobile application, or the timer may be implemented separately from the hybrid mobile application, but associated with the hybrid mobile application, and needs to be able to start with the start of the hybrid mobile application and be able to cycle the timing during the operation of the hybrid mobile application. During each timing period of the timer, the CPU sequentially executes the triggered objective functions in a single-thread mode, and record codes are inserted into the objective functions, so that the record codes are executed together during the execution period of the objective functions, and therefore the execution time of the objective functions, identification information and other information can be recorded by using the record codes inserted into the objective functions, and the identification information can be information which can uniquely identify the objective functions, such as class names, method names and the like of the objective functions. Taking rendering function render () as an example, the partial program code before the plug-in and the corresponding program code after the plug-in are given as follows:
Before the insertion:
render(){
if(this.state.isError){
return this.renderErrorView();
}
return this.renderViews();
}
after the plug-in mounting:
render(){
global. CallStack. Unshift (new Date (). GetTime () + class name + method name)
if(this.state.isError){
return this.renderErrorView();
}
return this.renderViews();
}
Compared with the corresponding program code after the insertion, the partial program code before the insertion is added with a statement of global/callStack/unshifted (new Date (). GetTime () + class name+method name), and the statement is used for recording the execution time, class name and method name of the current execution function. Note that, the name of the record code is not limited to global. Callstack. Unshift (), but is merely an example, and the name of the record code may be specifically defined according to the application requirement.
In an alternative embodiment, the record code may be located before the subject code of the objective function or at the start position of the objective function, as shown in the above code example, the code position where the "global. Callstack. Unshift (newDate (). GetTime () + class name+method name)" statement starts in the render (), but is not limited thereto. Based on the method, the execution time and the identification information of the objective function are recorded by using the record codes inserted in the objective function, wherein when the objective function is triggered, the record codes are executed before the main body codes of the objective function are executed, the execution time of the objective function and the class names and the method names corresponding to the objective function are acquired and recorded by the record codes in the execution state, and the class names and the method names form the identification information of the objective function. The method name is the name of the objective function, and the class name corresponding to the objective function can be the name of a folder storing the objective function.
In this embodiment, when the timer is called back each time, the actual timing duration of each time of the timer may be obtained, and the actual timing duration of the timer may be compared with a duration threshold set by the timer, where the actual timing duration represents a total running duration of one or more objective functions executed during the time that the timer is suspended, the duration threshold reflects a maximum waiting time that can be sustained by the user from when the user triggers the page request to when the response data is output to the user, and details regarding the duration threshold may be found in the foregoing embodiments, and will not be described in detail herein. If the actual timing time length is greater than the time length threshold, the page clamping phenomenon possibly occurs in the running process of the hybrid mobile application, the identification information of the objective function executed in the actual timing time length can be determined according to the execution time of each objective function recorded by the recording codes in each objective function, and the identification information of the objective function executed in the actual timing time length greater than the time length threshold is output for analyzing the page response state of the hybrid mobile application. The objective functions executed in the actual timing duration greater than the duration threshold are objective functions that cause the actual timing duration of the timer to be greater than the duration threshold (simply referred to as timing timeout), which means that the running duration of the objective functions may be long to some extent, that is, the response time of the objective functions to the page request is long, so that the identification information of the objective functions may be output for analyzing the page response state of the hybrid mobile application by starting from the objective functions. It should be noted that these objective functions may be functions that affect the page response state of the hybrid mobile application, and finally whether the functions that actually affect the page response state of the hybrid mobile application may be determined through further analysis manually. For example, if the actually executed objective function includes two or more than two objective functions during the period in which the timer is suspended, the total operation duration of the two or more than two objective functions constitutes the actual operation duration of the timer, in which case, if the actual operation duration is greater than the set duration threshold, it does not mean that the operation duration of each objective function is necessarily greater than the duration threshold, only rough judgment may be made that the objective functions may have an effect on the page response status of the hybrid mobile application, and further, the actual operation duration of each objective function is combined as an accurate judgment.
In an alternative embodiment, the execution time and the identification information of the objective function executed by recording in a circular linked list, the circular linked list is a chain storage structure, and is characterized in that the pointer field of the last node in the list points to the head node, and the whole linked list forms a ring. Alternatively, the circular linked list in the embodiment of the present application may be a single circular linked list, where the pointer field NULL of the terminal node is changed to point to the header node or the start node. The method and the device can accelerate the adding, searching, replacing, storing and other processes of the data information by using the circular linked list, and improve the processing efficiency of the data information. Based on the method, the execution time and the identification information of the objective function are recorded by using the record codes inserted in the objective function, wherein the execution time and the identification information of the objective function to be recorded currently are directly recorded into the circular linked list by the record codes in the execution state when the circular linked list is not full, the execution time and the identification information of at least one objective function recorded in the circular linked list are deleted according to the early and late of the execution time when the circular linked list is full, and the execution time and the identification information of the objective function to be recorded currently are recorded into the circular linked list by the record codes in the execution state. In this embodiment, when the circular linked list is full, the execution time and the identification information of at least one objective function whose execution time is previous are deleted. For example, when the circular linked list is full, 10 objective functions that have been completed and have different execution times are recorded, and the 10 objective functions are time-sequentially arranged as an objective function 1 and an objective function 2. In addition, the objective function 11 is in an execution state. Then the execution time and the execution information of the objective function 1 with the earliest execution time recorded in the circular linked list are deleted, and the execution time and the identification information of the objective function 11 in the execution state are recorded in the circular linked list.
Further, in the embodiment, the recorded execution time of the objective function may include an execution start time and an execution end time of the objective function, based on which the application running state monitoring method further includes determining an execution duration of the objective function according to the execution start time and the execution end time of the objective function, and when the identification information of the objective function executed in the actual timing duration greater than the duration threshold is output, outputting the execution duration of the objective function executed in the actual timing duration greater than the duration threshold together for analyzing the page response state of the hybrid mobile application. Based on the execution time of each objective function, a developer can conveniently and quickly locate which specific function causes page clamping. For example, each objective function has an expected execution duration, and when its actual execution duration is longer than its expected execution duration, the objective function may be considered problematic, either in terms of code logic, code redundancy, etc. Or comparing the actual execution time length of each objective function, and preferentially analyzing the problems of partial objective functions with longer execution time length, and further analyzing the problems of the objective functions with shorter execution time length only under the condition that the objective functions with longer execution time length have no problems, thereby reducing the number of code analysis, being beneficial to reducing the workload of developers and improving the efficiency of positioning the problem objective functions.
In this embodiment, when the development end develops the hybrid mobile application, the code instrumentation tool may be used to plug in the record code before the main code of each objective function, for example, the start position in the compiling process of the source program code corresponding to the hybrid mobile application. The code instrumentation tool is used for inserting program codes at specified positions of programs to be instrumented so as to perform tasks such as statistics, measurement, debugging, tracking and the like, and for example, the code instrumentation tool can be a BABEL instrumentation tool, a PIN dynamic instrumentation tool, an embedded program instrumentation tool based on GCC and the like. It should be noted that, before the body code of each objective function, in addition to the plug-in record code, a code for implementing other functions may be also plugged in, for example, a function code for setting a length of a circular linked list, and a method for implementing the plug-in other function codes is similar to a method for implementing the plug-in record code, which is not described herein.
Further, in compiling source program codes corresponding to the hybrid mobile application, the code instrumentation tool is utilized to plug in record codes before the main code of each objective function, and the method can be realized by carrying out Syntax analysis and semantic analysis on the source program codes corresponding to the hybrid mobile application to obtain an abstract Syntax tree corresponding to the hybrid mobile application, wherein in the embodiment, the abstract Syntax tree (Abstract Syntax Tree, AST) or simply called Syntax tree (Syntax tree) is an abstract representation of a Syntax structure of the source code, the Syntax structure of a programming language is represented in a tree form, and each node on the tree represents one structure of the source codes. The abstract syntax tree at least comprises a plurality of function nodes, each function node represents a function contained in source program codes, the plurality of function nodes on the abstract syntax tree are subjected to type analysis according to a classification principle of whether page requests are responded or not so as to obtain target function nodes responding to the page requests, the target function nodes correspond to target functions, and when the target function nodes on the abstract syntax tree are compiled, a code instrumentation tool is used for instrumentation of record codes before main codes of the target functions corresponding to the target function nodes.
Further, the application running state monitoring method further comprises the steps of predicting page response time acceptable to the user by using a performance model taking the user as a core, and determining a duration threshold of the timer according to the page response time acceptable to the user. The page response time acceptable to the user, that is, the maximum response time allowed by the above-mentioned jam phenomenon, may occur after the maximum response time exceeds the maximum response time. In this embodiment, a Response (Load) performance model may be used to analyze and determine a duration threshold of a timer adapted to the hybrid mobile application, after a user triggers a requirement, the corresponding objective function is executed in Response to the user's trigger requirement, and the timer records the execution duration, if a page Response is received within the duration threshold, the user does not feel a page clamping phenomenon, thereby improving the performance and user experience of the hybrid mobile application. In this embodiment, the RAIL performance model analysis determines that the duration threshold set by the timer may be 100ms or other duration thresholds.
According to the technical scheme provided by the embodiments of the application, aiming at the mixed mobile application supporting single-thread operation, in order to monitor the operation state of the mixed mobile application, a timer with a set duration threshold and a cyclic timing function is realized in the mixed mobile application, during each timing period of the timer, the triggered objective functions are sequentially executed in a single-thread mode, meanwhile, the identification information of the objective functions executed during each timing period of the timer and the execution time of the objective functions are recorded by using the record codes inserted in the objective functions in advance, and when the timer is called back each time, the identification information of the objective functions executed in the actual timing duration can be obtained by combining the actual timing duration of the timer, wherein the objective functions can be functions which cause page clamping of the mixed mobile application, and the page clamping condition of the mixed mobile application can be analyzed by the objective functions so as to optimize the objective functions which cause page clamping of the mixed mobile application, thereby improving the page performance and customer experience of the mixed mobile application.
Fig. 2 is a schematic structural diagram of an application running state monitoring device according to an exemplary embodiment of the present application. As shown in fig. 2, the apparatus includes:
A starting module 21, configured to start a timer when starting the hybrid mobile application, where the timer is configured to cycle and time according to a set duration threshold, and the hybrid mobile application includes a plurality of objective functions for responding to the page request;
An execution module 22, configured to sequentially execute the triggered objective functions during each timing of the timer in a single-threaded manner, and record the execution time and the identification information of the objective functions by using the record codes inserted in the objective functions;
The obtaining module 23 is configured to obtain an actual timing duration of each time when the timer is called back each time, and determine, according to the recorded execution time of each objective function, identification information of the objective function executed in the actual timing duration if the actual timing duration is greater than a duration threshold;
an output module 24 for outputting identification information of the objective function performed during the actual timing duration greater than the duration threshold for analyzing the page response status of the hybrid mobile application.
Further, the execution module 22 is configured to execute the record code at the start position before the main body code of the objective function is executed when the objective function is triggered, and acquire and record the execution time of the objective function and the class name and method name corresponding to the objective function from the record code in the execution state, where the class name and method name form the identification information of the objective function.
Further, the execution module 22 is specifically configured to record the execution time and the identification information of the objective function by the record code in the execution state directly into the circular linked list when the circular linked list is not full, delete the execution time and the identification information of at least one of the objective functions recorded in the circular linked list according to the early and late times of the execution time when the circular linked list is full, and record the execution time and the identification information of the objective function to be recorded into the circular linked list by the record code in the execution state when the circular linked list is not full.
Further, the execution time of the objective function comprises an execution start time and an execution end time of the objective function, and the application running state monitoring device further comprises a determining module, which is used for determining the execution time of the objective function according to the execution start time and the execution end time of the objective function, and an output module 24, which is also used for outputting the execution time of the objective function to be executed in the actual timing time greater than the time threshold together when the identification information of the objective function executed in the actual timing time greater than the time threshold is output, so as to analyze the page response state of the hybrid mobile application.
The application running state monitoring device further comprises an inserting module, a code inserting tool and a code processing module, wherein the inserting module is used for inserting record codes before the main body codes of all the objective functions in the compiling process of source program codes corresponding to the mixed mobile application.
The method comprises the steps of obtaining an abstract syntax tree corresponding to a hybrid mobile application by carrying out grammar analysis and semantic analysis on source program codes corresponding to the hybrid mobile application in the process of compiling the source program codes corresponding to the hybrid mobile application, carrying out type analysis on the function nodes on the abstract syntax tree according to a classification principle of whether page requests are responded or not so as to obtain target function nodes responding to the page requests, wherein the target function nodes correspond to target functions, and carrying out type analysis on the target function nodes on the abstract syntax tree by using a code instrumentation tool before the main body codes of the target functions corresponding to the target function nodes when compiling the target function nodes on the abstract syntax tree.
Further, the determining module is further used for predicting the page response time acceptable to the user by using the performance model taking the user as a core, and determining the duration threshold of the timer according to the page response time acceptable to the user.
The principles of the specific implementation of each module or unit and the detailed implementation of each step in the embodiments of the present application may be referred to the description of the same or corresponding steps in the foregoing, which is not repeated herein.
Fig. 3 is a schematic structural diagram of a mobile terminal according to an embodiment of the present application. As shown in fig. 3, the mobile terminal includes a memory 30a and a processor 30b, the memory 30a is used for storing target program codes corresponding to the hybrid mobile application, and the processor 30b is coupled to the memory 30a and is used for executing the target program codes for implementing the steps in the above application running state monitoring method, wherein the target program codes are compiled from source program codes corresponding to the hybrid mobile application. Specifically, the processor 30b is configured to perform the following steps:
Starting a timer when starting the hybrid mobile application, wherein the timer circularly times according to a set duration threshold, and the hybrid mobile application comprises a plurality of objective functions for responding to the page request;
Sequentially executing the triggered objective functions in a single-thread mode during each timing period of the timer, and recording the execution time and identification information of the objective functions by using the record codes inserted in the objective functions;
when the timer is called back each time, acquiring actual timing time length of the timer each time, if the actual timing time length is larger than a time length threshold value, determining identification information of the objective function executed in the actual timing time length according to the recorded execution time of each objective function;
And outputting the identification information of the objective function executed in the actual timing time length greater than the time length threshold value for analyzing the page response state of the hybrid mobile application.
Further, the record code is located before the main code of the objective function, and when the record code is used for recording the execution time and the identification information of the objective function by using the record code inserted in the objective function, the processor 30b is specifically configured to execute the record code before executing the main code of the objective function when the objective function is triggered, and acquire and record the execution time of the objective function and the class name and the method name corresponding to the objective function by the record code in the execution state, where the class name and the method name form the identification information of the objective function.
Further, the processor 30b is specifically configured to record the execution time and the identification information of the objective function by the record code in the execution state directly into the circular linked list when the circular linked list is not full, delete the execution time and the identification information of at least one of the objective functions recorded in the circular linked list according to the early and late times of the execution time when the circular linked list is full, and record the execution time and the identification information of the objective function to be recorded directly into the circular linked list by the record code in the execution state when the circular linked list is not full.
Further, the execution time of the objective function includes an execution start time and an execution end time of the objective function, based on which the processor 30b is further configured to determine an execution duration of the objective function according to the execution start time and the execution end time of the objective function, and when outputting the identification information of the objective function executed within the actual timing duration greater than the duration threshold, output together the execution duration of the objective function to be executed within the actual timing duration greater than the duration threshold for analyzing the page response status of the hybrid mobile application.
Further, the processor 30b is further configured to insert the record code before the subject code of each objective function by using the code insertion tool in compiling the source program code corresponding to the hybrid mobile application.
Further, the processor 30b is specifically configured to, when executing compiling process for source program codes corresponding to a hybrid mobile application, execute syntax analysis and semantic analysis for the source program codes corresponding to the hybrid mobile application to obtain an abstract syntax tree corresponding to the hybrid mobile application, where each abstract syntax tree includes at least a plurality of function nodes, each function node represents a function included in the source program codes, execute type analysis for the plurality of function nodes on the abstract syntax tree according to a classification rule of whether to respond to a page request, so as to obtain an objective function node responding to the page request, where the objective function node corresponds to an objective function, and execute, when compiling to the objective function node on the abstract syntax tree, executing embedding the record code by using the code instrumentation tool before the main code of the objective function corresponding to the objective function node.
Further, the processor 30b is further configured to predict a user acceptable page response time using the user-centric performance model, and determine a duration threshold of the timer based on the user acceptable page response time.
Further, as shown in FIG. 3, the mobile terminal also includes a display 30c, a communication component 30d, a power component 30e, an audio component 30f, and other components. Only some of the components are schematically shown in fig. 3, which does not mean that the electronic terminal comprises only the components shown in fig. 3. The electronic terminal of the embodiment can be implemented as a mobile terminal such as a desktop computer, a notebook computer, a smart phone or an IOT device.
The principles of the specific implementation of each module or unit and the detailed implementation of each step in the embodiments of the present application may be referred to the description of the same or corresponding steps in the foregoing, which is not repeated herein.
The embodiments of the present application also provide a computer-readable storage medium storing a computer program, which when executed by a processor, causes the processor to implement the steps in the above-described application running state monitoring method. Specifically, the processor is configured to perform the steps of:
Starting a timer when starting the hybrid mobile application, wherein the timer circularly times according to a set duration threshold, and the hybrid mobile application comprises a plurality of objective functions for responding to the page request;
Sequentially executing the triggered objective functions in a single-thread mode during each timing period of the timer, and recording the execution time and identification information of the objective functions by using the record codes inserted in the objective functions;
when the timer is called back each time, acquiring actual timing time length of the timer each time, if the actual timing time length is larger than a time length threshold value, determining identification information of the objective function executed in the actual timing time length according to the recorded execution time of each objective function;
And outputting the identification information of the objective function executed in the actual timing time length greater than the time length threshold value for analyzing the page response state of the hybrid mobile application.
Further, the record code is located before the main body code of the objective function, and when the record code is used for recording the execution time and the identification information of the objective function by utilizing the record code inserted in the objective function, the processor is specifically used for executing the record code before executing the main body code of the objective function when the objective function is triggered, and acquiring and recording the execution time of the objective function and the class name and the method name corresponding to the objective function by the record code in an execution state, wherein the class name and the method name form the identification information of the objective function.
Further, the processor is used for recording the execution time and the identification information of the objective function by using the record code inserted in the objective function, and is particularly used for directly recording the execution time and the identification information of the objective function to be recorded currently into the circular linked list by the record code in the execution state under the condition that the circular linked list is not full, deleting the execution time and the identification information of at least one recorded objective function in the circular linked list according to the early and late times of the execution time under the condition that the circular linked list is full, and recording the execution time and the identification information of the objective function to be recorded currently into the circular linked list by the record code in the execution state.
Further, the execution time of the objective function includes an execution start time and an execution end time of the objective function, and the processor is further configured to determine an execution duration of the objective function according to the execution start time and the execution end time of the objective function, and when outputting the identification information of the objective function executed in the actual timing duration greater than the duration threshold, output together the execution duration of the objective function to be executed in the actual timing duration greater than the duration threshold, so as to analyze the page response state of the hybrid mobile application.
Further, the processor is further configured to insert the record code before the body code of each objective function by using the code insertion tool in the compiling process of the source program code corresponding to the hybrid mobile application.
Further, the processor is used for carrying out grammar analysis and semantic analysis on the source program codes corresponding to the hybrid mobile application to obtain an abstract grammar tree corresponding to the hybrid mobile application when the code instrumentation tool is used for instrumentation of record codes before the main body codes of all target functions in the compiling process of the source program codes corresponding to the hybrid mobile application, wherein the abstract grammar tree at least comprises a plurality of function nodes, each function node represents one function contained in the source program codes, the plurality of function nodes on the abstract grammar tree are subjected to type analysis according to a classification principle of whether page requests are responded or not so as to obtain the target function nodes responding to the page requests, the target function nodes correspond to the target functions, and the code instrumentation tool is used for instrumentation of record codes before the main body codes of the target functions corresponding to the target function nodes when the target function nodes on the abstract grammar tree are compiled.
Further, the processor is also used for predicting the page response time acceptable to the user by using the performance model taking the user as a core, and determining the duration threshold of the timer according to the page response time acceptable to the user.
The principles of the specific implementation of each module or unit and the detailed implementation of each step in the embodiments of the present application may be referred to the description of the same or corresponding steps in the foregoing, which is not repeated herein.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and variations of the present application will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. which come within the spirit and principles of the application are to be included in the scope of the claims of the present application.