Message delay detection method, device, electronic device and storage medium

By obtaining the message processing time in the target thread and determining the delay threshold according to the message type, the accuracy and fine-grained positioning of message delay detection is achieved, which solves the problem of inaccurate message delay detection in the existing technology and improves the fluency of the system. and user experience.

CN113595814BActive Publication Date: 2024-08-23SHENZHEN TCL NEW-TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110762437.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-06
Publication Date
2024-08-23
Estimated Expiration
2041-07-06

AI Technical Summary

Technical Problem

In the existing technology, message delay detection is not accurate enough, making it difficult to quickly locate the specific causes of system performance problems, affecting user experience.

Method used

By obtaining the message processing time in the target thread and determining its delay threshold according to the message type, accurate delay detection is performed and more fine-grained delay positioning is provided.

Benefits of technology

The accuracy of message delay detection is improved, the delay of each message can be accurately obtained, and the system fluency and user experience are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113595814B
    Figure CN113595814B
Patent Text Reader

Abstract

The embodiments of the present application disclose a message delay detection method, device, electronic device and storage medium, including: when the target thread of an application in a terminal system is executed, obtaining the processing time corresponding to the message in the target thread; performing type identification on the message in the target thread to obtain the message type of the message; determining the message delay threshold corresponding to the message according to the message type; performing delay detection on the message according to the processing time and the message delay threshold to obtain the message delay detection result; the scheme uses different message delay thresholds for different types of messages to perform message delay detection, which can improve the accuracy of message delay detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a message delay detection method, device, electronic device and storage medium. Background Art

[0002] With the rapid development of computer technology, electronic devices have been widely used, and people often complete their daily study and work by using various applications in electronic devices.

[0003] The use of applications depends on the terminal system in the electronic device. The terminal system provides the operating environment for the application. The terminal system often completes communication by sending messages. The message is the object transmitted by the communication system and is the carrier of information. However, there is often a delay in the message sending process, that is, there will be a delay when the message is processed in the thread. Once the delay time is too long, it will affect the performance of the system. For example, the screen of the interface (UI, User Interface) layer will freeze or even freeze, which will ultimately affect the user experience. Therefore, how to detect the delay and quickly obtain the cause of the delay is of great significance to ensure the smoothness of the system.

[0004] In some systems, a delay detection mechanism is provided, such as the native delay detection mechanism in the Android system. When a certain time is reached, a delay report will be returned. However, the result of this delay detection is inaccurate. Summary of the invention

[0005] The embodiments of the present application provide a message delay detection method, device, electronic device and storage medium, which can improve the accuracy of message delay detection.

[0006] The present application provides a message delay detection method, comprising:

[0007] When the target thread of the application in the terminal system is executed, the processing time corresponding to the message in the target thread is obtained;

[0008] Identify the type of the message in the target thread and obtain the message type;

[0009] Determine a message delay threshold corresponding to the message according to the message type;

[0010] According to the processing time and the message delay threshold, a message delay detection is performed to obtain a message delay detection result.

[0011] Accordingly, the present application also provides a message delay detection device, comprising:

[0012] An acquisition module, used for acquiring the processing time corresponding to the message in the target thread when the target thread of the application in the terminal system is executed;

[0013] An identification module is used to identify the type of the message in the target thread and obtain the message type;

[0014] A determination module, used to determine a message delay threshold corresponding to the message according to the message type identified by the identification module;

[0015] The analysis module is used to perform delay detection on the message according to the processing time obtained by the acquisition module and the message delay threshold determined by the determination module to obtain the message delay detection result.

[0016] Optionally, in some embodiments of the present invention, the determining module includes:

[0017] A first acquisition unit, configured to acquire a mapping relationship set, the mapping relationship set including a mapping relationship between a preset message type and a preset message delay threshold;

[0018] The first determining unit is used to determine a message delay threshold corresponding to the message according to the mapping relationship set obtained by the first obtaining unit and the message type identified by the identification module.

[0019] Optionally, in some embodiments of the present invention, the determining module includes:

[0020] A second determining unit, used to determine a message delay threshold interval corresponding to a message type;

[0021] The third determining unit is used to determine a message delay threshold corresponding to the message from the message delay interval according to a delay frequency of the message type.

[0022] Optionally, in some embodiments of the present invention, the third determining unit includes:

[0023] A selection subunit, configured to select an initial message delay threshold from the message delay threshold interval;

[0024] A recording subunit, used to record the delay frequency of the message type;

[0025] The adjusting subunit is used to adjust the initial message delay threshold within the message delay threshold interval according to the delay frequency to obtain the message delay threshold corresponding to the message.

[0026] Optionally, in some embodiments of the present invention, the processing time includes a dispatch delay time for the message to be dispatched from the message queue of the target thread, and obtaining the processing time corresponding to the message in the target thread is specifically used for:

[0027] When a message in the target thread enters the message queue, determine the expected dispatch time of the message from the message queue;

[0028] When a message is dispatched from a message queue, get the actual dispatch time when the message is dispatched from the message queue;

[0029] Generates the message dispatch delay time based on the actual dispatch time and the expected dispatch time.

[0030] Optionally, in some embodiments of the present invention, the processing time includes a dispatch delay time for the message to be dispatched from the message queue of the target thread, and obtaining the processing time corresponding to the message in the target thread is specifically used for:

[0031] When the message in the target thread is dispatched and starts to execute, get the start execution time of the message;

[0032] When the message execution is finished, get the end execution time of the message;

[0033] Generates the execution time of the message based on the start execution time and the end execution time.

[0034] Optionally, in some embodiments of the present invention, the message delay detection device further includes a feedback module, and the feedback module includes:

[0035] A second acquisition unit is used to acquire device information of the running application and delay information of the message delay if the delay detection result of the message is message delay;

[0036] The first output unit is used to output device information and delay information.

[0037] The present application obtains the processing time of a message in a thread and the message delay threshold corresponding to the message, and obtains a message delay detection result based on the message processing time and the message delay threshold; wherein, the acquisition of the message delay threshold of the message is determined based on the message type of the message. The present application sets corresponding different message delay thresholds for different message types, so that the result of message delay detection is more accurate. In addition, the present application can accurately obtain the delay of each message in the thread through delay detection of messages in the thread, so that the granularity of message delay detection is finer, thereby improving the accuracy of message delay positioning. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the technical solutions in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0039] Figure 1 It is a scenario diagram of the message delay detection method provided by the present application;

[0040] Figure 2 It is a flow chart of the message delay detection method provided by the present application;

