Operation time consumption determination method and device and electronic equipment
By using kernel objects to count system calls, combined with hook functions and sliding window technology, the problems of high resource consumption and high false positive rate of traditional monitoring methods are solved, and accurate monitoring of operation time is achieved without increasing hardware costs.
Patent Information
- Application Number
- CN202511304348.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-12
- Publication Date
- 2025-12-16
Smart Images

Figure CN121144142A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers, and in particular to an operation time consumption determination method and device and electronic equipment. BACKGROUND
[0002] Graphical interface software needs to obtain performance experience data (such as operation time consumption) of real users, but the traditional code embedding method cannot accurately reflect the actual operation time, so a scheme of collecting video information and then analyzing each frame is often used.
[0003] This scheme involves a large number of picture operations and has high performance requirements. To avoid affecting the actual running performance of the software, the mainstream approach is to deploy two machines: one machine is responsible for screen recording and analysis, and the other machine is used for actual operation by the user, which directly increases the cost of hardware deployment. SUMMARY
[0004] To solve the technical problem of increasing the cost of hardware deployment in the prior art, embodiments of the present application provide an operation time consumption determination method and device, electronic equipment and storage medium. The specific technical solutions are as follows:
[0005] In a first aspect of the embodiments of the present application, an operation time consumption determination method is first provided, and the method comprises:
[0006] obtaining a starting time of a target operation, and obtaining a first call number at each time within a preset time;
[0007] The first call number is a first call number of a first callback function counted by a kernel object, and a process in the software to be monitored calls the first callback function once for each system call;
[0008] According to a call number information set established by using the first call number, the operation time consumption of the target operation is determined.
[0009] In an optional embodiment, the process performs the following steps to obtain the first call number:
[0010] loading a first hook function, so that the first hook function performs the following operations: registering a first callback function corresponding to the process;
[0011] triggering the call of the first callback function once for each system call; wherein the first call number of the first callback function is counted by a kernel object, and the first call number represents the busy degree of the software to be monitored.
[0012] In an optional embodiment, the first hook function further performs the following operations:
[0013] injecting a second hook function into a first function for creating a new process, the first function corresponding to the process.
[0014] In an optional implementation, the process further performs the following steps to obtain a total number of calls:
[0015] calling the first function, creating a child process of the process, and injecting the first hook function into the child process through the second hook function injected in the first function;
[0016] wherein the child process loads the first hook function, so that the first hook function performs the following operations: registering a second callback function corresponding to the child process, and injecting a second hook function into a second function for creating a new process, the second function corresponding to the child process.
[0017] The second callback function is called once every time the child process calls a system call, and a kernel object counts a second number of calls of the second callback function and adds the second number of calls to the first number of calls to obtain a total number of calls, the total number of calls representing a busy degree of the software to be monitored.
[0018] In an optional implementation, the kernel object finds a busy level corresponding to the first number of calls or the total number of calls, the busy level representing the busy degree of the software to be monitored.
[0019] In an optional implementation, the first number of calls at each time point in a preset time is obtained, including:
[0020] The first number of calls at each time point in a preset time after the start time point is obtained from the kernel object.
[0021] In an optional implementation, an operation duration of a target operation is determined according to a call number information set established by using the first number of calls, including:
[0022] A call number information set is established according to the first number of calls at each time point in the preset time.
[0023] An end time point of the target operation is determined according to the call number information set, and an operation duration of the target operation is determined according to the start time point and the end time point.
[0024] In an optional implementation, the end time point of the target operation is determined according to the call number information set, including:
[0025] A second derivative of the first number of calls at each time point in the call number information set is performed to obtain a call number change amplitude information set.
[0026] According to the call frequency change range information set, an ending time of the target operation is determined.
[0027] In an optional embodiment, the determining of the ending time of the target operation according to the call frequency change range information set comprises:
[0028] controlling a sliding window to slide on the call frequency change range information set until an average value of the call frequency change range in the sliding window is less than a preset threshold value for the first time, and stopping the sliding;
[0029] According to the call frequency change range in the sliding window, the ending time of the target operation is determined.
[0030] In an optional embodiment, the determining of the ending time of the target operation according to the call frequency change range in the sliding window comprises:
[0031] finding a time corresponding to the first call frequency change range in the sliding window, and determining the time as the ending time of the target operation.
[0032] In a second aspect of the embodiments of the present application, an operation time consumption determination device is further provided, and the device comprises:
[0033] a frequency obtaining module, configured to obtain a starting time of a target operation, and obtain a first call frequency at each time within a preset time;
[0034] The first call frequency is a first call frequency of a first callback function counted by a kernel object, and a process in the software to be monitored calls the first callback function once for each call of a system call.
[0035] a time consumption determination module, configured to determine an operation time consumption of the target operation according to a call frequency information set established by using the first call frequency.
[0036] In an optional embodiment, the process performs the following steps to obtain the first call frequency.
[0037] loading a first hook function, so that the first hook function performs the following operation: registering a first callback function corresponding to the process;
[0038] triggering the first callback function once for each call of a system call, wherein a first call frequency of the first callback function is counted by a kernel object, and the first call frequency represents a busy degree of the software to be monitored.
[0039] In an optional embodiment, the first hook function further performs the following operation:
[0040] injecting a second hook function into a first function for creating a new process, the first function corresponding to the process.
[0041] In an optional implementation, the process further performs the following steps to obtain a total number of calls:
[0042] calling the first function, creating a child process of the process, and injecting the first hook function into the child process through the second hook function injected in the first function;
[0043] wherein the child process loads the first hook function, so that the first hook function performs the following operations: registering a second callback function corresponding to the child process, and injecting a second hook function into a second function for creating a new process, the second function corresponding to the child process.
[0044] The second callback function is called once every time the child process calls a system call, and a kernel object counts a second number of calls of the second callback function and adds the second number of calls to the first number of calls to obtain a total number of calls, the total number of calls representing a busy degree of the software to be monitored.
[0045] In an optional implementation, the kernel object finds a busy level corresponding to the first number of calls or the total number of calls, the busy level representing the busy degree of the software to be monitored.
[0046] In an optional implementation, the number of times obtaining module is specifically configured to:
[0047] obtain, from the kernel object, the first number of calls at each time within a preset time after the start time.
[0048] In an optional implementation, the time consumption determining module specifically includes:
[0049] an information set establishing submodule configured to establish a call number information set according to the first number of calls at each time within the preset time;
[0050] a time determining submodule configured to determine an end time of the target operation according to the call number information set;
[0051] a time consumption determining submodule configured to determine an operation time consumption of the target operation according to the start time and the end time.
[0052] In an optional implementation, the time determining submodule specifically includes:
[0053] an information set generating unit configured to perform second-order derivation on the first number of calls at each time in the call number information set to obtain a call number change amplitude information set;
[0054] a time point determination unit configured to determine an ending time point of the target operation according to the set of call number change amplitude information.
[0055] In an optional implementation, the time point determination unit specifically includes:
[0056] a sliding sub-unit configured to control a sliding window to slide on the set of call number change amplitude information until the average value of the call number change amplitudes in the sliding window is less than a preset threshold for the first time, and stop the sliding;
[0057] a time point determination sub-unit configured to determine an ending time point of the target operation according to the call number change amplitudes in the sliding window.
[0058] In an optional implementation, the time point determination sub-unit is specifically configured to:
[0059] search for a time point corresponding to the first call number change amplitude in the sliding window, and determine the time point as the ending time point of the target operation.
[0060] In a third aspect of the embodiments of the present application, an electronic device is further provided, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus.
[0061] the memory is configured to store a computer program;
[0062] the processor is configured to execute the program stored on the memory, and implement the operation time determination method in any of the first aspect.
[0063] In a fourth aspect of the embodiments of the present application, a storage medium is further provided, and the storage medium stores instructions, when the instructions run on a computer, the computer executes the operation time determination method in any of the first aspect.
[0064] In a fifth aspect of the embodiments of the present application, a computer program product including instructions is further provided, when the instructions run on a computer, the computer executes the operation time determination method in any of the first aspect.
[0065] The technical scheme provided in the embodiments of the present application acquires a starting time point of a target operation, acquires a first call number of each time point in a preset time, wherein the first call number is a first call number of a first callback function counted by a kernel object, and a process in the software to be monitored calls the first callback function once for each call of a system call, and determines an operation time of the target operation according to a call number information set established by using the first call number.
[0066] The first calling times of each time point in a preset time are acquired to establish a calling time information set, and the operation time consumption of the target operation is determined according to the calling time information set, so that the operation time consumption can be determined without increasing the hardware deployment cost. BRIEF DESCRIPTION OF DRAWINGS
[0067] The accompanying drawings, which are incorporated herein and form part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles of the application.
[0068] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings required to be used in the embodiments or prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without creative labor.
[0069] One or more embodiments are exemplarily illustrated by pictures in the drawings corresponding thereto, and these exemplary illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, unless otherwise specified. The drawings in the drawings do not constitute a proportional limitation.
[0070] Figure 1 An implementation flowchart of the operation time consumption determination method shown in the embodiments of the present application is shown.
[0071] Figure 2 An implementation flowchart of the software monitoring method shown in the embodiments of the present application is shown.
[0072] Figure 3 An implementation flowchart of another software monitoring method shown in the embodiments of the present application is shown.
[0073] Figure 4 An implementation flowchart of another operation time consumption determination method shown in the embodiments of the present application is shown.
[0074] Figure 5 An implementation flowchart of another operation time consumption determination method shown in the embodiments of the present application is shown.
[0075] Figure 6 A structure diagram of an operation time consumption determination device shown in the embodiments of the present application is shown.
[0076] Figure 7 A structure diagram of an electronic device shown in the embodiments of the present application is shown. DETAILED DESCRIPTION
[0077] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0078] The following disclosure provides numerous different embodiments or examples for implementing various structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.
[0079] like Figure 1 The diagram shown is a flowchart illustrating the implementation of an operation time determination method provided in this application embodiment. This method is applied to a monitoring platform and may specifically include the following steps:
[0080] S101, obtain the start time of the target operation, and obtain the first call count at each time within the preset time.
[0081] In this embodiment of the application, for the software to be monitored, a user can perform a target operation within the software, such as clicking a button. The start time of the user performing the target operation in the software is recorded, thus obtaining the start time of the target operation. Alternatively, if a target operation is performed in the software and this operation triggers a monitoring event, the trigger time will be recorded as the start time.
[0082] Furthermore, in this embodiment, the first call count at each moment within a preset time period is obtained, which can be obtained from the kernel object. It should be noted that the time unit recorded here is, for example, a hundred nanoseconds (the time unit obtained from the operating system API).
[0083] The first call count is the number of times the first callback function is called by the kernel object. The first callback function is called once for each system call made by the process in the software to be monitored.
[0084] S102, determine the operation time of the target operation based on the call count information set established using the first call count.
[0085] In the embodiment of the present application, for the first call number of each time within the preset time obtained above, a call number information set can be established according to the first call number of each time within the preset time. The call number information set can be embodied in a call number curve or a chart analysis set.
[0086] Taking the call number curve as an example, it should be noted that, for the first call number of each time within the preset time, a call number curve can be established with time as the X-axis and the call number as the Y-axis. In this way, the corresponding time is taken as the X-axis coordinate value, and the first call number of the corresponding time is taken as the Y-axis coordinate value.
[0087] For the call number information set established above, the end time of the target operation can be determined according to the call number information set. In this way, the start time and the end time of the target operation can be known, and the operation time of the target operation can also be determined according to the start time and the end time.
[0088] Through the description of the technical solutions provided by the embodiments of the present application above, the start time of the target operation is obtained, the first call number of each time within the preset time is obtained, the first call number is the first call number of the first callback function counted by the kernel object, and the process in the software to be monitored calls the first callback function once for each system call. The operation time of the target operation is determined according to the call number information set established by using the first call number.
[0089] The call number information set is established according to the first call number of each time within the preset time obtained, and the operation time of the target operation is determined according to the call number information set. In this way, the operation time can be determined without increasing the hardware deployment cost.
[0090] In addition, the software running busy degree monitoring method based on professional performance tools in the prior art has two limitations: first, the additional resource consumption of the tool itself will affect the running efficiency of the monitored system, which is particularly prominent in resource-intensive scenarios; second, it is difficult to accurately reflect the actual busy state by relying on a single indicator such as CPU occupancy or memory usage, because there may be a nonlinear relationship between resource occupancy and task processing intensity, which is easy to misjudge.
[0091] Therefore, by counting the first call number of the first callback function by the kernel object, the call number of the system call is equivalent to counting the call number of the process to the system call, which can well reflect the busy degree of the software to be monitored. In this way, an accurate and resource-consuming way is realized, and the busy degree of the software to be monitored can be obtained.
[0092] Based on this, as Figure 2As shown in the figure, an embodiment of the software monitoring method provided in the application is an implementation flowchart of a software monitoring method, which is applied to a process in the software to be monitored. The process is injected with a first hook function in a starting or running state, and can specifically include the following steps:
[0093] In S201, the first hook function is loaded, so that the first hook function performs the following operation: registering a first callback function corresponding to the process.
[0094] In the embodiment of the application, for the software to be monitored, a process in the software to be monitored can be determined, which is a process that needs to be monitored, and the process can be a main process or any process in the software to be monitored, which is not limited in the embodiment of the application.
[0095] For the process in the software to be monitored, the first hook function can be injected into the process in an active or passive form in the case that the process is in a starting or running state, so that the process is injected with the first hook function in the case that the process is in a starting or running state.
[0096] It should be noted that for the first hook function, it can be a plug-in, for example, the first hook function is named NirvanaHook, and the process in the software to be monitored is injected with NirvanaHook in the case that the process is in a starting or running state; or the hook function can be an extension point of a code framework, which is not limited in the embodiment of the application.
[0097] So for the process in the software to be monitored, the first hook function is injected into the process in the case that the process is in a starting or running state, and then the first hook function can be loaded, so that the first hook function performs the following operation: registering a first callback function corresponding to the process.
[0098] It should be noted that for the first callback function, it can be an Instrumentation callback function (also known as a "plug-in callback function"), which is a special function used to insert custom logic at specific event points (such as function calls, exception throws, variable assignments, etc.) during program execution, to achieve the purpose of monitoring, debugging, performance analysis or behavior modification, without the need to directly modify the target code.
[0099] In addition, for the way of injecting the first hook function into the process, it can be DLL injection (the most common way), by injecting a DLL containing the first hook function into the process, and using the DLL main function or exported function to execute the first hook function logic, which is not limited in the embodiment of the application.
[0100] S202, triggering the invocation of the first callback function once per invocation of the system call, wherein the first number of invocations of the first callback function is counted by the kernel object, and the first number of invocations represents the busy degree of the software to be monitored.
[0101] In the embodiments of the present application, the number of invocations of the system call of the process can be monitored by using the callback mechanism of the operating system, because the callback function is invoked once after the process completes the invocation of the system call each time, and the number of invocations of the callback function can be counted, which is equivalent to counting the number of invocations of the system call, and the number of invocations of the system call generally represents the busy degree; for example, the number of invocations of the system call (syscall) of the process can be monitored by using the Instrumentation callback mechanism of the operating system, because the Instrumentation callback function is invoked once after the process completes the invocation of the system call (syscall) each time, and the number of invocations of the Instrumentation callback function can be counted, which is equivalent to counting the number of invocations of the system call (syscall), and the number of invocations of the system call (syscall) generally represents the busy degree.
[0102] Based on this, for the process in the software to be monitored, the first callback function (Instrumentation callback function) is invoked once per invocation of the system call (syscall), and at this time, a kernel object is created, which can count the first number of invocations of the first callback function (Instrumentation callback function), and the first number of invocations is equivalent to the number of invocations of the system call (syscall) of the process, and can represent the busy degree of the software to be monitored. For the kernel object, the number of invocations of the first callback function (Instrumentation callback function) can be counted at each time, so that the first number of invocations of the first callback function (Instrumentation callback function) at each time can be recorded, and the first number of invocations of the first callback function (Instrumentation callback function) at each time represents the busy degree of the software to be monitored at each time.
[0103] It should be noted that for the creation of the kernel object, a kernel object can be created by using mapofview, and the embodiments of the present application do not limit this. In addition, the system call (syscall) is essentially a standardized interface for the user state process to send a request to the kernel state. The user state program cannot directly access the kernel resource (such as hardware, core data structure), and must let the kernel perform the operation by using Syscall, which is the security mechanism of the "user state-kernel state" isolation of the operating system.
[0104] Through the description of the technical solutions provided by the embodiments of the present application, the process in the software to be monitored is injected with the first hook function in the case of being in the starting or running state, and the first hook function is loaded to enable the first hook function to perform the following operations: registering the first callback function corresponding to the process; calling the first callback function once for each call of the system call, wherein the kernel object counts the first call times of the first callback function, and the first call times represent the busy degree of the software to be monitored.
[0105] By counting the first call times of the first callback function by the kernel object, it is equivalent to counting the call times of the system call by the process, and the call times of the system call as an index can well reflect the busy degree of the software to be monitored, so as to realize an accurate and extremely small resource consumption manner to obtain the busy degree of the software to be monitored.
[0106] As shown in FIG. 1, it is an implementation flow diagram of another software monitoring method provided by the embodiments of the present application, which is applied to a process in software to be monitored. The process is injected with a first hook function in the case of being in a starting or running state, and can specifically include the following steps: Figure 3
[0107] S301, loading the first hook function to enable the first hook function to perform the following operations: registering the first callback function corresponding to the process, and injecting the second hook function into the first function for creating a new process, the first function corresponding to the process.
[0108] In the embodiments of the present application, for the software to be monitored, a process in the software to be monitored can be determined, which is the process to be monitored, and the process can be a main process or any process in the software to be monitored, which is not limited in the embodiments of the present application.
[0109] For the process in the software to be monitored, the first hook function can be injected into the process in the form of initiative or passivity in the case of the process being in the starting or running state, so that the process is injected with the first hook function in the case of being in the starting or running state.
[0110] It should be noted that for the first hook function, it can be a plug-in, for example, the first hook function is named NirvanaHook, and the process in the software to be monitored is injected with NirvanaHook in the case of being in the starting or running state; or the hook function can be an extension point of a code framework, which is not limited in the embodiments of the present application.
[0111] In the embodiments of the present application, the callback mechanism of the operating system can be used to monitor the number of invocations of the system call of the process. After the process invokes the system call each time, the callback function is invoked once. The number of invocations of the callback function can be counted, which is equivalent to counting the number of invocations of the system call. The number of invocations of the system call generally represents the degree of busy. For example, the Instrumentation callback mechanism of the operating system can be used to monitor the number of invocations of the system call (syscall) of the process. After the process invokes the system call (syscall) each time, the Instrumentation callback function is invoked once. The number of invocations of the Instrumentation callback function can be counted, which is equivalent to counting the number of invocations of the system call (syscall). The number of invocations of the system call (syscall) generally represents the degree of busy.
[0112] Meanwhile, in order to monitor all child processes of the current process, an unlimited Hook mechanism needs to be implemented. When the first hook function is actively or passively injected, the function (CreateProcess) for creating a new process is hooked. In this way, the first hook function can be injected into the child process each time the process creates a child process.
[0113] In this way, the process in the software to be monitored is injected with the first hook function in the starting or running state, and then the first hook function is loaded to enable the first hook function to perform the following operations: registering the first callback function corresponding to the process, injecting the second hook function into the first function for creating a new process, and the first function corresponding to the process.
[0114] It should be noted that the first function for creating a new process may be CreateProcess, and may also be another function for creating a new process. The embodiments of the present application do not limit this.
[0115] S302, the first callback function is triggered once each time the system call is invoked, and the first number of invocations of the first callback function is counted by the kernel object.
[0116] In the embodiments of the present application, this step is similar to the above step S202, and the embodiments of the present application will not be repeated here.
[0117] S303, the first function is invoked to create a child process of the process, and the first hook function is injected into the child process through the second hook function injected in the first function.
[0118] In the embodiment of the present application, for the software to be monitored, the user can perform a corresponding operation on the software to be monitored, for example, click a certain button, at which time the process in the software to be monitored can need to invoke a child process.
[0119] To this end, for the process in the software to be monitored, the first function for creating a new process described above can be called to create a child process of the process. During this period, since the first function for creating a new process is injected with the second hook function, the first hook function can be injected to the child process through the second hook function injected in the first function.
[0120] For the child process, the first hook function can be loaded to enable the first hook function to perform the following operations: register the second callback function corresponding to the child process, and inject the second hook function into the second function for creating a new process, the second function corresponding to the child process.
[0121] It should be noted that, for the first hook function, it can be a plug-in, for example, the first hook function is named NirvanaHook, and the child process of the process is injected with NirvanaHook when it is in a starting or running state; or the hook function can be an extension point of a code framework, and the like, which is not limited in the embodiment of the present application.
[0122] In addition, for the second function for creating a new process, it can be CreateProcess, and of course it can be other functions for creating a new process, which is not limited in the embodiment of the present application.
[0123] For the child process, each time a system call (syscall) is invoked, the second callback function (Instrumentation callback function) is invoked once, and the kernel object can count the second invocation times of the second callback function and add the first invocation times of the first callback function counted above to obtain the total invocation times, which represent the busy degree of the software to be monitored.
[0124] It should be noted that, for the kernel object, the invocation times of the first callback function (Instrumentation callback function) can be counted at each moment, and the invocation times of the second callback function (Instrumentation callback function) can be counted at each moment, so that the first invocation times of the first callback function (Instrumentation callback function) at each moment and the second invocation times of the second callback function (Instrumentation callback function) at each moment can be recorded, and the total invocation times at each moment can be obtained by adding the two, which represent the busy degree of the software to be monitored at each moment.
[0125] In addition, in the embodiments of the present application, the corresponding busy levels can be divided according to different ranges of the calling times, as shown in Table 1 below. Thus, for the kernel object, the busy level corresponding to the first calling time or the total calling time can be found, which represents the busy degree of the software to be monitored.
[0126] Call frequency range Busy level 0-5 calls / sec Very low 6-50 calls / sec Low 51-300 calls / sec Medium 301-1000 calls / sec High 1001 calls / sec Very high
[0127] Table 1
[0128] In addition, for software with a graphical interface, at present, to understand the performance experience (such as the time-consuming time of a certain operation) of the real user using the software, the way of collecting data by burying points in the code cannot necessarily obtain the real user operation time, so sometimes the scheme of collecting video information and then analyzing frame by frame is adopted, which involves a large number of picture operations and requires high performance. In order not to affect the performance of the actual operation, the scheme can only be used to detect two machines, one for recording and analysis, and the other for actual operation. Another way can monitor and analyze in real time, but the method adopted is to reduce the frame rate of the recording, such as capturing a picture once a second, which lacks accuracy and cannot record some millisecond-level operations.
[0129] Therefore, in the embodiments of the present application, the first calling time or the total calling time of each time during the running of the software to be monitored can be obtained by the above software monitoring method, that is, the calling time of the system call (syscall) at each time. According to experimental observation, when the software to be monitored performs a certain operation process, the calling time of the system call (syscall) will fluctuate obviously, and when the operation ends, the fluctuation will also tend to be flat. Thus, the fluctuation amplitude is recorded, and the starting point and the ending point of the fluctuation are judged, so that the time interval consumed by the operation can be found. Thus, compared with video monitoring, the time from the beginning to the end of the operation process of the software can be monitored at a lower cost while maintaining high accuracy.
[0130] Based on this, as shown in Figure 4 Another operation time determination method provided by the embodiments of the present application is shown in the flowchart of the implementation process of the method, which is applied to a monitoring platform and is realized based on the above software monitoring method. Specifically, the method can include the following steps:
[0131] S401, obtaining the starting time of the target operation, and obtaining the first calling time or the total calling time of each time within a preset time from the kernel object.
[0132] In the embodiment of the present application, for the software to be monitored, a user can perform a certain target operation in the software to be monitored, for example, click a certain button, at which time the starting moment of the user performing the target operation in the software to be monitored is recorded, so as to obtain the starting moment of the target operation. Alternatively, a certain target operation is performed in the software to be monitored, a behavior of the target operation triggers a monitoring event, and the triggering moment is recorded as the starting moment.
[0133] In addition, in the embodiment of the present application, the first call number or the total call number of each moment within the preset time can be obtained from the kernel object.
[0134] S402, according to the first call number or the total call number of each moment within the preset time, a call number information set is established.
[0135] In the embodiment of the present application, for the first call number or the total call number of each moment within the preset time obtained above, a call number information set can be established according to the first call number or the total call number of each moment within the preset time. The call number information set can be embodied in the form of a call number curve or a chart analysis set.
[0136] Taking the call number curve as an example, it should be noted that for the first call number or the total call number of each moment within the preset time, a call number curve can be established with time as the X-axis and the call number as the Y-axis, so that the corresponding moment is taken as the X-axis coordinate value and the first call number or the total call number of the corresponding moment is taken as the Y-axis coordinate value.
[0137] S403, according to the call number information set, the ending moment of the target operation is determined, and according to the starting moment and the ending moment, the operation time consumption of the target operation is determined.
[0138] In the embodiment of the present application, for the call number information set established above, the ending moment of the target operation can be determined according to the call number information set, so that the starting moment and the ending moment of the target operation can be known, and the operation time consumption of the target operation can also be determined according to the starting moment and the ending moment.
[0139] In addition, in the embodiment of the present application, as shown in Figure 5 FIG. 2 is a flowchart of another operation time consumption determination method provided by the embodiment of the present application, which is applied to a monitoring platform and is realized based on the software monitoring method, and can include the following steps:
[0140] S501, the starting moment of a target operation is obtained, and the first call number or the total call number of each moment within a preset time after the starting moment is obtained from a kernel object.
[0141] In the embodiment of the present application, for the software to be monitored, a user can perform a certain target operation in the software to be monitored, for example, click a certain button, at which time the starting moment of the user performing the target operation in the software to be monitored is recorded, so as to obtain the starting moment of the target operation. Alternatively, a certain target operation is performed in the software to be monitored, a behavior of the target operation triggers a monitoring event, and the triggering moment is recorded as the starting moment.
[0142] In addition, in the embodiment of the present application, the first call number or the total call number at each moment within the preset time after the starting moment can be obtained from the kernel object.
[0143] S502, establish a call number information set according to the first call number or the total call number at each moment within the preset time.
[0144] In the embodiment of the present application, this step is similar to the above step S402, and the embodiment of the present application will not be repeated here.
[0145] S503, twice differentiate the first call number or the total call number at each moment in the call number information set to obtain a call number change amplitude information set.
[0146] In the embodiment of the present application, for the call number information set established above, the first call number or the total call number at each moment in the call number information set can be twice differentiated to obtain a call number change amplitude information set, which can be embodied in the form of a call number change amplitude curve.
[0147] The first differentiation of the first call number or the total call number at each moment in the call number information set obtains a slope, that is, the call number of the system call (syscall) within a unit time, and the second differentiation is the slope of the slope, that is, the change amplitude of the call number of the system call (syscall) within a unit time, which is not limited by the embodiment of the present application.
[0148] S504, determine the ending moment of the target operation according to the call number change amplitude information set, and determine the operation time of the target operation according to the starting moment and the ending moment.
[0149] In the embodiments of the present application, for the obtained call frequency change range information set (for example, the call frequency change range graph), the end time of the target operation can be determined according to the call frequency change range information set (for example, the call frequency change range graph). In this way, the start time and the end time of the target operation can be known, and the operation time of the target operation can also be determined according to the start time and the end time.
[0150] In the X axis, the sliding window is controlled to slide on the call frequency change range information set (for example, the call frequency change range graph) according to a certain step value, and the sliding is stopped when the average value of the call frequency change range in the sliding window is less than the preset threshold for the first time. At this time, the end time of the target operation is determined according to the call frequency change range in the sliding window.
[0151] In the X axis, the sliding window is controlled to slide on the call frequency change range information set (for example, the call frequency change range graph) according to a certain step value, and the sliding is stopped when the average value of the call frequency change range in the sliding window is less than the preset threshold for the first time. At this time, the end time of the target operation is determined according to the call frequency change range in the sliding window.
[0152] It should be noted that the operation of the operating system is not completely predictable, and there will be abnormal values fluctuating in a short time. The average value method can help to exclude the influence of abnormal values. As for the sliding window, it is used to assist in determining the end time of the target operation for the monitoring platform to calculate. Generally, when the average value of the call frequency change range in the sliding window is less than the preset threshold for the first time, it represents that the operation is ended. The subsequent part of the call frequency change range information set (for example, the call frequency change range graph) can be stable or fluctuate due to other tasks of the operating system. Therefore, the sliding window is used to exclude these interference terms.
[0153] In addition, the preset threshold and the size of the sliding window can be adjusted according to actual needs to adapt to the precision of different operations, and the embodiments of the present application do not limit this.
[0154] Corresponding to the method embodiments, the embodiments of the present application also provide an operation time determination device applied to a monitoring platform, as shown in the figure, the device can include: a frequency acquisition module 610, a time determination module 620. Figure 6
[0155] The frequency acquisition module 610 is configured to acquire the start time of the target operation, and acquire the first call frequency at each time within a preset time.
[0156] The first call number is a first call number of a first callback function counted by the kernel object, and the process in the software to be monitored calls the first callback function once for each system call;
[0157] The time consumption determination module 620 is configured to determine operation time consumption of the target operation according to the call number information set established by using the first call number.
[0158] In an optional implementation, the process performs the following steps to obtain the first call number.
[0159] The first hook function is loaded, so that the first hook function performs the following operations: registering a first callback function corresponding to the process.
[0160] The first callback function is triggered once for each system call, and the first call number of the first callback function is counted by the kernel object, and the first call number represents the busy degree of the software to be monitored.
[0161] In an optional implementation, the first hook function further performs the following operations:
[0162] The second hook function is injected into a first function for creating a new process, and the first function corresponds to the process.
[0163] In an optional implementation, the process further performs the following steps to obtain the total call number:
[0164] The first function is called to create a child process of the process, and the first hook function is injected into the child process through the second hook function injected into the first function;
[0165] The child process loads the first hook function, so that the first hook function performs the following operations: registering a second callback function corresponding to the child process, and injecting the second hook function into a second function for creating a new process, and the second function corresponds to the child process.
[0166] The second callback function is called once for each system call of the child process, the second call number of the second callback function is counted by the kernel object, and the total call number is obtained by adding the first call number and the second call number, and the total call number represents the busy degree of the software to be monitored.
[0167] In an optional implementation, the kernel object finds a busy level corresponding to the first call number or the total call number, and the busy level represents the busy degree of the software to be monitored.
[0168] In an optional implementation, the number acquisition module is specifically configured to:
[0169] obtaining the first call times at each time point within a preset time after the starting time point from the kernel object.
[0170] In an optional implementation, the time consumption determining module specifically includes:
[0171] an information set establishing submodule, configured to establish a call time information set according to the first call times at each time point within the preset time;
[0172] a time point determining submodule, configured to determine an ending time point of the target operation according to the call time information set;
[0173] a time consumption determining submodule, configured to determine an operation time consumption of the target operation according to the starting time point and the ending time point.
[0174] In an optional implementation, the time point determining submodule specifically includes:
[0175] an information set generating unit, configured to perform second derivation on the first call times at each time point in the call time information set to obtain a call time change amplitude information set;
[0176] a time point determining unit, configured to determine an ending time point of the target operation according to the call time change amplitude information set.
[0177] In an optional implementation, the time point determining unit specifically includes:
[0178] a sliding subunit, configured to control a sliding window to slide on the call time change amplitude information set until an average value of the call time change amplitudes in the sliding window is less than a preset threshold value for the first time to stop the sliding;
[0179] a time point determining subunit, configured to determine an ending time point of the target operation according to the call time change amplitudes in the sliding window.
[0180] In an optional implementation, the time point determining subunit is specifically configured to:
[0181] find a time point corresponding to the first call time change amplitude in the sliding window, and determine the time point as the ending time point of the target operation.
[0182] The embodiments of the present application also provide an electronic device, as shown in the accompanying drawings, which comprises a processor 71, a communication interface 72, a memory 73 and a communication bus 74, wherein the processor 71, the communication interface 72 and the memory 73 complete mutual communication through the communication bus 74, Figure 7
[0183] the memory 73 is configured to store a computer program.
[0184] The processor 71, when executing the program stored in the memory 73, implements the following steps:
[0185] Obtain the starting time of the target operation, and obtain the first call number at each time within a preset time; the first call number is the first call number of the first callback function counted by the kernel object, and the process in the software to be monitored calls the first callback function once for each call of the system call; and the operation time of the target operation is determined according to the call number information set established by using the first call number.
[0186] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or only one type of bus.
[0187] The communication interface is used for communication between the above electronic device and other devices.
[0188] The memory can include a Random Access Memory (RAM), and can also include a non-volatile memory, such as at least one disk memory. Optionally, the memory can also be at least one storage device located away from the aforementioned processor.
[0189] The processor mentioned above can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; and can also be a Digital Signal Processing (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0190] In a further implementation provided in the present application, a storage medium is provided, which stores instructions that, when executed on a computer, cause the computer to perform the software monitoring or operation time determination method of any of the above embodiments.
[0191] In a further implementation provided in the present application, a computer program product is provided, which contains instructions that, when executed on a computer, cause the computer to perform the software monitoring or operation time determination method of any of the above embodiments.
[0192] In the above embodiments, the implementation can be wholly or partially achieved by software, hardware, firmware, or any combination thereof. When implemented by software, the implementation can be wholly or partially in the form of a computer program product. The computer program product contains one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the above processes or functions are wholly or partially generated. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a storage medium, or transferred from one storage medium to another storage medium, for example, the computer instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) manner. The storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains one or more available media. The available medium can be a magnetic medium (for example, floppy disk, hard disk, magnetic tape), an optical medium (for example, DVD), or a semiconductor medium (for example, solid state disk (SSD)), etc.
[0193] It should be noted that, in this document, the terms such as first and second are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0194] Each of the embodiments in the specification is described in a relevant manner, and the same or similar parts between the embodiments can be referred to each other. Each of the embodiments focuses on the difference from other embodiments. In particular, for the system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiments.
[0195] The above only describes the preferred embodiments of the present application, and is not used to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method of operating a time-to-determination method, characterized by, The method comprises: acquiring a starting time of a target operation, and acquiring a first call number at each time within a preset time; wherein the first call number is a first call number of a first callback function counted by a kernel object, and a process in the software to be monitored calls the first callback function once for each call of a system call; determining an operation time consumption of the target operation according to a call number information set established by using the first call number.
2. The method of claim 1, wherein, The process performs the following steps to obtain the first call number: loading a first hook function, so that the first hook function performs the following operation: registering a first callback function corresponding to the process; for each call of a system call, triggering a call of the first callback function once; wherein a first call number of the first callback function is counted by a kernel object, and the first call number represents a busy degree of the software to be monitored.
3. The method of claim 2, wherein, The first hook function further performs the following operation: injecting a second hook function into a first function for creating a new process, the first function corresponding to the process.
4. The method of claim 3, wherein, The process further performs the following steps to obtain a total call number: calling the first function to create a child process of the process, and injecting the first hook function into the child process through the second hook function injected in the first function; wherein the child process loads the first hook function, so that the first hook function performs the following operation: registering a second callback function corresponding to the child process, and injecting the second hook function into a second function for creating a new process, the second function corresponding to the child process; for each call of a system call, the child process calls the second callback function once, a kernel object counts a second call number of the second callback function, and the total call number is obtained by adding the first call number and the second call number, the total call number representing the busy degree of the software to be monitored.
5. The method according to claim 2 or 4, characterized in that, The kernel object finds a busy level corresponding to the first call number or the total call number, and the busy level represents the busy degree of the software to be monitored.
6. The method of claim 1, wherein, The acquiring of the first call number at each time within the preset time comprises: acquiring the first call number at each time within the preset time after the starting time from the kernel object.
7. The method of claim 1, wherein, The determining of the operation time consumption of the target operation according to the call number information set established by using the first call number comprises: establishing a call number information set according to the first call number at each time within the preset time; determining an ending time of the target operation according to the call number information set, and determining the operation time consumption of the target operation according to the starting time and the ending time.
8. The method of claim 7, wherein, The determining of the ending time of the target operation according to the call number information set comprises: performing second-order differentiation on the first call number at each time in the call number information set to obtain a call number change amplitude information set; determining the ending time of the target operation according to the call number change amplitude information set.
9. The method of claim 8, wherein, The determining of the ending time of the target operation according to the call number change amplitude information set comprises: The sliding window is controlled to slide on the set of call frequency change amplitude information until an average of call frequency change amplitudes in the sliding window is less than a preset threshold for the first time to stop sliding; An end time of the target operation is determined according to the call frequency change amplitudes in the sliding window.
10. The method of claim 9, wherein, The determining of the end time of the target operation according to the call frequency change amplitudes in the sliding window comprises: An earliest time corresponding to a call frequency change amplitude in the sliding window is found, and the time is determined as the end time of the target operation.
11. An apparatus for operating a time-consuming determination, characterized by The device comprises: A frequency acquisition module is configured to acquire a start time of a target operation and acquire a first call frequency at each time within a preset time. The first call frequency is a first call frequency of a first callback function counted by a kernel object, and a process in the software to be monitored calls the first callback function once for each call of a system call. A time consumption determination module is configured to determine operation time consumption of the target operation according to a call frequency information set established by using the first call frequency.
12. An electronic device, comprising: The device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus. The memory is configured to store a computer program. The processor is configured to execute the program stored in the memory to implement the method in any one of claims 1-10.