WO2017096734A1 - Program detection method and device - Google Patents

Program detection method and device Download PDF

Info

Publication number
WO2017096734A1
WO2017096734A1 PCT/CN2016/077653 CN2016077653W WO2017096734A1 WO 2017096734 A1 WO2017096734 A1 WO 2017096734A1 CN 2016077653 W CN2016077653 W CN 2016077653W WO 2017096734 A1 WO2017096734 A1 WO 2017096734A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
time
execution
target
target message
Prior art date
Application number
PCT/CN2016/077653
Other languages
French (fr)
Chinese (zh)
Inventor
巩晓波
Original Assignee
腾讯科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2017096734A1 publication Critical patent/WO2017096734A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a program detection method and a program detection apparatus.
  • Android applications are message driven, including the display of the interface and the execution of the program logic.
  • the interface display is driven in the form of a series of screen refresh messages in the main thread. For example, when the user's finger swipes a list, the system constructs a screen refresh message and throws it into the message queue of the main thread. Only when the message before the message is executed, the message will be executed. When the message is executed, the screen will be executed. The content of the next frame will be displayed.
  • the function logic of the program developer is also queued in the main thread in the form of a message. If a program logic message thrown by the developer blocks the screen refresh message because the execution time is too long, the screen display occurs. In the prior art, it is impossible to accurately locate the message that generates the card.
  • the embodiment of the invention provides a program detection method and device, which can accurately locate and output a target message that causes a screen to be jammed by detecting the execution duration of the target message in the main thread.
  • the present invention provides a program detection method, which may include:
  • the present invention provides a program detecting apparatus, which may include:
  • a detecting module configured to detect a first time of execution of a target message in a message queue of the main thread and a second time after the message following the target message is executed;
  • a determining module configured to determine an execution duration of the target message according to the first time and the second time
  • Determining an output module if the execution duration is greater than a preset threshold, determining that execution of the target message causes the screen to be stuck and outputting the target message.
  • the first time of executing the target message in the message queue of the main thread and the second time of executing the message after the target message are determined, and the execution time of the target message is determined according to the first time and the second time, if executed If the duration is greater than the preset threshold, it is determined that the execution of the target message causes the screen to be jammed and the target message is output. This manner can accurately locate the target message that causes the screen to be jammed by detecting the execution duration of the target message in the main thread.
  • FIG. 1 is a flowchart of a method for detecting a program according to an embodiment of the present invention
  • FIG. 2 is a flowchart of another method for detecting a program according to an embodiment of the present invention.
  • FIG. 3 is a flowchart of still another method for detecting a program according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of performing a screen refresh message according to an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a program carton according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of a detection program stuck according to an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a program detecting apparatus according to an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of a detection module according to an embodiment of the present disclosure.
  • FIG. 9 is a schematic structural diagram of another detection module according to an embodiment of the present invention.
  • FIG. 10 is a schematic structural diagram of another program detecting apparatus according to an embodiment of the present invention.
  • FIG. 1 is a flowchart of a method for detecting a program according to an embodiment of the present invention; the method may include the following steps S100-S102.
  • the Android application is message driven, including the display of the interface and the execution of the program logic.
  • the display of the interface is driven in the form of a series of screen refresh messages in the main thread. For example, when the user swipes a list, the system constructs a screen refresh message and throws it into the message queue of the main thread. Only when the message before the screen refresh message is executed, the message will be executed when the screen is refreshed. The screen displays the contents of the next frame when the message is executed.
  • the frequency of screen refresh is 60fps, which means that each screen refresh message can not be executed for more than 16 milliseconds. If this time is exceeded, the user will feel the card.
  • FIG. 4 it is a schematic diagram of the main thread of the screen refresh message execution, and the screen refresh message is executed in the main thread at a frequency of 16 milliseconds.
  • a program logic message thrown by a developer blocks the screen refresh message because its execution time is too long. Carton happened. As shown in FIG. 5, if the execution time of the program logic message exceeds a preset threshold, the execution of the screen refresh message is blocked, and the screen appears to be stuck.
  • the present invention provides a mechanism for automatically detecting such a message that is too long to execute.
  • each message is queued and executed in the form of a message queue, and the first time of executing the target message in the main thread message queue and the second execution of the message after the target message are obtained. time.
  • the target message may be a message of the main thread's message queue front end, that is, a message to be executed, and the type of the message may be a program logic message or a screen refresh message.
  • S101 Determine, according to the first time and the second time, an execution duration of the target message.
  • the execution time of the target message may be determined according to the first time executed by the target message and the second time after the message execution of the target message, as shown in FIG. 5, according to the first screen refresh message of the main thread.
  • the first time and the second time after the program logic message after the screen refresh message is executed, the execution time of the first screen refresh message can be calculated.
  • the determining the execution duration of the target message according to the first time and the second time includes:
  • the execution duration is greater than the preset threshold, the execution time of the target message is too long, which may block the execution of the screen refresh message, thereby causing the screen to be stuck, in order to enable the developer to know which target message is explicitly known.
  • the card causes the card to be output, and outputs the target message whose execution time is too long.
  • the first time of executing the target message in the message queue of the main thread and the second time of executing the message after the target message are determined, and the execution time of the target message is determined according to the first time and the second time, if executed If the duration is greater than the preset threshold, it is determined that the execution of the target message causes the screen to be jammed and the target message is output. This manner can accurately locate the target message that causes the screen to be jammed by detecting the execution duration of the target message in the main thread.
  • FIG. 2 is a flowchart of another method for detecting a program according to an embodiment of the present invention; the method may include the following steps S200-S204.
  • the present invention starts a detection thread for monitoring when the program is started.
  • the main thread's message is executed.
  • the implementation method may be to continuously send a detection message to the message queue front end of the main thread.
  • the first detection message "0" is set in the front end of the message queue of the main thread, and when the first detection message "0" is executed, the first detection message is 0.
  • the execution time is determined as the first time the target message (ie, the program logic message) in the message queue of the main thread executes.
  • the execution time of the first detection message is very short, almost at the microsecond level.
  • the target message ie, the program logic message
  • the front end continues to set the second detection message "1".
  • the execution time of the second detection message "1" is determined as a message after the target message (ie, a program logic message) (ie, a screen refresh message). The second time of execution. Because when the second detection message "1" is executed, it indicates that the program logic message is just finished.
  • the execution time of the target message (that is, the program logic message) may be determined according to the first time and the second time, and the execution time is less than the preset threshold, and the message after the target message is dequeued, and the message is sent to the front end of the main thread message queue.
  • the next detection message the execution time is greater than the preset threshold, indicating that the target message being executed in the main thread is too time consuming, which may cause the interface to be stuck.
  • the present invention outputs the query information for locating the target message, and queries according to the query information. Target information and output the target message,
  • S203 Determine, according to the first time and the second time, an execution duration of the target message.
  • steps S203-S204 of the embodiment of the present invention refer to the steps S101-S102 of the embodiment of FIG. 1 , and details are not described herein again.
  • the first time of executing the target message in the message queue of the main thread and the second time of executing the message after the target message are determined, and the execution time of the target message is determined according to the first time and the second time, if executed If the duration is greater than the preset threshold, it is determined that the execution of the target message causes the screen to be jammed and the target message is output. This manner can accurately locate the target message that causes the screen to be jammed by detecting the execution duration of the target message in the main thread.
  • FIG. 3 is a flowchart of still another method for detecting a program according to an embodiment of the present invention.
  • the method may include the following steps S300-S304.
  • a callback notification is registered on the message execution function of the main thread of the system.
  • the first callback notification when the system executes the target message in the message queue of the main thread, the first callback notification may be returned, where the first callback notification carries the first time when the target message is executed.
  • the second callback notification when the system executes the message after the target message in the message queue of the main thread, the second callback notification may also be returned, where the second callback notification carries the second time of execution of the message after the target message.
  • S303 Determine, according to the first time and the second time, an execution duration of the target message.
  • steps S303-S304 of the embodiment of the present invention refer to the steps S101-S102 of the embodiment of FIG. 1 , and details are not described herein again.
  • the first time of executing the target message in the message queue of the main thread and the second time of executing the message after the target message are determined, and the execution time of the target message is determined according to the first time and the second time, if executed If the duration is greater than the preset threshold, it is determined that the execution of the target message causes the screen to be jammed and the target message is output. This manner can accurately locate the target message that causes the screen to be jammed by detecting the execution duration of the target message in the main thread.
  • FIG. 7 is a schematic structural diagram of a program detecting apparatus according to an embodiment of the present invention.
  • the apparatus may include: a detecting module 100, a determining module 101, and a determining output module 102;
  • the detecting module 100 is configured to detect a first time when the target message is executed in the message queue of the main thread and a second time when the message after the target message is executed;
  • the Android application is message driven, including the display of the interface and the execution of the program logic.
  • the display of the interface is driven in the form of a series of screen refresh messages in the main thread. For example, when the user swipes a list, the system constructs a screen refresh message and throws it into the message queue of the main thread. Only when the message before the screen refresh message is executed, the message will be executed when the screen is refreshed. The screen displays the contents of the next frame when the message is executed.
  • the frequency of screen refresh is 60fps, which means that each screen refresh message can not be executed for more than 16 milliseconds. If this time is exceeded, the user will feel the card.
  • FIG. 4 it is a schematic diagram of the main thread of the screen refresh message execution, and the screen refresh message is executed in the main thread at a frequency of 16 milliseconds.
  • a program logic message thrown by a developer blocks the screen refresh message because its execution time is too long. Carton happened. As shown in FIG. 5, if the execution time of the program logic message exceeds a preset threshold, the execution of the screen refresh message is blocked, and the screen appears to be stuck.
  • the present invention provides a mechanism for automatically detecting such a message that is too long to execute.
  • each message is queued and executed in the form of a message queue, and the first time when the target message in the main thread message queue is executed and the second time after the target message is executed are acquired.
  • the target message may be a message of the main thread's message queue front end, that is, a message to be executed, and the type of the message may be a program logic message or a screen refresh message.
  • the detection module 100 can have the following two alternative implementations:
  • the detecting module 100 includes a first determining list. a unit 1000, a setting unit 1001 and a second determining unit 1002;
  • the first determining unit 1000 is configured to determine, when the first detection message is executed, an execution time of the first detection message as a first time when the target message in the message queue of the main thread is executed;
  • the present invention starts a detection thread for monitoring when the program is started.
  • the main thread's message is executed.
  • the implementation method may be to continuously send a detection message to the message queue front end of the main thread.
  • the first detection message “0” is set in the front end of the message queue of the main thread, and when the first detection message “0” is executed, the first determining unit 1000 The execution time of a detection message "0" is determined as the first time the target message (ie, the program logic message) in the message queue of the main thread is executed.
  • a setting unit 1001 configured to dequeue the target message, and continue to set a second detection message at a front end of the message queue of the main thread;
  • the execution time of the first detection message is very short, almost at the microsecond level.
  • the target message ie, the program logic message
  • the setting unit 1001 is simultaneously in the main thread.
  • the front end of the message queue continues to set the second detection message "1".
  • the second determining unit 1002 is configured to determine, when the second detection message is executed, an execution time of the second detection message as a second time of execution of the message after the target message.
  • the second determining unit 1002 determines the execution time of the second detection message "1" as the message after the target message (ie, the program logic message) (ie, Is the screen refresh message) the second time of execution. Because when the second detection message "1" is executed, it indicates that the program logic message is just finished.
  • the execution time of the target message (that is, the program logic message) may be determined according to the first time and the second time, and the execution time is less than the preset threshold, and the message after the target message is dequeued, and the message is sent to the front end of the main thread message queue.
  • the next detection message, the execution time is greater than the preset threshold, indicating that the target message being executed in the main thread is too time consuming, may cause the interface to be stuck, output query information for locating the target message, and query the target information according to the query information, and The target message is output to facilitate the developer to locate the source of the card.
  • the device further includes a registration module
  • the detection module 100 may include a first obtaining unit 1003 and a second obtaining unit 1004;
  • a registration module configured to register a callback notification on a message execution function of the main thread of the system
  • a callback notification is registered on the message execution function of the main thread of the system.
  • the first obtaining unit 1003 is configured to acquire a first callback notification of the system when the target message in the message queue of the main thread is executed, where the first callback notification carries the first time when the target message is executed;
  • the first callback notification when the system performs the target message in the message queue of the main thread, the first callback notification may be returned, and the first obtaining unit 1003 acquires a first callback notification of the system, where the first callback notification carries the target message. The first time.
  • the second obtaining unit 1004 is configured to acquire a second callback notification of the system when the message after the target message is executed, where the second callback notification carries a second time point of execution of the message after the target message.
  • the second callback notification when the system executes the message after the target message in the message queue of the main thread, the second callback notification may also be returned, where the second callback notification carries the second time of execution of the message after the target message.
  • the determining module 101 is configured to determine an execution duration of the target message according to the first time and the second time;
  • the determining module 101 determines the execution time of the target message according to the first time executed by the target message and the second time after the message execution of the target message, as shown in FIG. 5, according to the first screen of the main thread.
  • the execution time of the first screen refresh message can be calculated by refreshing the first time of execution of the message and the second time of execution of the program logic message after the screen refresh message.
  • the determining module 101 is specifically configured to calculate a duration formed between the first time and the second time, and determine the duration as an execution duration of the target message.
  • Determining the output module 102 if the execution duration is greater than a preset threshold, determining that execution of the target message causes the screen to be stuck, and outputting the target message.
  • the execution duration is greater than the preset threshold, the execution time of the target message is too long, which may block the execution of the screen refresh message, thereby causing the screen to be stuck, in order to enable the developer to know which target message is explicitly known. As a result of the stuck, it is determined that the output module 102 outputs the target message whose execution time is too long.
  • the program detecting method according to FIGS. 1 to 3 may be performed by each unit in the program detecting device shown in FIGS. 7 to 9.
  • steps S100, S101, and S102 shown in FIG. 1 may be performed by the detection module 100, the determination module 101, and the determination output module 102 shown in FIG. 7, respectively.
  • steps S200, S201, S202, S203, and S204 shown in FIG. 2 may be respectively performed by the first determining unit 1000, the setting unit 1001, the second determining unit 1002, the determining module 101, and the determination output shown in FIGS. 7 and 8.
  • Module 102 is executed.
  • Steps S300, S301, S302, S303, and S304 shown in FIG. 3 may be respectively performed by the registration module (not shown) shown in FIG. 7 and FIG. 9, the first acquisition unit 1003, the second acquisition unit 1004, and the determination module. 101 and determining the output module 102 to execute.
  • each unit in the program detecting apparatus shown in FIGS. 7 to 9 may be separately or entirely combined into one or several other units, or one of the units may also be It is further divided into a plurality of functionally smaller units, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present invention.
  • the above units are divided based on logical functions. In practical applications, the functions of one unit may also be implemented by multiple units, or the functions of multiple units may be implemented by one unit. In other embodiments of the invention, the terminal device may also include other modules. However, in practical applications, these functions can also be implemented by other units, and can be implemented by multiple units.
  • a general-purpose computing device such as a computer including a processing unit and a storage element including a central processing unit (CPU), a random access memory (RAM), a read only memory (ROM), and the like.
  • a computer program (including program code) for performing the program detecting method as shown in FIGS. 1 to 3 to construct a program detecting device as shown in FIGS. 7 to 9, and a program detecting method according to an embodiment of the present invention .
  • the computer program can be recorded, for example, on a computer readable recording medium, and loaded in the above computing device by a computer readable recording medium, and Run in it.
  • the first time of executing the target message in the message queue of the main thread and the second time of executing the message after the target message are determined, and the execution time of the target message is determined according to the first time and the second time, if executed If the duration is greater than the preset threshold, it is determined that the execution of the target message causes the screen to be jammed and the target message is output. This manner can accurately locate the target message that causes the screen to be jammed by detecting the execution duration of the target message in the main thread.
  • FIG. 10 is a schematic structural diagram of another program detecting apparatus according to an embodiment of the present invention.
  • the program detecting means may include at least one processor 1101, such as a CPU, at least one communication bus 1102, a user interface 1103, at least one network interface 1104, and a memory 1105.
  • the communication bus 1102 is used to implement connection communication between these components.
  • the user interface 1103 can include a display and a keyboard.
  • the optional user interface 1103 can also include a standard wired interface and a wireless interface.
  • the network interface 1104 can optionally include a standard wired interface, a wireless interface (such as a WI-FI interface, a Bluetooth interface).
  • the memory 1105 may be a high speed RAM memory or a non-volatile memory such as at least one disk memory.
  • the memory 1105 can also optionally be at least one storage device located away from the processor 1101.
  • the memory 1105 as a computer storage medium may further include an operating system, a network communication module, a user interface module, and a data processing application.
  • the network interface 1104 is mainly used to connect to a server and perform data communication with the server.
  • the memory 1105 stores a set of program codes, and the processor 1101 calls the program code stored in the memory 1105 to perform the following operations:
  • the processor 1101 invokes a program code stored in the memory 1105 to determine an execution duration of the target message according to the first time and the second time, Can include:
  • processor 1101 invokes program code stored in memory 1105 for performing the following operations:
  • processor 1101 invokes program code stored in memory 1105 for performing the following operations:
  • FIG. 7 - a program corresponding to the module of the program detecting means shown in FIG. 9 can be stored in a readable storage medium of the program detecting means and executed by at least one of the program detecting means to implement the above-described program detecting method, the method Including the method embodiments of FIG. 1 to FIG. Process.
  • a "computer-readable medium” can be any apparatus that can contain, store, communicate, propagate, or transport a program for use in an instruction execution system, apparatus, or device, or in conjunction with the instruction execution system, apparatus, or device.
  • computer readable media include the following: electrical connections (electronic devices) having one or more wires, portable computer disk cartridges (magnetic devices), random access memory (RAM), Read only memory (ROM), erasable editable read only memory (EPROM or flash memory), fiber optic devices, and portable compact disk read only memory (CDROM).
  • the computer readable medium may even be a paper or other suitable medium on which the program can be printed, as it may be optically scanned, for example by paper or other medium, followed by editing, interpretation or, if appropriate, other suitable The method is processed to obtain the program electronically and then stored in computer memory.
  • portions of the invention may be implemented in hardware, software, firmware or a combination thereof.
  • multiple steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system.
  • a suitable instruction execution system For example, if implemented in hardware, as in another embodiment, it can be implemented by any one or combination of the following techniques well known in the art: having logic gates for implementing logic functions on data signals. Discrete logic circuits, application specific integrated circuits with suitable combinational logic gates, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.
  • the above mentioned storage medium may be a read only memory, a magnetic disk or an optical disk or the like.