[0041] Figure 3 It is a flow chart of obtaining the processing time of a message in the message delay detection method provided by the present application;

[0042] Figure 4 This is a flow chart of obtaining the message dispatch delay time in the message delay detection method provided by the present application;

[0043] Figure 5 This is a flow chart of obtaining the message execution time in the message delay detection method provided by this application;

[0044] Figure 6 It is a flowchart of obtaining delay information of a delayed message in the message delay detection method provided by the present application;

[0045] Figure 7 is another flow chart of the message delay detection method provided by the present application;

[0046] Figure 8 It is a structural schematic diagram of a message delay detection device provided by the present application;

[0047] Fig. 9 It is a structural schematic diagram of the electronic device provided by this application. DETAILED DESCRIPTION

[0048] The following will be combined with the drawings in this application to clearly and completely describe the technical solutions in this application. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments in the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0049] The embodiments of the present application provide a message delay detection method, device, electronic device and storage medium. Specifically, the embodiments of the present application provide a message delay detection device suitable for electronic devices, wherein the electronic device can be a terminal or a server and other devices, wherein the terminal can be a notebook, a desktop, a smart phone, a smart TV, a tablet computer or a car-mounted smart terminal, etc., the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms, etc. The server can be directly or indirectly connected via wired or wireless communication.

[0050] It can be understood that the message delay detection method of the embodiment of the present application can be executed on the terminal, can be executed on the server, or can be executed jointly by the terminal and the server.

[0051] For example, see Figure 1 In the embodiment of the present application, a terminal and a server jointly execute a message delay detection method as an example, wherein other devices can be added on the basis of the terminal and the server to assist in completing the message delay detection method, and the types of other devices are not limited here; the terminal and the server are connected via a network, such as a wired or wireless network connection, etc., wherein the message delay detection device can be integrated in the server, and integrating the message delay detection device in the terminal can be understood by referring to integrating the message delay detection device in the server.

[0052] Among them, integrating the message delay detection device on the server specifically includes: the server can obtain the processing time of the message in the thread when the application is running, and determine the message delay threshold of the message according to the message type of the message, and obtain the delay detection result of the message in the thread when the thread is executed according to the processing time of the message and the message delay threshold corresponding to the message.

[0053] First, the terminal can trigger and start the application, then the server performs delay detection on the message in the thread when the application is running, and finally, the terminal can receive the message delay detection result sent by the server, so that the maintenance personnel can make corresponding adjustments at the terminal according to the delay detection result.

[0054] The message delay detection method provided in the embodiment of the present application relates to the problem of processing messages in a thread when an application is running in a terminal system. After identifying the message type of a message, the embodiment of the present application determines the message delay threshold corresponding to the message according to the message type, obtains the processing time of the message in the thread, and performs delay detection on the message according to the message delay threshold and processing time of the message to obtain the delay detection result of the message.

[0055] Among them, in the embodiment of the present application, the delay detection result of the message can be a message processing delay or a normal message processing. Therefore, for different delay detection results, the maintenance personnel can make different adjustments on the client. For example, if the delay detection result indicates that the message is delayed, the maintenance personnel can use the delay detection result to promptly discover the location and cause of the delay, and make timely adjustments to the corresponding location to ensure the smoothness of the thread execution. If the delay detection result indicates that the message processing is normal, the maintenance personnel may not make adjustments.

[0056] In addition, the message delay threshold of the message in the thread is determined according to the message type. The message delay thresholds corresponding to messages of different message types may be different. The specific value of the message delay threshold can be set according to the experience of the management personnel or maintenance personnel, the application or the needs of the scenario. The specific setting method and setting standard of the message delay threshold are not limited here.

[0057] The present application sets different message delay thresholds according to the different message types of each message in the thread, so that when the application is running, the message in the thread can determine the corresponding message delay threshold according to its own message type, and after obtaining the processing time of the message, obtain the message delay detection result according to the message processing time and the message delay threshold. After outputting the delay detection result, if the delay detection result is a message delay, it is also convenient for the management personnel to determine the specific location and cause of the delay according to the delay detection result, which is convenient for rapid adjustment and ensuring the smoothness of the system. In addition, the embodiment of the present application can accurately obtain the delay situation of each message in the thread through delay detection of the message in the thread, so that the granularity of the message delay detection is finer, and the accuracy of message delay positioning is improved.

[0058] It should be noted that the order of description of the following embodiments is not intended to limit the priority order of the embodiments.

[0059] See also Figure 2 , Figure 2 A schematic diagram of a flow chart of a message delay detection method provided in an embodiment of the present application. The specific flow of the message delay detection method may be as follows:

[0060] 101. When a target thread of an application in a terminal system is executed, a processing time corresponding to a message in the target thread is obtained.

[0061] Among them, the terminal system is located between the hardware and software of the electronic device. It is responsible for managing computer hardware and software resources and providing an operating environment for applications. The terminal system mainly includes mobile terminal operating systems, such as Android operating system, Apple (iOS) operating system, Microsoft (Windows) operating system, Linux (Linux) operating system, etc.

[0062] An application is a computer program that is used to complete one or more specific tasks. It runs in user mode, can interact with users, and has a visual user interface. For example, an application can be a video application, a game application, a payment application, or a search application.

[0063] The target thread is the thread executed by the application in the terminal system when it is running. The thread is the smallest unit that the operating system can perform operations and scheduling. The thread is essentially a section of instructions (also program code), and the operating system executes the thread to complete the business logic of the application. For example, in the Android system, threads include main threads and sub-threads.

[0064] Among them, in the embodiment of the present application, the message is the object processed when the thread is executed, and the terminal system completes the communication by sending messages. For example, the message type may include a normal message, a drawing message, or a life cycle message.

[0065] The embodiment of the present application takes the Android operating system as an example, and other terminal systems can use the Android operating system as a reference. For example, each application in the Android system will have a thread when it is started. The thread can perform drawing operations and other operations. However, if the application code is not standardized, it may take time to execute in the thread. In addition, since the messages in the thread are processed in sequence, if a message takes time to process, it will affect the processing of subsequent messages. Ultimately, it will affect the operation of the entire application, resulting in freezes, frame drops, and the like. Traditional delay detection of the entire thread can only detect the delay of the entire thread, but cannot obtain the specific reason for the freeze of the application. For example, it is not possible to obtain which specific message has been delayed in processing, or it is difficult to find which process of the thread processing has been delayed, which is not convenient for making targeted adjustments quickly. Therefore, it is necessary to detect the processing of each message in the thread, and the most direct way to detect the delay of each message in the thread is to obtain the processing time of the message and determine whether the processing time has timed out.

[0066] The message processing time may be the time used by the message in each processing process of the thread, or the time used by two or more consecutive processing processes, or the processing delay time of each processing process.

[0067] For example, see Figure 3 Each Android thread has a message queue for storing messages to be executed. The execution process of the Android thread can refer to the following steps 131 to 134:

[0068] 131. Process the message before entering the message queue, for example, initialize the message loop (Looper.prepareMainLooper) and loop to obtain messages (Looper.loop);

[0069] 132. Send the acquired message (Handler.sendMessage);

[0070] 133. Send the message to the message queue (MessageQueue.enqueueMessage);

[0071] 134. Loop to take out messages from the message queue for execution, for example, take out the message at the head of the message queue (MessageQueue.next).

[0072] Among them, in the embodiment of the present application, if there is no message in the message queue, the thread enters a sleep state, the process of taking out the message from the message queue is the dispatch of the message, and the execution process is the execution of the message. Therefore, the processing time of the message can be the dispatch time and execution time of the message. In addition, since there may be a delay in the dispatch of the message from the message queue in the thread, that is, the message is not dispatched according to the expected dispatch time, therefore, the processing time of the message can also be the dispatch delay time, etc. The above examples should not be understood as limitations on the embodiments of the present application.

[0073] There are many ways to obtain the message processing time. For example, timing is performed when the message processing starts, and the time when the message processing ends is obtained when the message processing ends. The message processing end time is the message processing time.

[0074] Or, if Figure 3 As shown, the specific method of obtaining the processing time of the message can refer to the content of the following steps 135 to 139:

[0075] 135. Mark or monitor the start of message processing (LooperMonitor.markDispatch);

[0076] 136. Mark or monitor the end of message processing (LooperMonitor.markFinish);

[0077] The message processing start time and message processing end time are recorded respectively by the above-mentioned marking or monitoring method, and the message processing time is calculated by using the time points before and after the processing, specifically including:

[0078] 137. Record the time when the message starts to be executed;

[0079] 138. Record the time when the message execution ends;

[0080] 139. The execution time of the message is calculated using the end execution time and the start execution time of the message;

[0081] Among them, the above example of a method for obtaining the processing time of a message is only used as a specific implementation method and should not be understood as a limitation on the embodiments of the present application.

[0082] For example, see Figure 4 In the Android system, the process of dispatching a message from a message queue can be seen in the following steps 141 to 144:

[0083] 141. Loop to get a message from the message object pool (Message.obtain);

[0084] 142. Send the acquired message to the message queue (sendMessage);

[0085] 143. Enqueue the messages entering the message queue in the order of expected delivery time (enqueueMessage);

[0086] 144. The message handler obtains the message from the message queue in a loop according to the expected dispatch time (Looper.loop).

[0087] Among them, in the embodiment of the present application, if the processing of the previous message in the thread is delayed, it will affect the dispatch of subsequent messages, causing the dispatch of subsequent messages to be delayed, that is, the processing time of the message includes the message dispatch delay time. When the processing time of the message includes the dispatch delay time of the message being dispatched from the message queue of the target thread, the message dispatch can be monitored to obtain the actual dispatch time of the message, that is, optionally, in some embodiments, the step of "when the target thread of the application in the terminal system is executed, obtaining the processing time corresponding to the message in the target thread" can specifically include:

[0088] 145. When the message in the target thread enters the message queue, determine the expected dispatch time of the message from the message queue;

[0089] 146. When the message in the target thread is dispatched from the message queue, obtain the actual dispatch time when the message is dispatched from the message queue;

[0090] Generates the message dispatch delay time based on the actual dispatch time and the expected dispatch time.

[0091] In an embodiment of the present application, the dispatch delay time of the message can be obtained by obtaining the expected dispatch time and the actual dispatch time when the message is dispatched from the message queue. The dispatch delay time can be used as a comparison object for whether the dispatch of the message in the thread is delayed, that is, when the dispatch delay time times out, it can be determined that the dispatch of the message is delayed, wherein the expected dispatch time is set when the message enters the message queue, that is, under normal circumstances, when the expected dispatch time is met, the message is dispatched from the message queue, and the set time is obtained, and the actual dispatch time is obtained when the message is dispatched from the message queue. The actual dispatch time can be obtained by real-time monitoring when the message leaves the message queue. The dispatch delay time of the message can be obtained by calculating the difference between the actual dispatch time and the expected dispatch time. This method of obtaining the dispatch delay time is relatively fast and accurate.

[0092] Among them, see Figure 5 , the execution process of the message in the Android thread is as follows:

[0093] 151. Loop to get messages from the message queue (MessageQueue.next);

[0094] 152. Execute the obtained message (handMessage).

[0095] Among them, in the embodiment of the present application, the time used to execute the message is the execution time of the message. When the processing time of the message includes the execution time of the message after being dispatched from the message queue of the target thread, the time points before and after the execution of the message can be monitored and obtained, and then the execution time of the message can be calculated according to the time difference before and after the execution of the message. That is, optionally, in some embodiments, the step of "when the target thread of the application in the terminal system is executed, obtaining the processing time corresponding to the message in the target thread" can specifically include:

[0096] 153. When the message in the target thread is dispatched and starts to execute, get the start execution time of the message;

[0097] 154. When the message execution is completed, the end execution time of the message is obtained;

[0098] Generates the execution time of the message based on the start execution time and the end execution time.

[0099] In an embodiment of the present application, the end execution time can be acquired by real-time monitoring when the message ends execution, and the start execution time can be acquired by real-time monitoring when the message starts execution. The difference between the end execution time and the start execution time is calculated, and the difference is the execution time of the message. Moreover, the execution time obtained by using the difference between the time points before and after execution is also relatively accurate and convenient.

[0100] Among them, the execution of the message starts immediately after the message is dispatched from the thread, so the actual dispatch time when the message is dispatched from the thread is also the start execution time of the message. Therefore, the time obtained when the message is dispatched from the message queue can be used as both the actual dispatch time of the message and the start execution time of the message.

[0101] 102. Identify the type of the message in the target thread to obtain the message type;

[0102] In an embodiment of the present application, when the application is running, it relies on the execution of threads to complete various interface drawings or data loading. Different types of messages in the thread process the interface differently, and the processing time corresponding to different types of messages is often different. Identifying the type of message helps to determine the processing time of the message under normal circumstances.

[0103] The message type of the message may be determined according to a unique identifier of the message, that is, optionally, in some embodiments, the step of "identifying the type of the message in the target thread to obtain the message type of the message" may specifically include:

[0104] Identify the message ID of the message and the type of thread that processes the message;

[0105] The message type of the message is determined based on the message identifier and the processing thread type.

[0106] The message identifier includes a message number or a message unique code (message ID), and the message identifier is used to uniquely identify the message. Different types of messages have different types of processing threads, so the message type of the message can be determined based on the message identifier and the type of the message processing thread.

[0107] For example, in an embodiment of the present application, the message type of a message can be determined based on the mapping relationship between the message identifier, the processing thread type and the message type, or a part of the message type set can be determined based on the message identifier, and then a unique message type is determined from the above set based on the processing thread type of the message, etc. The above examples should not be understood as limitations on the embodiments of the present application.

[0108] 103. Determine a message delay threshold corresponding to the message according to the message type;

[0109] Among them, when the application is running, the processing time of different messages in the thread may be different. If the message delay threshold of all messages in the thread is set to the same, inaccurate detection results will appear when detecting message delays. For example, if the message delay threshold is set to a large value, some messages with a short processing time will be delayed after a delay, and the delay detection results will show that the messages are not delayed because the time after the delay is still less than the message delay threshold. On the contrary, if the message delay threshold is set to a small value, for some messages with a long processing time, the output delay detection results will be shown as message delays because the processing time is greater than the message delay threshold. In fact, it is only because the actual processing time itself is long and it is not a delay. Therefore, after setting the message delay threshold of all messages in the thread to the same value, it is inaccurate to detect message delays.

[0110] The processing time of messages of the same message type approaches a fixed value, so when setting the message delay threshold, the messages can be divided according to the message types, that is, the message delay thresholds corresponding to different types of messages are set according to the message types.

[0111] The message delay threshold can be understood as the maximum value corresponding to normal message processing. When the message processing time is greater than or equal to the message delay threshold, it is considered that the message processing time has timed out, that is, the message processing is delayed.

[0112] There are multiple methods for determining the message delay threshold of the message according to the message type of the message. For example, the message delay threshold corresponding to the message type can be determined according to the mapping relationship between the message type and the message delay threshold, or the message delay threshold interval corresponding to the message type is first determined, and then the message delay threshold corresponding to the message is determined in the message delay threshold interval. That is, optionally, in some embodiments, the step of "determining the message delay threshold corresponding to the message according to the message type" can specifically include:

[0113] Obtain a mapping relationship set, the mapping relationship set including a mapping relationship between a preset message type and a preset message delay threshold; specifically, the mapping relationship set includes a corresponding relationship between one or more preset message types and a message delay threshold corresponding to each message type;

[0114] A message delay threshold corresponding to the message is determined according to the mapping relationship set and the message type corresponding to the message.

[0115] After obtaining a mapping relationship set between message types and message delay thresholds, the message delay threshold corresponding to the message is determined from the mapping relationship set according to the identified message type.

[0116] Among them, by establishing a mapping relationship between message type and message delay threshold, a unique corresponding relationship can be determined between message type and message delay threshold. After obtaining the message type, the message delay threshold corresponding to the message type can be directly and quickly obtained. This method of obtaining the message delay threshold is relatively fast and accurate.

[0117] Among them, since the message delay threshold corresponding to the message type in the mapping relationship set is often set according to the experience of the maintenance personnel or the conventional standards, the message delay threshold corresponding to the message type is often a fixed value. However, in actual development or application, different code writing standards or writing habits may cause fluctuations in the processing time of messages in the thread, so the fixed message delay threshold may no longer be applicable, or may be greatly restricted. Therefore, each message type may correspond to a message delay threshold interval, and a value may be selected in the message delay threshold interval as the message delay threshold of the message according to certain conditions. That is, optionally, in some embodiments, the step of "determining the message delay threshold corresponding to the message according to the message type" may specifically include:

[0118] Determine a message delay threshold interval corresponding to a message type of the message;

[0119] According to the delay frequency of the message type, a message delay threshold corresponding to the message is determined from the message delay threshold interval.

[0120] The message delay threshold interval is also designed based on the experience of maintenance personnel. For example, based on the processing time of the same type of messages in the past, a message delay threshold value interval is determined in a relatively concentrated data range, namely, the message delay threshold interval.

[0121] Among them, the message delay frequency refers to the frequency of message delays. By calculating the frequency of message delays of the same type, it can be understood whether messages of this type are often delayed. Among them, message delays may be due to unreasonable design of the code block of the message dispatching or execution process in the thread, or it may be due to unreasonable settings of the message delay threshold. Therefore, assuming that the code block design is reasonable, the setting or selection of the message delay threshold can be designed to ensure that the setting of the message delay threshold is reasonable. For example, in an embodiment of the present application, the message delay threshold is selected by the delay frequency, and a message delay threshold with a lower delay frequency can be selected.

[0122] That is, optionally, in some embodiments, the step of “determining the message delay threshold corresponding to the message from the message delay threshold interval according to the delay frequency of the message type” may specifically include:

[0123] Selecting an initial message delay threshold from the message delay threshold interval;

[0124] Record the delay frequency of the message type;

[0125] The initial message delay threshold is adjusted within the message delay threshold interval according to the delay frequency to obtain a message delay threshold corresponding to the message.

[0126] For example, in an embodiment of the present application, after determining the corresponding message delay threshold interval by message type, an initial message delay threshold can be first selected from the message delay thresholds, and then the specific value of the initial message delay threshold in the interval can be adjusted according to the delay frequency of the message type, thereby obtaining the message delay threshold of the message. For example, if the delay frequency of this type of message delay is high, it may be because the value of the initial message delay threshold is set too small, and the value of the initial message delay threshold can be appropriately increased within the original interval to obtain the final message delay threshold; on the contrary, if the delay frequency of this type of message delay is low, it may be because the value of the initial message delay threshold is set too large, and the value of the initial message delay threshold can be appropriately reduced within the original interval, wherein the increase or decrease amplitude can also be set according to the delay frequency, when the delay frequency is high or low, the adjustment amplitude of the initial message delay threshold can be appropriately increased (for example, the increase scale or decrease scale of the initial message delay threshold is increased), when the delay frequency approaches the expected value and the change fluctuation is not large, the adjustment amplitude of the initial message delay threshold can be appropriately reduced, or even the adjustment of the initial message delay threshold can be stopped; by adjusting the initial message delay threshold, the delay frequency corresponding to the message type approaches a stable state with a low delay frequency value. This message delay threshold obtained after adjusting the initial message delay threshold according to the message delay frequency can ensure that each message type can correspond to an accurate message delay threshold.