Abstract

Embodiments of the present invention provide a program detection method and device. The method may comprise: detecting a first time at which a target message in a message queue of a main thread is executed and a second time at which a message following the target message is executed; determining the execution duration of the target message according to the first time and the second time; and determining that screen stuttering is caused by the execution of the target message if the execution duration is greater than a preset threshold, and outputting the target message. According to the present invention, by measuring execution durations of target messages in a main thread, target messages that cause screen stuttering can be precisely located and outputted.

Description

一种程序检测方法及装置Program detection method and device
本专利申请要求2015年12月10日提交的中国专利申请号为201510916597.9,发明名称为“一种程序检测方法及装置”的优先权,该申请的全文以引用的方式并入本申请中。The present application claims priority to Chinese Patent Application No. 201510916597.9, filed on Dec. 10, 2015, the entire disclosure of which is incorporated herein by reference.
技术领域Technical field
本发明涉及通信技术领域,具体涉及一种程序检测方法及一种程序检测装置。The present invention relates to the field of communications technologies, and in particular, to a program detection method and a program detection apparatus.
背景技术Background technique
Android应用程序是由消息驱动的,包括界面的显示以及程序逻辑的执行。其中界面显示是在主线程中以一连串的屏幕刷新消息的形式不停的驱动刷新的。例如当用户手指滑动一个列表时,系统就会构造一个屏幕刷新消息抛到主线程的消息队列中,只有当这个消息之前的消息都执行完毕后,这个消息才会执行,当这个消息执行时屏幕才会显示下一帧的内容。而程序开发者的功能逻辑也是以消息的形式在主线程中排队的,如果一个由开发人员抛出的程序逻辑消息因为本身执行时间过长而阻塞了屏幕刷新消息的话,屏幕显示卡顿就发生了,现有技术中无法精确定位产生卡顿的消息。Android applications are message driven, including the display of the interface and the execution of the program logic. The interface display is driven in the form of a series of screen refresh messages in the main thread. For example, when the user's finger swipes a list, the system constructs a screen refresh message and throws it into the message queue of the main thread. Only when the message before the message is executed, the message will be executed. When the message is executed, the screen will be executed. The content of the next frame will be displayed. The function logic of the program developer is also queued in the main thread in the form of a message. If a program logic message thrown by the developer blocks the screen refresh message because the execution time is too long, the screen display occurs. In the prior art, it is impossible to accurately locate the message that generates the card.
发明内容Summary of the invention
本发明实施例提供一种程序检测方法及装置,可通过检测主线程中目标消息的执行时长,精确定位输出导致屏幕卡顿的目标消息。The embodiment of the invention provides a program detection method and device, which can accurately locate and output a target message that causes a screen to be jammed by detecting the execution duration of the target message in the main thread.
一方面,本发明提供一种程序检测方法,可包括:In one aspect, the present invention provides a program detection method, which may include:
检测主线程的消息队列中目标消息执行的第一时间以及在所述目标消息之后的消息执行的第二时间;Detecting a first time when the target message is executed in the message queue of the main thread and a second time of executing the message after the target message;
根据所述第一时间与所述第二时间,确定所述目标消息的执行时长;Determining an execution duration of the target message according to the first time and the second time;
若所述执行时长大于预设阈值,则确定所述目标消息的执行导致屏幕卡顿,并输出所述目标消息。If the execution duration is greater than a preset threshold, determining that execution of the target message causes the screen to jam and output the target message.
另一方面,本发明提供一种程序检测装置,可包括:In another aspect, the present invention provides a program detecting apparatus, which may include:
检测模块,用于检测主线程的消息队列中目标消息执行的第一时间以及在 所述目标消息之后的消息执行的第二时间;a detecting module, configured to detect a first time of execution of a target message in a message queue of the main thread and a second time after the message following the target message is executed;
确定模块,用于根据所述第一时间与所述第二时间,确定所述目标消息的执行时长;a determining module, configured to determine an execution duration of the target message according to the first time and the second time;
确定输出模块,用于若所述执行时长大于预设阈值,则确定所述目标消息的执行导致屏幕卡顿,并输出所述目标消息。Determining an output module, if the execution duration is greater than a preset threshold, determining that execution of the target message causes the screen to be stuck and outputting the target message.
实施本发明实施例,具有如下有益效果:Embodiments of the present invention have the following beneficial effects:
本发明实施例,检测主线程的消息队列中目标消息执行的第一时间以及在目标消息之后的消息执行的第二时间,根据第一时间与第二时间,确定目标消息的执行时长,若执行时长大于预设阈值,则确定目标消息的执行导致屏幕卡顿,并输出目标消息,这种方式可通过检测主线程中目标消息的执行时长,精确定位输出导致屏幕卡顿的目标消息。In the embodiment of the present invention, the first time of executing the target message in the message queue of the main thread and the second time of executing the message after the target message are determined, and the execution time of the target message is determined according to the first time and the second time, if executed If the duration is greater than the preset threshold, it is determined that the execution of the target message causes the screen to be jammed and the target message is output. This manner can accurately locate the target message that causes the screen to be jammed by detecting the execution duration of the target message in the main thread.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below. Obviously, the drawings in the following description are only It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any creative work.
图1为本发明实施例提供的一种程序检测方法的流程图;FIG. 1 is a flowchart of a method for detecting a program according to an embodiment of the present invention;
图2为本发明实施例提供的另一种程序检测方法的流程图;FIG. 2 is a flowchart of another method for detecting a program according to an embodiment of the present invention;
图3为本发明实施例提供的又一种程序检测方法的流程图;FIG. 3 is a flowchart of still another method for detecting a program according to an embodiment of the present invention;
图4为本发明实施例提供的一种屏幕刷新消息执行示意图;FIG. 4 is a schematic diagram of performing a screen refresh message according to an embodiment of the present invention;
图5为本发明实施例提供的一种程序卡顿示意图;FIG. 5 is a schematic diagram of a program carton according to an embodiment of the present invention; FIG.
图6为本发明实施例提供的一种检测程序卡顿的示意图;FIG. 6 is a schematic diagram of a detection program stuck according to an embodiment of the present invention; FIG.
图7为本发明实施例提供的一种程序检测装置的结构示意图;FIG. 7 is a schematic structural diagram of a program detecting apparatus according to an embodiment of the present invention;
图8为本发明实施例提供的一种检测模块的结构示意图;FIG. 8 is a schematic structural diagram of a detection module according to an embodiment of the present disclosure;
图9为本发明实施例提供的另一种检测模块的结构示意图;及FIG. 9 is a schematic structural diagram of another detection module according to an embodiment of the present invention; and
图10为本发明实施例提供的另一种程序检测装置的结构示意图。FIG. 10 is a schematic structural diagram of another program detecting apparatus according to an embodiment of the present invention.
具体实施方式 detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, but not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
下面将结合附图1-附图6,对本发明实施例提供的程序检测方法进行详细介绍。The program detection method provided by the embodiment of the present invention will be described in detail below with reference to FIG.
请参照图1,为本发明实施例提供的一种程序检测方法的流程图;该方法可包括以下步骤S100-步骤S102。FIG. 1 is a flowchart of a method for detecting a program according to an embodiment of the present invention; the method may include the following steps S100-S102.
S100,检测主线程的消息队列中目标消息执行的第一时间以及在所述目标消息之后的消息执行的第二时间。S100. Detect a first time when the target message is executed in the message queue of the main thread and a second time after the message is executed after the target message.
具体实施例中,Android应用程序是由消息驱动的,包括界面的显示以及程序逻辑的执行。其中界面的显示是在主线程中以一连串的屏幕刷新消息的形式不停的驱动刷新的。例如当用户手指滑动一个列表时,系统就会构造一个屏幕刷新消息抛到主线程的消息队列中,只有当这个屏幕刷新消息之前的消息都执行完毕后,这个消息才会执行,当这个屏幕刷新消息执行时屏幕才会显示下一帧的内容。一般来说屏幕刷新的频率是60fps,也就是说每个屏幕刷新消息执行的时间不能超过16毫秒,如果超过这个时长的话,用户就会感觉到卡顿。如图4所示,即是屏幕刷新消息执行的主线程示意图,屏幕刷新消息以16毫秒的频率在主线程中执行。In a specific embodiment, the Android application is message driven, including the display of the interface and the execution of the program logic. The display of the interface is driven in the form of a series of screen refresh messages in the main thread. For example, when the user swipes a list, the system constructs a screen refresh message and throws it into the message queue of the main thread. Only when the message before the screen refresh message is executed, the message will be executed when the screen is refreshed. The screen displays the contents of the next frame when the message is executed. Generally speaking, the frequency of screen refresh is 60fps, which means that each screen refresh message can not be executed for more than 16 milliseconds. If this time is exceeded, the user will feel the card. As shown in FIG. 4, it is a schematic diagram of the main thread of the screen refresh message execution, and the screen refresh message is executed in the main thread at a frequency of 16 milliseconds.
往往程序开发者的一些功能逻辑也是以消息的形式在主线程中排队执行的,比如程序逻辑消息,如果一个由开发人员抛出的程序逻辑消息因为本身执行时间过长而阻塞了屏幕刷新消息的话,卡顿就发生了。如图5所示,若该程序逻辑消息的执行时间超过预设阈值,则阻塞了屏幕刷新消息的执行,屏幕出现卡顿。Often some of the functional logic of a program developer is also queued for execution in the main thread in the form of a message, such as a program logic message, if a program logic message thrown by a developer blocks the screen refresh message because its execution time is too long. Carton happened. As shown in FIG. 5, if the execution time of the program logic message exceeds a preset threshold, the execution of the screen refresh message is blocked, and the screen appears to be stuck.
而在实际研发过程中,是需要能够准确定位到产生卡顿的程序逻辑消息,这样可以将该程序逻辑消息移除主线程执行。本发明提供了一种机制,能够自动检测出这种执行时间过长的消息。In the actual development process, it is necessary to be able to accurately locate the program logic message that generates the stuck, so that the program logic message can be removed from the main thread for execution. The present invention provides a mechanism for automatically detecting such a message that is too long to execute.
在主线程中,各个消息是以消息队列的形式依次排队执行的,获取主线程消息队列中目标消息执行的第一时间以及在目标消息之后的消息执行的第二 时间。目标消息可以是主线程的消息队列前端的消息,即是即将执行的消息,该消息的类型可能为程序逻辑消息,也可能为屏幕刷新消息。In the main thread, each message is queued and executed in the form of a message queue, and the first time of executing the target message in the main thread message queue and the second execution of the message after the target message are obtained. time. The target message may be a message of the main thread's message queue front end, that is, a message to be executed, and the type of the message may be a program logic message or a screen refresh message.
S101,根据所述第一时间与所述第二时间,确定所述目标消息的执行时长。S101. Determine, according to the first time and the second time, an execution duration of the target message.
具体实施例中,根据目标消息执行的第一时间以及目标消息之后的消息执行的第二时间,即可确定目标消息的执行时长,如图5所示,根据主线程第一个屏幕刷新消息执行的第一时间和该屏幕刷新消息之后的程序逻辑消息执行的第二时间,即可计算出第一个屏幕刷新消息的执行时长。In a specific embodiment, the execution time of the target message may be determined according to the first time executed by the target message and the second time after the message execution of the target message, as shown in FIG. 5, according to the first screen refresh message of the main thread. The first time and the second time after the program logic message after the screen refresh message is executed, the execution time of the first screen refresh message can be calculated.
具体可选的,所述根据所述第一时间与所述第二时间,确定所述目标消息的执行时长,包括:Specifically, the determining the execution duration of the target message according to the first time and the second time includes:
计算所述第一时间和所述第二时间之间所形成的时长,并将所述时长确定为所述目标消息的执行时长。Calculating a duration formed between the first time and the second time, and determining the duration as an execution duration of the target message.
具体实施例中,计算第一时间和第二时间之间所形成的时长,可选的,计算方法可以是将第二时间点减去第一时间点,例如,第一时间是第5ms(相对于整个程序执行时间),第二时间是第17ms(相对于整个程序执行时间),则时长为17ms-5ms=12ms,该时长即是目标消息的执行时长。In a specific embodiment, calculating a duration formed between the first time and the second time, optionally, the calculating method may be: subtracting the second time point from the first time point, for example, the first time is 5 ms (relative For the entire program execution time), the second time is 17ms (relative to the entire program execution time), and the duration is 17ms-5ms=12ms, which is the execution time of the target message.
S102,若所述执行时长大于预设阈值,则确定所述目标消息的执行导致屏幕卡顿,并输出所述目标消息。S102. If the execution duration is greater than a preset threshold, determining that execution of the target message causes the screen to be stuck and outputting the target message.
具体实施例中,若执行时长大于预设阈值,则说明该目标消息的执行时间过长,可能阻塞屏幕刷新消息的执行,从而导致屏幕卡顿,为了能够使得研发人员明确知道是哪一个目标消息导致卡顿,输出该执行时间过长的目标消息。In a specific embodiment, if the execution duration is greater than the preset threshold, the execution time of the target message is too long, which may block the execution of the screen refresh message, thereby causing the screen to be stuck, in order to enable the developer to know which target message is explicitly known. Causes the card to be output, and outputs the target message whose execution time is too long.
本发明实施例,检测主线程的消息队列中目标消息执行的第一时间以及在目标消息之后的消息执行的第二时间,根据第一时间与第二时间,确定目标消息的执行时长,若执行时长大于预设阈值,则确定目标消息的执行导致屏幕卡顿,并输出目标消息,这种方式可通过检测主线程中目标消息的执行时长,精确定位输出导致屏幕卡顿的目标消息。In the embodiment of the present invention, the first time of executing the target message in the message queue of the main thread and the second time of executing the message after the target message are determined, and the execution time of the target message is determined according to the first time and the second time, if executed If the duration is greater than the preset threshold, it is determined that the execution of the target message causes the screen to be jammed and the target message is output. This manner can accurately locate the target message that causes the screen to be jammed by detecting the execution duration of the target message in the main thread.
请参照图2,为本发明实施例提供的另一种程序检测方法的流程图;该方法可包括以下步骤S200-步骤S204。FIG. 2 is a flowchart of another method for detecting a program according to an embodiment of the present invention; the method may include the following steps S200-S204.
S200,当检测到所述第一检测消息执行时,将所述第一检测消息的执行时间确定为所述主线程的消息队列中目标消息执行的第一时间。 S200. When detecting that the first detection message is executed, determining an execution time of the first detection message as a first time of execution of a target message in a message queue of the main thread.
具体实施例中,为了能够检测执行目标消息的第一时间,以及执行该目标消息之后的消息的第二时间,如图6所示,本发明在程序启动的时候会启动一个检测线程用于监控主线程的消息执行。实现方法可以是不断的向主线程的消息队列前端抛送检测消息。In a specific embodiment, in order to be able to detect the first time of executing the target message and the second time of executing the message after the target message, as shown in FIG. 6, the present invention starts a detection thread for monitoring when the program is started. The main thread's message is executed. The implementation method may be to continuously send a detection message to the message queue front end of the main thread.
如图6所示,当主线程的刷新消息正在执行时,在主线程的消息队列前端设置第一检测消息“0”,当第一检测消息“0”执行时,将该第一检测消息“0”的执行时间确定为该主线程的消息队列中目标消息(即是程序逻辑消息)执行的第一时间。As shown in FIG. 6, when the refresh message of the main thread is being executed, the first detection message "0" is set in the front end of the message queue of the main thread, and when the first detection message "0" is executed, the first detection message is 0. The execution time is determined as the first time the target message (ie, the program logic message) in the message queue of the main thread executes.
S201,将所述目标消息出队,并继续在所述主线程的消息队列的前端设置第二检测消息。S201. Dequeue the target message, and continue to set a second detection message on a front end of the message queue of the main thread.
具体实施例中,第一检测消息的执行时间非常短,几乎在微秒级别,当第一检测消息执行时,目标消息(即是程序逻辑消息)出队执行,同时在主线程的消息队列的前端继续设置第二检测消息“1”。In a specific embodiment, the execution time of the first detection message is very short, almost at the microsecond level. When the first detection message is executed, the target message (ie, the program logic message) is dequeued and executed in the message queue of the main thread. The front end continues to set the second detection message "1".
S202,当执行到所述第二检测消息时,将所述第二检测消息的执行时间确定为在所述目标消息之后的消息执行的第二时间。S202. When performing the second detection message, determining an execution time of the second detection message as a second time of execution of the message after the target message.
具体实施例中,当第二检测消息“1”执行时,将该第二检测消息“1”的执行时间确定为该目标消息(即是程序逻辑消息)之后的消息(即是屏幕刷新消息)执行的第二时间。因为当第二检测消息“1”执行到时,则说明程序逻辑消息刚好执行完。In a specific embodiment, when the second detection message "1" is executed, the execution time of the second detection message "1" is determined as a message after the target message (ie, a program logic message) (ie, a screen refresh message). The second time of execution. Because when the second detection message "1" is executed, it indicates that the program logic message is just finished.
根据第一时间和第二时间可以确定该目标消息(即是程序逻辑消息)的执行时长,执行时长小于预设阈值,则目标消息后的消息出队,并向主线程消息队列前端继续抛送下一个检测消息,执行时长大于预设阈值,说明主线程中正在执行的目标消息太耗时,可以引起界面的卡顿,这时候本发明输出用于定位目标消息的查询信息,根据查询信息查询目标信息,并输出该目标消息,The execution time of the target message (that is, the program logic message) may be determined according to the first time and the second time, and the execution time is less than the preset threshold, and the message after the target message is dequeued, and the message is sent to the front end of the main thread message queue. The next detection message, the execution time is greater than the preset threshold, indicating that the target message being executed in the main thread is too time consuming, which may cause the interface to be stuck. At this time, the present invention outputs the query information for locating the target message, and queries according to the query information. Target information and output the target message,
S203,根据所述第一时间与所述第二时间,确定所述目标消息的执行时长。S203. Determine, according to the first time and the second time, an execution duration of the target message.
S204,若所述执行时长大于预设阈值,则确定所述目标消息的执行导致屏幕卡顿,并输出所述目标消息。S204. If the execution duration is greater than a preset threshold, determining that execution of the target message causes the screen to be stuck and outputting the target message.
本发明实施例步骤S203-S204,请参照图1的实施例步骤S101-S102,在此不再赘述。 For the steps S203-S204 of the embodiment of the present invention, refer to the steps S101-S102 of the embodiment of FIG. 1 , and details are not described herein again.
本发明实施例,检测主线程的消息队列中目标消息执行的第一时间以及在目标消息之后的消息执行的第二时间,根据第一时间与第二时间,确定目标消息的执行时长,若执行时长大于预设阈值,则确定目标消息的执行导致屏幕卡顿,并输出目标消息,这种方式可通过检测主线程中目标消息的执行时长,精确定位输出导致屏幕卡顿的目标消息。In the embodiment of the present invention, the first time of executing the target message in the message queue of the main thread and the second time of executing the message after the target message are determined, and the execution time of the target message is determined according to the first time and the second time, if executed If the duration is greater than the preset threshold, it is determined that the execution of the target message causes the screen to be jammed and the target message is output. This manner can accurately locate the target message that causes the screen to be jammed by detecting the execution duration of the target message in the main thread.
请参照图3,为本发明实施例提供的又一种程序检测方法的流程图;该方法可包括以下步骤S300-步骤S304。Please refer to FIG. 3, which is a flowchart of still another method for detecting a program according to an embodiment of the present invention; the method may include the following steps S300-S304.
S300,在系统所述主线程的消息执行函数上注册回调通知。S300, registering a callback notification on a message execution function of the main thread of the system.
具体实施例中,为了能够监测主线程中每一个函数的执行时间,在系统的主线程的消息执行函数上注册回调通知。In a specific embodiment, in order to be able to monitor the execution time of each function in the main thread, a callback notification is registered on the message execution function of the main thread of the system.
S301,当所述主线程的消息队列中目标消息执行时,获取系统的第一回调通知,所述第一回调通知携带所述目标消息执行的第一时间。S301. Acquire a first callback notification of the system when the target message in the message queue of the main thread is executed, where the first callback notification carries the first time when the target message is executed.
具体实施例中,当系统执行主线程的消息队列中的目标消息时,即可返回第一回调通知,该第一回调通知携带该目标消息执行的第一时间。In a specific embodiment, when the system executes the target message in the message queue of the main thread, the first callback notification may be returned, where the first callback notification carries the first time when the target message is executed.
S302,当所述目标消息之后的消息执行时,获取系统的第二回调通知,所述第二回调通知携带所述目标消息之后的消息执行的第二时间点。S302. Acquire a second callback notification of the system when the message after the target message is executed, where the second callback notification carries a second time point of execution of the message after the target message.
具体实施例中,当系统执行主线程的消息队列中的该目标消息之后的消息时,也可返回第二回调通知,该第二回调通知携带该目标消息之后的消息的执行第二时间。In a specific embodiment, when the system executes the message after the target message in the message queue of the main thread, the second callback notification may also be returned, where the second callback notification carries the second time of execution of the message after the target message.
S303,根据所述第一时间与所述第二时间,确定所述目标消息的执行时长。S303. Determine, according to the first time and the second time, an execution duration of the target message.
S304,若所述执行时长大于预设阈值,则确定所述目标消息的执行导致屏幕卡顿,并输出所述目标消息。S304. If the execution duration is greater than a preset threshold, determining that execution of the target message causes the screen to be stuck and outputting the target message.
本发明实施例步骤S303-S304,请参照图1的实施例步骤S101-S102,在此不再赘述。For the steps S303-S304 of the embodiment of the present invention, refer to the steps S101-S102 of the embodiment of FIG. 1 , and details are not described herein again.
本发明实施例,检测主线程的消息队列中目标消息执行的第一时间以及在目标消息之后的消息执行的第二时间,根据第一时间与第二时间,确定目标消息的执行时长,若执行时长大于预设阈值,则确定目标消息的执行导致屏幕卡顿,并输出目标消息,这种方式可通过检测主线程中目标消息的执行时长,精确定位输出导致屏幕卡顿的目标消息。 In the embodiment of the present invention, the first time of executing the target message in the message queue of the main thread and the second time of executing the message after the target message are determined, and the execution time of the target message is determined according to the first time and the second time, if executed If the duration is greater than the preset threshold, it is determined that the execution of the target message causes the screen to be jammed and the target message is output. This manner can accurately locate the target message that causes the screen to be jammed by detecting the execution duration of the target message in the main thread.
下面将结合附图7-附图9,对本发明实施例提供的一种程序检测装置进行详细介绍。A program detecting apparatus according to an embodiment of the present invention will be described in detail below with reference to FIG. 7 to FIG.
请参阅图7,为本发明实施例提供的一种程序检测装置的结构示意图;该装置可包括:检测模块100、确定模块101以及确定输出模块102;FIG. 7 is a schematic structural diagram of a program detecting apparatus according to an embodiment of the present invention; the apparatus may include: a detecting module 100, a determining module 101, and a determining output module 102;
检测模块100,用于检测主线程的消息队列中目标消息执行的第一时间以及在所述目标消息之后的消息执行的第二时间;The detecting module 100 is configured to detect a first time when the target message is executed in the message queue of the main thread and a second time when the message after the target message is executed;
具体实施例中,Android应用程序是由消息驱动的,包括界面的显示以及程序逻辑的执行。其中界面的显示是在主线程中以一连串的屏幕刷新消息的形式不停的驱动刷新的。例如当用户手指滑动一个列表时,系统就会构造一个屏幕刷新消息抛到主线程的消息队列中,只有当这个屏幕刷新消息之前的消息都执行完毕后,这个消息才会执行,当这个屏幕刷新消息执行时屏幕才会显示下一帧的内容。一般来说屏幕刷新的频率是60fps,也就是说每个屏幕刷新消息执行的时间不能超过16毫秒,如果超过这个时长的话,用户就会感觉到卡顿。如图4所示,即是屏幕刷新消息执行的主线程示意图,屏幕刷新消息以16毫秒的频率在主线程中执行。In a specific embodiment, the Android application is message driven, including the display of the interface and the execution of the program logic. The display of the interface is driven in the form of a series of screen refresh messages in the main thread. For example, when the user swipes a list, the system constructs a screen refresh message and throws it into the message queue of the main thread. Only when the message before the screen refresh message is executed, the message will be executed when the screen is refreshed. The screen displays the contents of the next frame when the message is executed. Generally speaking, the frequency of screen refresh is 60fps, which means that each screen refresh message can not be executed for more than 16 milliseconds. If this time is exceeded, the user will feel the card. As shown in FIG. 4, it is a schematic diagram of the main thread of the screen refresh message execution, and the screen refresh message is executed in the main thread at a frequency of 16 milliseconds.
往往程序开发者的一些功能逻辑也是以消息的形式在主线程中排队执行的,比如程序逻辑消息,如果一个由开发人员抛出的程序逻辑消息因为本身执行时间过长而阻塞了屏幕刷新消息的话,卡顿就发生了。如图5所示,若该程序逻辑消息的执行时间超过预设阈值,则阻塞了屏幕刷新消息的执行,屏幕出现卡顿。Often some of the functional logic of a program developer is also queued for execution in the main thread in the form of a message, such as a program logic message, if a program logic message thrown by a developer blocks the screen refresh message because its execution time is too long. Carton happened. As shown in FIG. 5, if the execution time of the program logic message exceeds a preset threshold, the execution of the screen refresh message is blocked, and the screen appears to be stuck.
而在实际研发过程中,是需要能够准确定位到产生卡顿的程序逻辑消息,这样可以将该程序逻辑消息移除主线程执行。本发明提供了一种机制,能够自动检测出这种执行时间过长的消息。In the actual development process, it is necessary to be able to accurately locate the program logic message that generates the stuck, so that the program logic message can be removed from the main thread for execution. The present invention provides a mechanism for automatically detecting such a message that is too long to execute.
在主线程中,各个消息是以消息队列的形式依次排队执行的,获取主线程消息队列中目标消息执行的第一时间以及在目标消息之后的消息执行的第二时间。目标消息可以是主线程的消息队列前端的消息,即是即将执行的消息,该消息的类型可能为程序逻辑消息,也可能为屏幕刷新消息。In the main thread, each message is queued and executed in the form of a message queue, and the first time when the target message in the main thread message queue is executed and the second time after the target message is executed are acquired. The target message may be a message of the main thread's message queue front end, that is, a message to be executed, and the type of the message may be a program logic message or a screen refresh message.
检测模块100可以有以下两种可选的实施方式:The detection module 100 can have the following two alternative implementations:
在第一种可选的实施方式中,如图8所示,检测模块100包括第一确定单 元1000、设置单元1001以及第二确定单元1002;In a first optional implementation manner, as shown in FIG. 8, the detecting module 100 includes a first determining list. a unit 1000, a setting unit 1001 and a second determining unit 1002;
第一确定单元1000,用于当检测到所述第一检测消息执行时,将所述第一检测消息的执行时间确定为所述主线程的消息队列中目标消息执行的第一时间;The first determining unit 1000 is configured to determine, when the first detection message is executed, an execution time of the first detection message as a first time when the target message in the message queue of the main thread is executed;
具体实施例中,为了能够检测执行目标消息的第一时间,以及执行该目标消息之后的消息的第二时间,如图6所示,本发明在程序启动的时候会启动一个检测线程用于监控主线程的消息执行。实现方法可以是不断的向主线程的消息队列前端抛送检测消息。In a specific embodiment, in order to be able to detect the first time of executing the target message and the second time of executing the message after the target message, as shown in FIG. 6, the present invention starts a detection thread for monitoring when the program is started. The main thread's message is executed. The implementation method may be to continuously send a detection message to the message queue front end of the main thread.
如图6所示,当主线程的刷新消息正在执行时,在主线程的消息队列前端设置第一检测消息“0”,当第一检测消息“0”执行时,第一确定单元1000将该第一检测消息“0”的执行时间确定为该主线程的消息队列中目标消息(即是程序逻辑消息)执行的第一时间。As shown in FIG. 6, when the refresh message of the main thread is being executed, the first detection message “0” is set in the front end of the message queue of the main thread, and when the first detection message “0” is executed, the first determining unit 1000 The execution time of a detection message "0" is determined as the first time the target message (ie, the program logic message) in the message queue of the main thread is executed.
设置单元1001,用于将所述目标消息出队,并继续在所述主线程的消息队列的前端设置第二检测消息;a setting unit 1001, configured to dequeue the target message, and continue to set a second detection message at a front end of the message queue of the main thread;
具体实施例中,第一检测消息的执行时间非常短,几乎在微秒级别,当第一检测消息执行时,目标消息(即是程序逻辑消息)出队执行,设置单元1001同时在主线程的消息队列的前端继续设置第二检测消息“1”。In a specific embodiment, the execution time of the first detection message is very short, almost at the microsecond level. When the first detection message is executed, the target message (ie, the program logic message) is dequeued, and the setting unit 1001 is simultaneously in the main thread. The front end of the message queue continues to set the second detection message "1".
第二确定单元1002,用于当执行到所述第二检测消息时,将所述第二检测消息的执行时间确定为在所述目标消息之后的消息执行的第二时间。The second determining unit 1002 is configured to determine, when the second detection message is executed, an execution time of the second detection message as a second time of execution of the message after the target message.
具体实施例中,当第二检测消息“1”执行时,第二确定单元1002将该第二检测消息“1”的执行时间确定为该目标消息(即是程序逻辑消息)之后的消息(即是屏幕刷新消息)执行的第二时间。因为当第二检测消息“1”执行到时,则说明程序逻辑消息刚好执行完。In a specific embodiment, when the second detection message "1" is executed, the second determining unit 1002 determines the execution time of the second detection message "1" as the message after the target message (ie, the program logic message) (ie, Is the screen refresh message) the second time of execution. Because when the second detection message "1" is executed, it indicates that the program logic message is just finished.
根据第一时间和第二时间可以确定该目标消息(即是程序逻辑消息)的执行时长,执行时长小于预设阈值,则目标消息后的消息出队,并向主线程消息队列前端继续抛送下一个检测消息,执行时长大于预设阈值,说明主线程中正在执行的目标消息太耗时,可以引起界面的卡顿,输出用于定位目标消息的查询信息,根据查询信息查询目标信息,并输出该目标消息,方便开发人员定位卡顿的源头。 The execution time of the target message (that is, the program logic message) may be determined according to the first time and the second time, and the execution time is less than the preset threshold, and the message after the target message is dequeued, and the message is sent to the front end of the main thread message queue. The next detection message, the execution time is greater than the preset threshold, indicating that the target message being executed in the main thread is too time consuming, may cause the interface to be stuck, output query information for locating the target message, and query the target information according to the query information, and The target message is output to facilitate the developer to locate the source of the card.
在第二种可选的实施方式中,所述装置还包括注册模块,检测模块100可以包括第一获取单元1003以及第二获取单元1004;In a second optional implementation manner, the device further includes a registration module, and the detection module 100 may include a first obtaining unit 1003 and a second obtaining unit 1004;
注册模块,用于在系统所述主线程的消息执行函数上注册回调通知;a registration module, configured to register a callback notification on a message execution function of the main thread of the system;
具体实施例中,为了能够监测主线程中每一个函数的执行时间,在系统的主线程的消息执行函数上注册回调通知。In a specific embodiment, in order to be able to monitor the execution time of each function in the main thread, a callback notification is registered on the message execution function of the main thread of the system.
第一获取单元1003,用于当所述主线程的消息队列中目标消息执行时,获取系统的第一回调通知,所述第一回调通知携带所述目标消息执行的第一时间;The first obtaining unit 1003 is configured to acquire a first callback notification of the system when the target message in the message queue of the main thread is executed, where the first callback notification carries the first time when the target message is executed;
具体实施例中,当系统执行主线程的消息队列中的目标消息时,即可返回第一回调通知,第一获取单元1003获取系统的第一回调通知,该第一回调通知携带该目标消息执行的第一时间。In a specific embodiment, when the system performs the target message in the message queue of the main thread, the first callback notification may be returned, and the first obtaining unit 1003 acquires a first callback notification of the system, where the first callback notification carries the target message. The first time.
第二获取单元1004,用于当所述目标消息之后的消息执行时,获取系统的第二回调通知,所述第二回调通知携带所述目标消息之后的消息执行的第二时间点。The second obtaining unit 1004 is configured to acquire a second callback notification of the system when the message after the target message is executed, where the second callback notification carries a second time point of execution of the message after the target message.
具体实施例中,当系统执行主线程的消息队列中的该目标消息之后的消息时,也可返回第二回调通知,该第二回调通知携带该目标消息之后的消息的执行第二时间。In a specific embodiment, when the system executes the message after the target message in the message queue of the main thread, the second callback notification may also be returned, where the second callback notification carries the second time of execution of the message after the target message.
确定模块101,用于根据所述第一时间与所述第二时间,确定所述目标消息的执行时长;The determining module 101 is configured to determine an execution duration of the target message according to the first time and the second time;
具体实施例中,确定模块101根据目标消息执行的第一时间以及目标消息之后的消息执行的第二时间,即可确定目标消息的执行时长,如图5所示,根据主线程第一个屏幕刷新消息执行的第一时间和该屏幕刷新消息之后的程序逻辑消息执行的第二时间,即可计算出第一个屏幕刷新消息的执行时长。In a specific embodiment, the determining module 101 determines the execution time of the target message according to the first time executed by the target message and the second time after the message execution of the target message, as shown in FIG. 5, according to the first screen of the main thread. The execution time of the first screen refresh message can be calculated by refreshing the first time of execution of the message and the second time of execution of the program logic message after the screen refresh message.
可选的,所述确定模块101具体用于计算所述第一时间和所述第二时间之间所形成的时长,并将所述时长确定为所述目标消息的执行时长。Optionally, the determining module 101 is specifically configured to calculate a duration formed between the first time and the second time, and determine the duration as an execution duration of the target message.
具体实施例中,计算第一时间和第二时间之间所形成的时长,可选的,计算方法可以是将第二时间点减去第一时间点,例如,第一时间是第5ms(相对于整个程序执行时间),第二时间是第17ms(相对于整个程序执行时间),则时长为17ms-5ms=12ms,该时长即是目标消息的执行时长。 In a specific embodiment, calculating a duration formed between the first time and the second time, optionally, the calculating method may be: subtracting the second time point from the first time point, for example, the first time is 5 ms (relative For the entire program execution time), the second time is 17ms (relative to the entire program execution time), and the duration is 17ms-5ms=12ms, which is the execution time of the target message.
确定输出模块102,用于若所述执行时长大于预设阈值,则确定所述目标消息的执行导致屏幕卡顿,并输出所述目标消息。Determining the output module 102, if the execution duration is greater than a preset threshold, determining that execution of the target message causes the screen to be stuck, and outputting the target message.
具体实施例中,若执行时长大于预设阈值,则说明该目标消息的执行时间过长,可能阻塞屏幕刷新消息的执行,从而导致屏幕卡顿,为了能够使得研发人员明确知道是哪一个目标消息导致卡顿,确定输出模块102输出该执行时间过长的目标消息。In a specific embodiment, if the execution duration is greater than the preset threshold, the execution time of the target message is too long, which may block the execution of the screen refresh message, thereby causing the screen to be stuck, in order to enable the developer to know which target message is explicitly known. As a result of the stuck, it is determined that the output module 102 outputs the target message whose execution time is too long.
根据本发明的一个实施例,根据图1至3所示的程序检测方法可以是由图7至9所示的程序检测装置中的各个单元来执行。例如,图1中所示的步骤S100、S101及S102可以分别由图7中所示的检测模块100、确定模块101以及确定输出模块102来执行。图2中所示的步骤S200、S201、S202、S203及S204可以分别由图7及图8中所示的第一确定单元1000、设置单元1001、第二确定单元1002、确定模块101以及确定输出模块102来执行。图3中所示的步骤S300、S301、S302、S303及S304可以分别由图7及图9中所示的注册模块(图未示)、第一获取单元1003、第二获取单元1004、确定模块101以及确定输出模块102来执行。According to an embodiment of the present invention, the program detecting method according to FIGS. 1 to 3 may be performed by each unit in the program detecting device shown in FIGS. 7 to 9. For example, steps S100, S101, and S102 shown in FIG. 1 may be performed by the detection module 100, the determination module 101, and the determination output module 102 shown in FIG. 7, respectively. Steps S200, S201, S202, S203, and S204 shown in FIG. 2 may be respectively performed by the first determining unit 1000, the setting unit 1001, the second determining unit 1002, the determining module 101, and the determination output shown in FIGS. 7 and 8. Module 102 is executed. Steps S300, S301, S302, S303, and S304 shown in FIG. 3 may be respectively performed by the registration module (not shown) shown in FIG. 7 and FIG. 9, the first acquisition unit 1003, the second acquisition unit 1004, and the determination module. 101 and determining the output module 102 to execute.
根据本发明的另一个实施例,图7至9所示的程序检测装置中的各个单元可以分别或全部合并为一个或若干个另外的单元来构成,或者其中的某个(些)单元还可以再拆分为功能上更小的多个单元来构成,这可以实现同样的操作,而不影响本发明的实施例的技术效果的实现。上述单元是基于逻辑功能划分的,在实际应用中,一个单元的功能也可以由多个单元来实现,或者多个单元的功能由一个单元实现。在本发明的其它实施例中,终端设备也可以包括其它模块。但在实际应用中,这些功能也可以由其它单元协助实现,并且可以由多个单元协作实现。According to another embodiment of the present invention, each unit in the program detecting apparatus shown in FIGS. 7 to 9 may be separately or entirely combined into one or several other units, or one of the units may also be It is further divided into a plurality of functionally smaller units, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present invention. The above units are divided based on logical functions. In practical applications, the functions of one unit may also be implemented by multiple units, or the functions of multiple units may be implemented by one unit. In other embodiments of the invention, the terminal device may also include other modules. However, in practical applications, these functions can also be implemented by other units, and can be implemented by multiple units.
根据本发明的另一个实施例,可以通过在包括中央处理单元(CPU)、随机存取存储器(RAM)、只读存储器(ROM)等处理元件和存储元件的例如计算机的通用计算设备上运行能够执行如图1至3中所示的程序检测方法的计算机程序(包括程序代码),来构造如图7至9中所示的程序检测装置,以及来实现根据本发明的实施例的程序检测方法。所述计算机程序可以记载于例如计算机可读记录介质上,并通过计算机可读记录介质装载于上述计算设备中,并 在其中运行。According to another embodiment of the present invention, it is possible to operate on a general-purpose computing device such as a computer including a processing unit and a storage element including a central processing unit (CPU), a random access memory (RAM), a read only memory (ROM), and the like. A computer program (including program code) for performing the program detecting method as shown in FIGS. 1 to 3 to construct a program detecting device as shown in FIGS. 7 to 9, and a program detecting method according to an embodiment of the present invention . The computer program can be recorded, for example, on a computer readable recording medium, and loaded in the above computing device by a computer readable recording medium, and Run in it.
本发明实施例,检测主线程的消息队列中目标消息执行的第一时间以及在目标消息之后的消息执行的第二时间,根据第一时间与第二时间,确定目标消息的执行时长,若执行时长大于预设阈值,则确定目标消息的执行导致屏幕卡顿,并输出目标消息,这种方式可通过检测主线程中目标消息的执行时长,精确定位输出导致屏幕卡顿的目标消息。In the embodiment of the present invention, the first time of executing the target message in the message queue of the main thread and the second time of executing the message after the target message are determined, and the execution time of the target message is determined according to the first time and the second time, if executed If the duration is greater than the preset threshold, it is determined that the execution of the target message causes the screen to be jammed and the target message is output. This manner can accurately locate the target message that causes the screen to be jammed by detecting the execution duration of the target message in the main thread.
请参阅图10,图10为本发明实施例提供的另一种程序检测装置的结构示意图。如图10所示,所述程序检测装置可以包括至少一个处理器1101,例如,CPU,至少一个通信总线1102,用户接口1103,至少一个网络接口1104,以及存储器1105。其中,所述通信总线1102用于实现这些组件之间的连接通信。其中,用户接口1103可以包括显示屏(Display)、键盘(Keyboard),可选用户接口1103还可以包括标准的有线接口、无线接口。网络接口1104可选的可以包括标准的有线接口、无线接口(如WI-FI接口、蓝牙接口)。所述存储器1105可以是高速RAM存储器,也可以是非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。所述存储器1105可选的还可以是至少一个位于远离前述处理器1101的存储装置。作为一种计算机存储介质的存储器1105中还可以包括操作系统、网络通信模块、用户接口模块以及数据处理应用。Referring to FIG. 10, FIG. 10 is a schematic structural diagram of another program detecting apparatus according to an embodiment of the present invention. As shown in FIG. 10, the program detecting means may include at least one processor 1101, such as a CPU, at least one communication bus 1102, a user interface 1103, at least one network interface 1104, and a memory 1105. The communication bus 1102 is used to implement connection communication between these components. The user interface 1103 can include a display and a keyboard. The optional user interface 1103 can also include a standard wired interface and a wireless interface. The network interface 1104 can optionally include a standard wired interface, a wireless interface (such as a WI-FI interface, a Bluetooth interface). The memory 1105 may be a high speed RAM memory or a non-volatile memory such as at least one disk memory. The memory 1105 can also optionally be at least one storage device located away from the processor 1101. The memory 1105 as a computer storage medium may further include an operating system, a network communication module, a user interface module, and a data processing application.
在图10所示的数据处理装置中,当上述装置为用户终端时,网络接口1104主要用于连接服务器,与服务器进行数据通信。其中所述存储器1105中存储一组程序代码,且所述处理器1101调用所述存储器1105中存储的程序代码,用于执行以下操作:In the data processing apparatus shown in FIG. 10, when the above apparatus is a user terminal, the network interface 1104 is mainly used to connect to a server and perform data communication with the server. The memory 1105 stores a set of program codes, and the processor 1101 calls the program code stored in the memory 1105 to perform the following operations:
检测主线程的消息队列中目标消息执行的第一时间以及在所述目标消息之后的消息执行的第二时间;Detecting a first time when the target message is executed in the message queue of the main thread and a second time of executing the message after the target message;
根据所述第一时间与所述第二时间,确定所述目标消息的执行时长;及Determining, according to the first time and the second time, an execution duration of the target message; and
若所述执行时长大于预设阈值,则确定所述目标消息的执行导致屏幕卡顿,并输出所述目标消息。If the execution duration is greater than a preset threshold, determining that execution of the target message causes the screen to jam and output the target message.
在一可选实施例中,所述处理器1101调用所述存储器1105中存储的程序代码所述根据所述第一时间与所述第二时间,确定所述目标消息的执行时长, 可以包括:In an optional embodiment, the processor 1101 invokes a program code stored in the memory 1105 to determine an execution duration of the target message according to the first time and the second time, Can include:
计算所述第一时间和所述第二时间之间所形成的时长,并将所述时长确定为所述目标消息的执行时长。Calculating a duration formed between the first time and the second time, and determining the duration as an execution duration of the target message.
在一可选实施例中,处理器1101调用存储器1105中存储的程序代码,用于执行以下操作:In an alternate embodiment, processor 1101 invokes program code stored in memory 1105 for performing the following operations:
当检测到所述第一检测消息执行时,将所述第一检测消息的执行时间确定为所述主线程的消息队列中目标消息执行的第一时间;Determining, when the first detection message is executed, an execution time of the first detection message as a first time of execution of a target message in a message queue of the main thread;
将所述目标消息出队,并继续在所述主线程的消息队列的前端设置第二检测消息;Dequeuing the target message, and continuing to set a second detection message at a front end of the message queue of the main thread;
当执行到所述第二检测消息时,将所述第二检测消息的执行时间确定为在所述目标消息之后的消息执行的第二时间;Determining, when the second detection message is executed, an execution time of the second detection message as a second time of execution of the message after the target message;
根据所述第一时间与所述第二时间,确定所述目标消息的执行时长;及Determining, according to the first time and the second time, an execution duration of the target message; and
若所述执行时长大于预设阈值,则确定所述目标消息的执行导致屏幕卡顿,并输出所述目标消息。If the execution duration is greater than a preset threshold, determining that execution of the target message causes the screen to jam and output the target message.
在一可选实施例中,处理器1101调用存储器1105中存储的程序代码,用于执行以下操作:In an alternate embodiment, processor 1101 invokes program code stored in memory 1105 for performing the following operations:
在系统所述主线程的消息执行函数上注册回调通知;Registering a callback notification on a message execution function of the main thread of the system;
当所述主线程的消息队列中目标消息执行时,获取系统的第一回调通知,所述第一回调通知携带所述目标消息执行的第一时间;Obtaining a first callback notification of the system when the target message in the message queue of the main thread is executed, where the first callback notification carries the first time when the target message is executed;
当所述目标消息之后的消息执行时,获取系统的第二回调通知,所述第二回调通知携带所述目标消息之后的消息执行的第二时间点;Obtaining a second callback notification of the system when the message following the target message is executed, where the second callback notification carries a second time point of execution of the message after the target message;
根据所述第一时间与所述第二时间,确定所述目标消息的执行时长;及Determining, according to the first time and the second time, an execution duration of the target message; and
若所述执行时长大于预设阈值,则确定所述目标消息的执行导致屏幕卡顿,并输出所述目标消息。If the execution duration is greater than a preset threshold, determining that execution of the target message causes the screen to jam and output the target message.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,附图7-附图9所示程序检测装置的模块对应的程序可存储在程序检测装置的可读存储介质内,并被该程序检测装置中的至少一个处理器执行,以实现上述程序检测方法,该方法包括图1至图6中各方法实施例所述 的流程。A person skilled in the art can understand that all or part of the process of implementing the above embodiment method can be completed by computer program related hardware, and the program can be stored in a computer readable storage medium, FIG. 7 - a program corresponding to the module of the program detecting means shown in FIG. 9 can be stored in a readable storage medium of the program detecting means and executed by at least one of the program detecting means to implement the above-described program detecting method, the method Including the method embodiments of FIG. 1 to FIG. Process.
在流程图中表示或在此以其他方式描述的逻辑和/或步骤,例如,可以被认为是用于实现逻辑功能的可执行指令的定序列表,可以具体实现在任何计算机可读介质中,以供指令执行系统、装置或设备(如基于计算机的系统、包括处理器的系统或其他可以从指令执行系统、装置或设备取指令并执行指令的系统)使用,或结合这些指令执行系统、装置或设备而使用。就本说明书而言,"计算机可读介质"可以是任何可以包含、存储、通信、传播或传输程序以供指令执行系统、装置或设备或结合这些指令执行系统、装置或设备而使用的装置。计算机可读介质的更具体的示例(非穷尽性列表)包括以下:具有一个或多个布线的电连接部(电子装置),便携式计算机盘盒(磁装置),随机存取存储器(RAM),只读存储器(ROM),可擦除可编辑只读存储器(EPROM或闪速存储器),光纤装置,以及便携式光盘只读存储器(CDROM)。另外,计算机可读介质甚至可以是可在其上打印所述程序的纸或其他合适的介质,因为可以例如通过对纸或其他介质进行光学扫描,接着进行编辑、解译或必要时以其他合适方式进行处理来以电子方式获得所述程序,然后将其存储在计算机存储器中。The logic and/or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be embodied in any computer readable medium, Used in conjunction with, or in conjunction with, an instruction execution system, apparatus, or device (eg, a computer-based system, a system including a processor, or other system that can fetch instructions and execute instructions from an instruction execution system, apparatus, or device) Or use with equipment. For the purposes of this specification, a "computer-readable medium" can be any apparatus that can contain, store, communicate, propagate, or transport a program for use in an instruction execution system, apparatus, or device, or in conjunction with the instruction execution system, apparatus, or device. More specific examples (non-exhaustive list) of computer readable media include the following: electrical connections (electronic devices) having one or more wires, portable computer disk cartridges (magnetic devices), random access memory (RAM), Read only memory (ROM), erasable editable read only memory (EPROM or flash memory), fiber optic devices, and portable compact disk read only memory (CDROM). In addition, the computer readable medium may even be a paper or other suitable medium on which the program can be printed, as it may be optically scanned, for example by paper or other medium, followed by editing, interpretation or, if appropriate, other suitable The method is processed to obtain the program electronically and then stored in computer memory.
应当理解,本发明的各部分可以用硬件、软件、固件或它们的组合来实现。在上述实施方式中,多个步骤或方法可以用存储在存储器中且由合适的指令执行系统执行的软件或固件来实现。例如,如果用硬件来实现,和在另一实施方式中一样,可用本领域公知的下列技术中的任一项或他们的组合来实现:具有用于对数据信号实现逻辑功能的逻辑门电路的离散逻辑电路,具有合适的组合逻辑门电路的专用集成电路,可编程门阵列(PGA),现场可编程门阵列(FPGA)等。It should be understood that portions of the invention may be implemented in hardware, software, firmware or a combination thereof. In the above-described embodiments, multiple steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented by any one or combination of the following techniques well known in the art: having logic gates for implementing logic functions on data signals. Discrete logic circuits, application specific integrated circuits with suitable combinational logic gates, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.
上述提到的存储介质可以是只读存储器,磁盘或光盘等。尽管上面已经示出和描述了本发明的实施例,可以理解的是,上述实施例是示例性的,不能理解为对本发明的限制,本领域的普通技术人员在本发明的范围内可以对上述实施例进行变化、修改、替换和变型。 The above mentioned storage medium may be a read only memory, a magnetic disk or an optical disk or the like. Although the embodiments of the present invention have been shown and described, it is understood that the above-described embodiments are illustrative and are not to be construed as limiting the scope of the invention. The embodiments are subject to variations, modifications, substitutions and variations.