[0127] Among them, the message delay thresholds corresponding to the same message type when dispatching and executing may be different. Therefore, the message dispatch delay threshold corresponding to the message type when dispatching may be set for the message dispatch and the message execution delay threshold corresponding to the message type when executing may be set for the message execution. That is, the same message type corresponds to different message delay thresholds when dispatching and executing, that is, optionally, in some embodiments, the step of "determining the message delay threshold corresponding to the message according to the message type" may specifically include:

[0128] Obtain a mapping relationship set, the mapping relationship set including a mapping relationship between a preset message type, a preset message processing method, and a preset message delay threshold;

[0129] Identify the message processing method and obtain the message processing method of the message;

[0130] A message delay threshold corresponding to the message is determined according to a mapping relationship set, a message type, and a message processing method.

[0131] Among them, in the embodiment of the present application, the message processing method may include the dispatching or executing of the message. Of course, for different message types, other processing methods may also be included, which are not limited here.

[0132] In the embodiment of the present application, by establishing a mapping relationship between message type, message processing mode and message delay threshold, messages of different message types can correspond to a message delay threshold in different message processing modes. For example, the same message type corresponds to a message dispatch delay threshold when dispatched and corresponds to a message execution delay threshold when executed. This message delay threshold determined according to the message type and processing mode of the message makes the determination of the message delay threshold more accurate.

[0133] 104. Perform delay detection on the message according to the processing time and the message delay threshold to obtain a delay detection result of the message.

[0134] Among them, the message delay detection result includes message processing delay or normal message processing. When the processing time of the message is greater than or equal to the message delay threshold of the message, the message delay detection result is the message processing delay, otherwise, the message processing is normal.

[0135] Among them, the processing time of the message includes the dispatch delay time when the message is dispatched from the message queue and the execution time of the message after being dispatched from the message queue. When the dispatch delay time of the message (that is, the difference between the actual dispatch time and the expected dispatch time) is greater than or equal to the message delay threshold of the message, the message dispatch is considered to have timed out, otherwise the message dispatch has not timed out; when the execution time of the message (that is, the difference between the end execution time and the start execution time of the message) is greater than or equal to the message delay threshold of the message, the message execution is considered to have timed out, that is, the execution of the message is delayed, otherwise the execution of the message is not delayed.

[0136] Among them, in the embodiment of the present application, the message type of the message includes a common message, a drawing message or a life cycle message, wherein the common message refers to a message without characteristics in the message queue, which is different from the drawing message and the life cycle message. The drawing message refers to a message used to complete the drawing operation when the application is running. The life cycle message refers to a message with a life cycle in the message processing process. The life cycle refers to the status information of the message at each stage in the thread processing process. Of course, for different applications or needs, the types of messages in the thread are different, or there are more detailed divisions, and the types of message types are not specifically limited here.

[0137] In an embodiment of the present application, when the message type in the thread is a drawing message, the drawing message includes a single drawing message and multiple continuous drawing messages, wherein a single drawing message means that a single message can complete the drawing operation, and multiple continuous drawing messages mean that continuous drawing operations are completed by dispatching and executing multiple continuous messages, wherein the delay detection of a single drawing message and a single message in multiple continuous drawing messages is the same as that of an ordinary message or a life cycle message, and the calculation of the dispatch delay time and execution time of a single drawing message and a single message in multiple continuous drawing messages can be obtained by referring to the calculation method described above.

[0138] In the embodiment of the present application, for multiple continuous drawing messages, there will be a continuous execution time period when they are executed, and the continuous processing of multiple messages needs to be completed within this time period. However, since the requirements for the smooth processing of one or two of the multiple continuous drawing messages during the drawing process are not high, it can be allowed that one or two of the messages are delayed during processing. Therefore, for such multiple continuous drawing messages, a delay quantity threshold of message delay can be set, and the delay detection result is determined to be a message delay only after the quantity threshold is reached. That is, optionally, in some embodiments, the step of "delay detection of the message according to the processing time and the message delay threshold to obtain the message delay detection result" can specifically include:

[0139] When the message type is multiple continuous drawing messages, the expected total processing time of the multiple continuous drawing messages is obtained;

[0140] Determine the total number of messages for multiple consecutive drawing messages based on the expected total processing time;

[0141] Obtain the processing time and message delay threshold of each of multiple continuous drawing messages, and perform delay detection on each message;

[0142] Record the number of delayed messages in multiple consecutive drawing messages;

[0143] Obtaining the correlation between the preset total number of messages and the preset delay number threshold;

[0144] According to the total number of messages and the correlation relationship, the delay number threshold corresponding to multiple consecutive drawing messages is obtained;

[0145] According to the number of delayed messages and the delay number threshold, delay detection results of multiple continuous drawing messages are obtained.

[0146] For example, for a plurality of continuous drawing messages, the continuous drawing time is 2s, and 120 frames (i.e., 120 messages) need to be drawn within 2s. On average, the processing time for each frame is 16.66ms. Therefore, as long as the processing time of one frame is greater than 16.66ms, the plurality of continuous drawing messages will experience frame loss. However, a small amount of frame loss has little impact on the overall drawing. Therefore, for the case of multiple continuous drawing messages, a single frame drawing timeout may indicate in the delay detection result that the message is not delayed. However, when multiple frames of drawing timeout occur in a continuous drawing message, it will have a significant impact on the overall continuous drawing. Therefore, the present application sets a delay number threshold for multiple frame processing timeout for the case of multiple continuous drawing messages. For example, the delay number threshold is set to 30, that is, when the number of frames that time out during the continuous drawing message exceeds or is equal to 30, for example, the number of frames that time out within 2s is greater than or equal to 30, the output delay detection result of the plurality of continuous drawing messages is message delay.

[0147] Among them, the specific value of the number of delayed messages can be set according to the total number of messages of multiple consecutive drawing messages. If the delay detection result of multiple consecutive drawing messages is that the delay frequency of message delay is high, the delay number threshold can be appropriately adjusted. For example, when the delay frequency is high, the delay number threshold can be appropriately increased. Conversely, if the delay frequency is low, in order to detect the delay more accurately, the delay number threshold can be appropriately reduced.

[0148] See also Figure 6 , detect the processing of messages in the thread. When a delay in the processing of a message is detected, delay information related to the delayed message is obtained. For example, taking the detection of message execution as an example, the specific process is as follows:

[0149] 161. Execute the message;

[0150] 162. Identify a message type of the message, and determine a message delay threshold of the message according to the message type of the message;

[0151] 163. Determine whether the execution of the message is delayed, for example, by comparing the execution time with a message delay threshold to determine whether the execution of the message is delayed;

[0152] 164. When it is detected that the execution of a message is delayed, the delayed message is recorded, and delay information related to the delayed message is obtained;

[0153] 165. Output the delay information to the terminal.

[0154] Wherein, when a delay occurs in message processing, delay information related to the delayed message can be obtained to ensure accurate positioning of the message delay, that is, optionally, in some embodiments, the method further includes:

[0155] If the delay detection result of the message is message delay, then obtain the device information of the running application and the delay information of the message delay;

[0156] Output device information and delay information.

[0157] Among them, maintenance personnel can adjust the specific code blocks in the thread according to the device information and delay information, so that maintenance personnel can quickly find the specific cause of the delay, speed up the processing of the delay, and ensure the smooth operation of the application.

[0158] The delay information includes the time point when the freeze occurs, the process name where the freeze occurs, the application version information, the freeze type, the sender of the freeze message, the receiver of the freeze message, the message number of the freeze message, the freeze duration information, the method stack information or the system resource information, etc. When the message type is multiple continuous drawing messages, the delay information also includes view information and environment information, etc.

[0159] Among them, the jam duration information is the message processing time information, the sender of the jam message refers to the object that puts the message into the message queue (such as the Handler in Android) or the object that takes the message out of the message queue (such as the Looper in Android), and the processor of the jam message refers to the object that receives the message (such as the Handler in Android). Among them, the execution of the message is in the thread where the Handler is located. By returning the delay information related to the delayed message, it is convenient for maintenance personnel to make targeted adjustments in a timely and rapid manner. Among them, the View class is a super class of (Android) Android, which includes almost all screen types. Each View has a canvas for drawing, which can be extended arbitrarily. The environmental information includes thread ID, thread code segment, thread stack, etc. Among them, Handler directly inherits Object. A Handler allows sending and processing messages (Message) or Runnable interface objects, and will be associated with the main thread's message queue (MessageQueue). Looper is used to start a message loop for a thread. By default, newly created threads in Android (android) do not have a message loop turned on (except the main thread. The main thread system will automatically create a Looper object for it and start the message loop). The Looper object stores messages and events through the message queue (MessageQueue). A thread can only have one Looper, corresponding to a message queue (MessageQueue).

[0160] Different messages may use different resources, so when a delay or freeze occurs, the system resource information during message processing is recorded. According to the occupation and consumption of system resources, it is helpful to locate the cause of the delay or freeze. That is, optionally, in some embodiments, the step of "obtaining system resource information of the message" may specifically include:

[0161] Get the type of system resources used when the message is dispatched or executed;

[0162] Get the total amount of resources corresponding to various system resource types before and after the message is dispatched or executed;

[0163] The consumption corresponding to various system resource types before and after the message is dispatched or executed is determined according to the total amount of resources corresponding to various system resource types before and after the message is dispatched or executed.

[0164] The system resource information includes the system resource type and the system resource consumption. The system resource type includes central processing unit (CPU) resources, input / output (IO) resources or memory resources. By obtaining the system resource type, the occupancy of the system resource type during message delay can be obtained, such as Figure 6 As shown, specifically including:

[0165] 166. Record system resource information before and after message dispatch or execution;

[0166] 167. Obtain system resource consumption for dispatching or executing the message based on system resource information before and after the message is dispatched or executed.

[0167] Among them, by calculating the consumption of system resources corresponding to each system resource type, the consumption of system resources corresponding to each system resource type can be obtained, which is convenient for analyzing and locating the specific causes of message delays or freezes according to the occupancy of system resource types and system resource consumption. In addition, the occupied system resource types and the total amount of resources are also easy to identify and count.

[0168] In some embodiments, since a plurality of messages are stored in a message queue of a thread, these messages are queued and stored in the message queue, waiting to be dispatched and then executed one by one. Therefore, if a message in a thread is delayed during dispatch or execution, subsequent messages may also be delayed in dispatch. Therefore, in this case, only the number of subsequent message dispatch timeouts and the detailed information (delay information) of delayed messages that cause a series of subsequent message dispatch timeouts may be recorded. In addition, there may be a large time difference between the times when each message in the message queue is expected to be dispatched, so there is also a situation where the previous message dispatch is delayed and the next message dispatch is normal. For example, the expected dispatch time of the previous message is eight o'clock, and the dispatch delay time is 50ms, while the expected dispatch time of the next message is eight o'clock and one minute. Then, the dispatch delay of the previous message does not affect the dispatch of the next message. That is, since the time difference between the dispatch time of the subsequent message and the dispatch time of the previous message is greater than the dispatch delay time of the previous message, the dispatch of the subsequent message will not be delayed due to the dispatch delay of the previous message.

[0169] The present application sets different message delay thresholds for each message type in the thread, so that each message can correspond to a message delay threshold. The setting of the message delay threshold for each message in the present application is more conducive to the accurate detection of the delay of each message, and the message delay detection result is obtained according to the message delay threshold and the message processing time. When the message processing time is greater than or equal to the message delay threshold, the message delay detection result is determined to be a message delay, and the delay information associated with the delayed message is collected after the message delay, so that the management personnel can determine the specific location and cause of the delay according to the delay information, and facilitate the rapid adjustment to ensure the smoothness of the system. In addition, the embodiment of the present application can accurately obtain the delay of each message in the thread by detecting the delay of the message in the thread during processing, so that the granularity of the message delay detection is finer, and the accuracy of the message delay positioning is improved. For example, it can accurately detect which specific message in the thread is causing the delay in dispatching or executing.

[0170] The method according to the embodiment will be further described in detail below with examples.

[0171] In this embodiment, the message delay detection device is specifically integrated into a server as an example for description.

[0172] See also Figure 7 , a message delay detection method, the specific process can be as follows:

[0173] 201. When a target thread of an application in a terminal system is executed, the server obtains a processing time corresponding to a message in the target thread.

[0174] It should be noted that the message processing time includes the dispatch delay time of the message being dispatched from the message queue of the target thread or the execution time of the message being executed after being dispatched from the message queue of the target thread.

[0175] Among them, when the processing time of the message is the message dispatch delay time, the server sets and records the expected dispatch time of the message when the message enters the message queue, and when the message is dispatched from the message queue, that is, when the message is dequeued from the message queue, the server records the actual dispatch time when the message is dispatched. Finally, the server calculates the difference between the actual dispatch time and the expected dispatch time of the message, and determines the difference as the dispatch delay time of the message dispatch delay.