Claims (10)

  1. 一种程序检测方法,其特征在于,包括:A program detection method, comprising:
    检测主线程的消息队列中目标消息执行的第一时间以及在所述目标消息之后的消息执行的第二时间;Detecting a first time when the target message is executed in the message queue of the main thread and a second time of executing the message after the target message;
    根据所述第一时间与所述第二时间,确定所述目标消息的执行时长;Determining an execution duration of the target message according to the first time and the second time;
    若所述执行时长大于预设阈值,则确定所述目标消息的执行导致屏幕卡顿,并输出所述目标消息。If the execution duration is greater than a preset threshold, determining that execution of the target message causes the screen to jam and output the target message.
  2. 如权利要求1所述的程序检测方法,其特征在于,所述主线程的消息队列包括至少一个消息,所述至少一个消息中每个消息的类型为程序逻辑消息或者屏幕刷新消息。The program detection method according to claim 1, wherein the message queue of the main thread includes at least one message, and each of the at least one message is of a program logic message or a screen refresh message.
  3. 如权利要求2所述的程序检测方法,其特征在于,所述根据所述第一时间与所述第二时间,确定所述目标消息的执行时长,包括:The program detection method according to claim 2, wherein the determining the execution duration of the target message according to the first time and the second time comprises:
    计算所述第一时间和所述第二时间之间所形成的时长,并将所述时长确定为所述目标消息的执行时长。Calculating a duration formed between the first time and the second time, and determining the duration as an execution duration of the target message.
  4. 如权利要求1所述的程序检测方法,其特征在于,所述主线程的消息队列前端设置第一检测消息,所述第一检测消息在所述目标消息之前;The program detection method according to claim 1, wherein the message queue front end of the main thread sets a first detection message, and the first detection message is before the target message;
    所述检测主线程的消息队列中目标消息执行的第一时间以及在所述目标消息之后的消息执行的第二时间,包括:The detecting the first time of execution of the target message in the message queue of the main thread and the second time of executing the message after the target message include:
    当检测到所述第一检测消息执行时,将所述第一检测消息的执行时间确定为所述主线程的消息队列中目标消息执行的第一时间;Determining, when the first detection message is executed, an execution time of the first detection message as a first time of execution of a target message in a message queue of the main thread;
    将所述目标消息出队,并继续在所述主线程的消息队列的前端设置第二检测消息;Dequeuing the target message, and continuing to set a second detection message at a front end of the message queue of the main thread;
    当执行到所述第二检测消息时,将所述第二检测消息的执行时间确定为在所述目标消息之后的消息执行的第二时间。 When the second detection message is executed, the execution time of the second detection message is determined to be the second time when the message following the target message is executed.
  5. 如权利要求1至4中任一项所述的程序检测方法,其特征在于,所述检测主线程的消息队列中目标消息执行的第一时间以及在所述目标消息之后的消息执行的第二时间之前,还包括:The program detecting method according to any one of claims 1 to 4, wherein the detecting the first time in which the target message is executed in the message queue of the main thread and the second execution of the message following the target message Before time, it also includes:
    在系统所述主线程的消息执行函数上注册回调通知;Registering a callback notification on a message execution function of the main thread of the system;
    所述检测主线程的消息队列中目标消息执行的第一时间以及在所述目标消息之后的消息执行的第二时间,包括:The detecting the first time of execution of the target message in the message queue of the main thread and the second time of executing the message after the target message include:
    当所述主线程的消息队列中目标消息执行时,获取系统的第一回调通知,所述第一回调通知携带所述目标消息执行的第一时间;Obtaining a first callback notification of the system when the target message in the message queue of the main thread is executed, where the first callback notification carries the first time when the target message is executed;
    当所述目标消息之后的消息执行时,获取系统的第二回调通知,所述第二回调通知携带所述目标消息之后的消息执行的第二时间点。And when the message following the target message is executed, acquiring a second callback notification of the system, where the second callback notification carries a second time point of execution of the message after the target message.
  6. 一种程序检测装置,其特征在于,包括:A program detecting device, comprising:
    检测模块,用于检测主线程的消息队列中目标消息执行的第一时间以及在所述目标消息之后的消息执行的第二时间;a detecting module, configured to detect a first time when the target message is executed in the message queue of the main thread and a second time after the message is executed after the target message;
    确定模块,用于根据所述第一时间与所述第二时间,确定所述目标消息的执行时长;a determining module, configured to determine an execution duration of the target message according to the first time and the second time;
    确定输出模块,用于若所述执行时长大于预设阈值,则确定所述目标消息的执行导致屏幕卡顿,并输出所述目标消息。Determining an output module, if the execution duration is greater than a preset threshold, determining that execution of the target message causes the screen to be stuck and outputting the target message.
  7. 如权利要求6所述的程序检测装置,其特征在于,所述主线程的消息队列包括至少一个消息,所述至少一个消息中每个消息的类型为程序逻辑消息或者屏幕刷新消息。The program detecting apparatus according to claim 6, wherein the message queue of the main thread includes at least one message, and each of the at least one message is of a program logic message or a screen refresh message.
  8. 如权利要求7所述的程序检测装置,其特征在于,所述确定模块具体用于计算所述第一时间和所述第二时间之间所形成的时长,并将所述时长确定为所述目标消息的执行时长。The program detecting apparatus according to claim 7, wherein the determining module is specifically configured to calculate a duration formed between the first time and the second time, and determine the duration as the The execution time of the target message.
  9. 如权利要求6所述的程序检测装置,其特征在于,所述主线程的消息队列前端设置第一检测消息,所述第一检测消息在所述目标消息之前;所述检 测模块包括:The program detecting apparatus according to claim 6, wherein the message queue front end of the main thread sets a first detection message, the first detection message is before the target message; The test module includes:
    第一确定单元,用于当检测到所述第一检测消息执行时,将所述第一检测消息的执行时间确定为所述主线程的消息队列中目标消息执行的第一时间;a first determining unit, configured to determine, when the first detection message is executed, an execution time of the first detection message as a first time of execution of a target message in a message queue of the main thread;
    设置单元,用于将所述目标消息出队,并继续在所述主线程的消息队列的前端设置第二检测消息;a setting unit, configured to dequeue the target message, and continue to set a second detection message at a front end of the message queue of the main thread;
    第二确定单元,用于当执行到所述第二检测消息时,将所述第二检测消息的执行时间确定为在所述目标消息之后的消息执行的第二时间。And a second determining unit, configured to determine, when the second detection message is executed, an execution time of the second detection message as a second time of execution of the message after the target message.
  10. 如权利要求6至9中任一项所述的程序检测装置,其特征在于,所述装置还包括:The program detecting device according to any one of claims 6 to 9, wherein the device further comprises:
    注册模块,用于在系统所述主线程的消息执行函数上注册回调通知;a registration module, configured to register a callback notification on a message execution function of the main thread of the system;
    所述检测模块包括:The detection module includes:
    第一获取单元,用于当所述主线程的消息队列中目标消息执行时,获取系统的第一回调通知,所述第一回调通知携带所述目标消息执行的第一时间;a first acquiring unit, configured to acquire a first callback notification of the system when the target message in the message queue of the main thread is executed, where the first callback notification carries the first time when the target message is executed;
    第二获取单元,用于当所述目标消息之后的消息执行时,获取系统的第二回调通知,所述第二回调通知携带所述目标消息之后的消息执行的第二时间点。 And a second acquiring unit, configured to acquire a second callback notification of the system when the message after the target message is executed, where the second callback notification carries a second time point of execution of the message after the target message.