[0176] In an embodiment of the present application, when the processing time of a message is the execution time of the message, when the server starts to execute the message, that is, when the message is dispatched from the message queue, the server records the time at this time as the start execution time of the message, and when the message execution ends, the server records the time at this time as the end execution time of the message. Finally, the server calculates the difference between the end execution time and the start execution time of the message, and determines the difference as the execution time of the message execution.

[0177] 202. The server identifies the type of the message in the target thread and obtains the message type of the message.

[0178] For example, the server may extract a message identifier (such as a message number or a message unique code) and a type of a message processing thread from the processed message, and determine the type of the message according to the message identifier and the type of the message processing thread.

[0179] 203. The server determines a message delay threshold corresponding to the message according to the message type.

[0180] Among them, the processing time of different messages in the thread may be different. If the message delay threshold of all messages in the thread is set to the same, then inaccurate detection results will appear during message delay detection, and the processing time of messages of the same type tends to a fixed value. Therefore, when setting the message delay threshold of the message, it can be divided according to the type of message, that is, the message delay threshold corresponding to different types of messages is set according to the type of message, wherein the message delay threshold of each message type is set according to the actual application or demand and stored in the server. Subsequently, after obtaining the message, the server obtains the message delay threshold corresponding to the message type according to the message type obtained after identifying the message.

[0181] Among them, the message delay threshold can be a fixed value that has a one-to-one mapping relationship with the message type, or it can be an interval, and a value is selected from the interval as the message delay threshold, wherein the selection of the message delay threshold can be adjusted according to the delay frequency of the message type.

[0182] 204. Perform delay detection on the message according to the processing time and the message delay threshold to obtain a delay detection result of the message.

[0183] In an embodiment of the present application, the server obtains a delay detection result of the message based on the processing time of the message and the message delay threshold corresponding to the message, and obtains a final result of the delay detection result after comparing the processing time and the message delay threshold. For example, after the processing time of the message is greater than or equal to the message delay threshold of the message, it is considered that the message is delayed, and the delay information related to the delay of the message is output to the terminal. The maintenance personnel analyze and adjust the code block where the delay occurs based on the delay detection result and delay information output by the server.

[0184] The server of the present application sets different message delay thresholds for each type of message, so that each message can correspond to a message delay threshold. The setting of the message delay threshold for each message by the server is more conducive to the accurate detection of the delay of each message. In addition, the server obtains the delay detection result according to the message delay threshold and the processing time of the message, and judges whether the processing of the message in the thread has been delayed by comparing the message delay threshold with the processing time of the message. After detecting that the message has been delayed, the server can return the delay information of the delayed message, so that the management personnel can determine the specific location and cause of the delay according to the delay detection result and delay information returned by the server, and facilitate the rapid adjustment of the location where the delay occurs (including specific code blocks, etc.) to ensure the smoothness of the system. In addition, the server can accurately obtain the delay of each message in the thread by detecting the delay of the message in the thread during processing, so that the granularity of the message delay detection is finer and the accuracy of the message delay positioning is improved.

[0185] In order to better implement the message delay detection method of the present application, the present application also provides a message delay detection device based on the above-mentioned message delay detection method. The meanings of the terms are the same as those in the above-mentioned message delay detection method, and the specific implementation details can refer to the description in the method embodiment.

[0186] See also Figure 8 , Figure 8 This is a schematic diagram of the structure of the message delay detection device provided by the present application, wherein the message delay detection device may include an acquisition module 301, an identification module 302, a determination module 303, and an analysis module 304. Optionally, a feedback module 305 may also be included. Specifically, it may be as follows:

[0187] The acquisition module 301 is used to acquire the processing time corresponding to the message in the target thread when the target thread of the application in the terminal system is executed.

[0188] Optionally, in some embodiments of the present invention, the processing time includes a dispatch delay time for the message to be dispatched from the message queue of the target thread, and obtaining the processing time corresponding to the message in the target thread is specifically used for:

[0189] When a message in the target thread enters the message queue, determine the expected dispatch time of the message from the message queue;

[0190] When a message is dispatched from a message queue, get the actual dispatch time when the message is dispatched from the message queue;

[0191] Generates the message dispatch delay time based on the actual dispatch time and the expected dispatch time.

[0192] Optionally, in some embodiments of the present invention, the processing time includes the execution time after the message is dispatched from the message queue of the target thread, and obtaining the processing time corresponding to the message in the target thread is specifically used for:

[0193] When the message in the target thread is dispatched and starts to execute, get the start execution time of the message;

[0194] When the message execution is finished, get the end execution time of the message;

[0195] Generates the execution time of the message based on the start execution time and the end execution time.

[0196] The identification module 302 is used to identify the type of the message in the target thread and obtain the message type of the message.

[0197] The determination module 303 is used to determine the message delay threshold corresponding to the message according to the message type.

[0198] Optionally, in some embodiments of the present invention, the determining module 303 may specifically include:

[0199] A first acquisition unit, configured to acquire a mapping relationship set, the mapping relationship set including a mapping relationship between a preset message type and a preset message delay threshold;

[0200] The first determining unit is used to determine a message delay threshold corresponding to the message according to a mapping relationship set and a message type.

[0201] Optionally, in some embodiments of the present invention, the determining module 303 further includes:

[0202] A second determining unit, used to determine a message delay threshold interval corresponding to a message type;

[0203] The third determining unit is used to determine a message delay threshold corresponding to the message from the message delay interval according to a delay frequency of the message type.

[0204] Optionally, in some embodiments of the present invention, the third determining unit includes:

[0205] A selection subunit, configured to select an initial message delay threshold from the message delay threshold interval;

[0206] A recording subunit, used to record the delay frequency of the message type;

[0207] The adjusting subunit is used to adjust the initial message delay threshold within the message delay threshold interval according to the delay frequency to obtain the message delay threshold corresponding to the message.

[0208] The analysis module 304 is used to perform delay detection on the message according to the processing time and the message delay threshold to obtain a delay detection result of the message.

[0209] Optionally, in some embodiments of the present invention, the message delay detection device may further include a feedback module 305. The specific feedback module may include:

[0210] A second acquisition unit is used to acquire device information of the running application and delay information of the message delay if the delay detection result of the message is message delay;

[0211] The first output unit is used to output device information and delay information.