PCT/CN2016/077653 2015-12-10 2016-03-29 Program detection method and device WO2017096734A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510916597.9A CN105389258B (en) 2015-12-10 2015-12-10 Program detection method and device
CN201510916597.9 2015-12-10

Publications (1)

Publication Number Publication Date
WO2017096734A1 true WO2017096734A1 (en) 2017-06-15

Family

ID=55421564

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/077653 WO2017096734A1 (en) 2015-12-10 2016-03-29 Program detection method and device

Country Status (2)

Country Link
CN (1) CN105389258B (en)
WO (1) WO2017096734A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3617889A4 (en) * 2017-06-27 2020-06-17 Huawei Technologies Co., Ltd. Stutter detection method and device
CN115268565A (en) * 2022-06-27 2022-11-01 北京五八信息技术有限公司 Timer control method and device and electronic equipment

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105389258B (en) * 2015-12-10 2020-08-14 腾讯科技(深圳)有限公司 Program detection method and device
CN106708613B (en) * 2016-05-05 2019-09-17 腾讯科技(深圳)有限公司 A kind of detection method and detection device of input control sensitivity
CN106484507B (en) * 2016-09-18 2019-11-29 天脉聚源(北京)传媒科技有限公司 A kind of processing method and processing device using thread
CN106776253B (en) * 2016-12-08 2020-08-04 武汉斗鱼网络科技有限公司 Interface card pause monitoring method and device
CN108345524B (en) * 2017-01-22 2021-12-14 腾讯科技(深圳)有限公司 Application program monitoring method and application program monitoring device
CN107038107B (en) * 2017-03-09 2020-03-17 武汉斗鱼网络科技有限公司 Method and device for acquiring application blocking information
CN106959918B (en) * 2017-04-25 2021-04-13 百度在线网络技术(北京)有限公司 Method and apparatus for evaluating operations in a robotic operating system
CN107273278B (en) * 2017-06-02 2019-10-25 Oppo广东移动通信有限公司 Caton determines method, apparatus and terminal
CN107678945B (en) * 2017-09-04 2020-04-21 清华大学 Method and device for judging webpage application blocking
CN107590060A (en) * 2017-09-05 2018-01-16 杭州时趣信息技术有限公司 A kind of analysis method and device of terminal interim card
EP3663925B1 (en) * 2017-10-09 2021-12-01 Huawei Technologies Co., Ltd. Method for processing refreshing display abnormality, and terminal
CN109840177B (en) * 2017-11-24 2021-08-24 腾讯科技(深圳)有限公司 Carton processing method and related equipment
CN109491907A (en) * 2018-11-05 2019-03-19 网易(杭州)网络有限公司 A kind of Caton detection method, device, electronic equipment and storage medium
CN110888781B (en) * 2019-11-21 2021-11-16 腾讯科技(深圳)有限公司 Application blockage detection method and detection device
CN114356789A (en) * 2022-03-21 2022-04-15 大鲲智联(成都)科技有限公司 Application program detection method and device, electronic equipment and computer readable medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103412812A (en) * 2013-08-23 2013-11-27 北京奇虎科技有限公司 Method and device for monitoring running status of browser
CN104965773A (en) * 2015-07-09 2015-10-07 网易(杭州)网络有限公司 Terminal, jamming detection method, device as well as game jamming detection method and device
CN104991855A (en) * 2015-06-16 2015-10-21 广州华多网络科技有限公司 Processing method and device for interface lag
US20150317769A1 (en) * 2014-04-30 2015-11-05 Vonage Network, Llc Systems and methods for controlling a display screen of a portable computing device
CN105389258A (en) * 2015-12-10 2016-03-09 腾讯科技(深圳)有限公司 Program detection method and apparatus

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007251232A (en) * 2006-03-13 2007-09-27 Oki Electric Ind Co Ltd Video reproducing unit having telephone function
CN101876938B (en) * 2009-11-11 2012-10-10 北京神州泰岳软件股份有限公司 Message queue-based application software response time measuring method
CN104184875B (en) * 2013-05-20 2019-01-11 中兴通讯股份有限公司 Open method, device and the terminal of terminal debugging port
IN2013MU02744A (en) * 2013-08-22 2015-07-03 Tata Consultancy Services Ltd
CN104834597B (en) * 2015-03-06 2017-12-26 深信服网络科技(深圳)有限公司 Using the measuring method and system of response time
CN105022627B (en) * 2015-06-02 2018-04-06 上海斐讯数据通信技术有限公司 A kind of communication means in android system between View

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103412812A (en) * 2013-08-23 2013-11-27 北京奇虎科技有限公司 Method and device for monitoring running status of browser
US20150317769A1 (en) * 2014-04-30 2015-11-05 Vonage Network, Llc Systems and methods for controlling a display screen of a portable computing device
CN104991855A (en) * 2015-06-16 2015-10-21 广州华多网络科技有限公司 Processing method and device for interface lag
CN104965773A (en) * 2015-07-09 2015-10-07 网易(杭州)网络有限公司 Terminal, jamming detection method, device as well as game jamming detection method and device
CN105389258A (en) * 2015-12-10 2016-03-09 腾讯科技(深圳)有限公司 Program detection method and apparatus

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3617889A4 (en) * 2017-06-27 2020-06-17 Huawei Technologies Co., Ltd. Stutter detection method and device
CN115268565A (en) * 2022-06-27 2022-11-01 北京五八信息技术有限公司 Timer control method and device and electronic equipment

Also Published As

Publication number Publication date
CN105389258A (en) 2016-03-09
CN105389258B (en) 2020-08-14

Similar Documents

Publication Publication Date Title
WO2017096734A1 (en) Program detection method and device
WO2018103245A1 (en) Method, device, and readable storage medium for monitoring interface lag
US20140007107A1 (en) Concurrent execution of a computer software application along multiple decision paths
KR20140091555A (en) Measuring web page rendering time
US11288164B2 (en) Dynamic distributed tracing instrumentation in a microservice architecture
US9466310B2 (en) Compensating for identifiable background content in a speech recognition device
US10564889B2 (en) Method and apparatus for processing data based on physical host
US20160313370A1 (en) Semiconductor device tester with dut data streaming
US10810019B2 (en) Method for interface refresh synchronization, terminal device, and non-transitory computer-readable storage medium
WO2016061941A1 (en) Exception handling method and device, and storage medium
CN112954056B (en) Method and device for processing monitoring data, electronic equipment and storage medium
US20140033097A1 (en) Method and apparatus of testing a computer program
RU2015107736A (en) AUDIO ACTIVATED AND / OR ACTIVATION BY AN AUDIO MODE AND / OR INSTRUMENT INSTALLING APPLICATION INSTRUMENT
US20160188361A1 (en) Systems and methods for determining desktop readiness using interactive measures
CN107122305B (en) Software testing device and method
CN106709330B (en) Method and device for recording file execution behaviors
CN111949512A (en) Application program jamming detection method and device, terminal and medium
CN111382017A (en) Fault query method, device, server and storage medium
US20180286140A1 (en) Information processing apparatus and information processing method
WO2018227475A1 (en) Fingerprint chip detection method, device and system
US11206156B2 (en) Method and apparatus for storing data of transmission signal, and computer readable storage medium
CN106708705B (en) Terminal background process monitoring method and system
CN111090570A (en) Method and device for measuring response time of terminal screen and terminal equipment
US11093346B2 (en) Uninterrupted backup operation using a time based approach
US20170139796A1 (en) Bus interface card detection system and method for detecting bus interface card

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16871940

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 07/11/2018)

122 Ep: pct application non-entry in european phase

Ref document number: 16871940

Country of ref document: EP

Kind code of ref document: A1