[0212] In this application, the acquisition module 301 acquires the processing time of the message in the thread when the application is running, and then the identification module 302 extracts the type of the message, and then the determination module 303 determines the message delay threshold of the message according to the message type of the message. Finally, the analysis module 304 generates the message delay detection result according to the message processing time and the message delay threshold of the message, wherein the message delay detection result can be a message delay or a message is not delayed, and when the message delay detection result is determined to be a message delay, the feedback module 305 can be used to output the delay information of the message delay, so that the maintenance personnel can obtain the delay information and accurately locate the message delay according to the delay information. The message delay detection scheme provided by the present application uses the message type of the message to determine the message delay threshold of the message, so that each message corresponds to a message delay threshold respectively. The setting of the message delay threshold for each message in the present application is conducive to the accurate detection of the delay of each message. In addition, by detecting the delay of the message in the thread during processing, the processing status of each message in the thread can be accurately obtained, so that the granularity of the message delay detection is finer.

[0213] In addition, the present application also provides an electronic device, such as Fig. 9 As shown, it shows a schematic diagram of the structure of the electronic device involved in this application, specifically:

[0214] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that Fig. 9 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0215] The processor 401 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.

[0216] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.

[0217] The electronic device also includes a power supply 403 for supplying power to each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 403 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.

[0218] The electronic device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0219] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, as follows:

[0220] Get the processing time used for message processing in the thread, extract the type of message and the processing method of the message in the thread, determine the delay threshold corresponding to the message in the processing method according to the type of message and the processing method of the message in the thread, if the processing time of the message in the processing method is greater than or equal to the delay threshold corresponding to the message in the processing method, then return a detection result reflecting the message delay, if the processing time of the message in the processing method is less than the delay threshold corresponding to the message in the processing method, then return a detection result reflecting that the message processing is normal.

[0221] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0222] The present application sets different delay thresholds for each type of message and the different ways of processing messages in the thread, so that each message can correspond to a delay threshold. Compared with the traditional setting of a unified threshold for each message in a thread, the setting of the delay threshold for each message in the present application is more conducive to the accurate detection of the delay of each message, avoiding the unreasonable delay detection caused by the different processing time of each message, and by comparing the delay threshold with the processing time of the message, it is determined whether the processing of the message in the thread has been delayed. After detecting that a delay has occurred, the delay information of the message, that is, the detection result, can be returned, so that the management personnel can determine the specific code block where the delay occurs according to the delay information, and facilitate rapid adjustment to ensure the smoothness of the system. In addition, the present invention can accurately obtain the processing status of each message in the thread by detecting the delay in the processing of the message in the thread. Compared with the traditional detection of the processing status of the entire thread, the detection granularity of the present invention is finer, and the specific problem of thread jamming can be discovered.

[0223] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0224] To this end, the present application provides a storage medium in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any message delay detection method provided in the present application. For example, the instructions can execute the following steps:

[0225] Get the processing time used for message processing in the thread, extract the type of message and the processing method of the message in the thread, determine the delay threshold corresponding to the message in the processing method according to the type of message and the processing method of the message in the thread, if the processing time of the message in the processing method is greater than or equal to the delay threshold corresponding to the message in the processing method, then return a detection result reflecting the message delay, if the processing time of the message in the processing method is less than the delay threshold corresponding to the message in the processing method, then return a detection result reflecting that the message processing is normal.

[0226] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0227] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0228] Since the instructions stored in the storage medium can execute the steps in any message delay detection method provided in the present application, the beneficial effects that can be achieved by any message delay detection method provided in the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0229] The above is a detailed introduction to a message delay detection method, device, electronic device and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A message delay detection method, It is characterized in that include: When a target thread of an application in the terminal system is executed, obtaining a processing time corresponding to a message in the target thread; Performing type identification on the message in the target thread to obtain the message type of the message; Determine a message delay threshold corresponding to the message according to the message type; Performing delay detection on the message according to the processing time and the message delay threshold to obtain a delay detection result of the message; The determining, according to the message type, a message delay threshold corresponding to the message includes: Determine a message delay threshold interval corresponding to the message type; According to the delay frequency of the message type, a message delay threshold corresponding to the message is determined from the message delay threshold interval.

2. The method according to claim 1, It is characterized in that The determining, according to the message type, a message delay threshold corresponding to the message includes: Acquire a mapping relationship set, where the mapping relationship set includes a mapping relationship between a preset message type and a preset message delay threshold; A message delay threshold corresponding to the message is determined according to the mapping relationship set and the message type.

3. The method according to claim 2, It is characterized in that The determining, according to the delay frequency of the message type, a message delay threshold corresponding to the message from the message delay threshold interval includes: Selecting an initial message delay threshold from the message delay threshold interval; Record the delay frequency of the message type; The initial message delay threshold is adjusted within the message delay threshold interval according to the delay frequency to obtain a message delay threshold corresponding to the message.

4. The method according to claim 1, It is characterized in that The processing time includes a dispatch delay time of a message being dispatched from a message queue of the target thread, and obtaining the processing time corresponding to the message in the target thread includes: When the message in the target thread enters a message queue, determining an expected dispatch time for the message to be dispatched from the message queue; When the message is dispatched from the message queue, obtaining the actual dispatch time when the message is dispatched from the message queue; A dispatch delay time of the message is generated according to the actual dispatch time and the expected dispatch time.

5. The method according to claim 1, It is characterized in that The processing time includes the execution time after the message is dispatched from the message queue of the target thread, and the obtaining of the processing time corresponding to the message in the target thread includes: When the message in the target thread starts to execute after being dispatched, obtaining the start execution time of the message; When the execution of the message is completed, obtaining the end execution time of the message; The execution time of the message is generated according to the start execution time and the end execution time.

6. The method according to claim 1, It is characterized in that After performing delay detection on the message according to the processing time and the message delay threshold to obtain the delay detection result of the message, the method further includes: If the delay detection result of the message is message delay, obtaining device information for running the application and delay information of the message delay; The device information and the delay information are output.

7. A message delay detection device, It is characterized in that include: An acquisition module, used for acquiring the processing time corresponding to the message in the target thread when the target thread of the application in the terminal system is executed; An identification module, used for identifying the type of the message in the target thread to obtain the message type of the message; A determination module, configured to determine a message delay threshold corresponding to the message according to the message type; An analysis module, configured to perform delay detection on the message according to the processing time and the message delay threshold, and obtain a delay detection result of the message; Wherein, determining the message delay threshold corresponding to the message according to the message type includes: Determine a message delay threshold interval corresponding to the message type; According to the delay frequency of the message type, a message delay threshold corresponding to the message is determined from the message delay threshold interval.

8. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, in, When the processor executes the program, the steps of the message delay detection method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium, It is characterized in that A computer program is stored thereon, wherein when the computer program is executed by a processor, the steps of the message delay detection method according to any one of claims 1 to 6 are implemented.