WO2017206476A1 - Method, device and apparatus for detecting cpu occupation - Google Patents

Method, device and apparatus for detecting cpu occupation Download PDF

Info

Publication number
WO2017206476A1
WO2017206476A1 PCT/CN2016/109542 CN2016109542W WO2017206476A1 WO 2017206476 A1 WO2017206476 A1 WO 2017206476A1 CN 2016109542 W CN2016109542 W CN 2016109542W WO 2017206476 A1 WO2017206476 A1 WO 2017206476A1
Authority
WO
WIPO (PCT)
Prior art keywords
function
function name
target application
name
information
Prior art date
Application number
PCT/CN2016/109542
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 WO2017206476A1 publication Critical patent/WO2017206476A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3024Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3065Monitoring arrangements determined by the means or processing involved in reporting the monitored data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging

Definitions

  • the present invention relates to the field of electronic technologies, and in particular, to a method, device and device for detecting CPU usage.
  • the embodiment of the invention provides a method, a device and a device for detecting CPU usage, which can obtain related information when an abnormality occurs in the CPU, so that the developer can optimize the application of the test according to the related information.
  • a first aspect of the embodiments of the present invention provides a method for detecting CPU usage, including:
  • the function name If the function name satisfies the preset function name recording condition, the function name is recorded.
  • the method further includes:
  • the recording the function name includes:
  • the function name and the class name corresponding to the function name are recorded.
  • the acquiring the function information of the target application running includes:
  • the acquiring a tracking information log file corresponding to the target application, from the tracking Obtaining function information of the target application running in the information log file including:
  • the determining whether the function name meets a preset function name recording condition includes:
  • the function name If the function name is in the preset blacklist corresponding to the target application, the function name satisfies the preset function name recording condition.
  • the method before the acquiring the function information of the target application, the method further includes:
  • an embodiment of the present invention provides a device for detecting CPU usage, including:
  • a first acquiring unit configured to acquire function information of the target application running when detecting that a CPU usage corresponding to the target application is greater than or equal to a preset threshold
  • a second acquiring unit configured to acquire a function name in function information of the target application running
  • a first determining unit configured to determine whether the function name satisfies a preset function name recording condition
  • a recording unit configured to record the function name if the first determining unit determines that the function name satisfies the preset function name recording condition.
  • a third obtaining unit configured to acquire a class name corresponding to the function name before the recording unit records the function name
  • the recording unit is specifically configured to:
  • the first determining unit determines that the function name satisfies the preset function name recording condition, records the function name and the class name corresponding to the function name.
  • the first acquiring unit is specifically configured to:
  • the first acquiring unit is specifically configured to:
  • the first determining unit is specifically configured to:
  • the function name If the function name is in the preset blacklist corresponding to the target application, the function name satisfies the preset function name recording condition.
  • the method further includes:
  • a second determining unit configured to determine whether the current time reaches a preset time point
  • the detecting unit is configured to: if the second determining unit determines that the current time reaches the preset time point, and detects whether the CPU usage corresponding to the target application is greater than or equal to the preset threshold.
  • the third aspect of the embodiment of the present invention provides a detection device occupied by a CPU, including: a processor, a memory, a communication interface, and a bus;
  • the processor, the memory, and the communication interface are connected by the bus and complete communication with each other; the memory stores executable program code; the processor reads an executable program stored in the memory by reading Code for running a program corresponding to the executable program code for performing a CPU occupancy detection method; wherein Methods include:
  • the function name If the function name satisfies the preset function name recording condition, the function name is recorded.
  • a fourth aspect of the embodiments of the present invention provides a storage medium, where the storage medium is used to store an application, and the application is configured to perform a CPU occupancy detection method according to an embodiment of the present invention at runtime.
  • a fifth aspect of the embodiments of the present invention provides an application program, where the application is configured to perform a CPU occupancy detection method according to an embodiment of the present invention at runtime.
  • the function information corresponding to the target application is obtained, the function name of the target application is obtained from the function information, and the function is determined. Whether the name satisfies the preset function name recording condition, and if so, records the function name.
  • the related function running information can be obtained by recording the name of the function running by the target application, so that the developer can optimize the application of the test according to the related information.
  • FIG. 1 is a schematic flowchart of a method for detecting CPU usage according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a TraceView file according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of an HTML file provided by an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a blacklist provided by an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a white list provided by an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of results of final recording provided by an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a device for detecting CPU usage according to an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of a detection device occupied by a CPU according to an embodiment of the present invention.
  • the devices described in the following embodiments of the invention include smart phones (such as Android phones, iOS phones, Windows Phone phones, etc.), tablets, emulators, and the like.
  • FIG. 1 is a schematic flowchart of a method for detecting CPU usage according to an embodiment of the present invention.
  • the detection method occupied by the CPU may include, but is not limited to, the following steps.
  • the acquiring function information of the target application running includes:
  • the tracking information log file is specifically a TraceView file
  • the tracking information log file includes function information of the target application running.
  • the trace information log of the .trace is generated in the system's storage space, such as the root directory of the Secure Digital (SD) card (English: log ) file, record the function information of the running of the app during this time.
  • SD Secure Digital
  • the TraceView file corresponding to the target application is obtained from the directory of the SD, so whether the mobile phone or the simulator needs to support the SD card, because TraceView The file will be saved to the SD card.
  • the system stores the TraceView file separately for each application when storing the TraceView file, and the corresponding TraceView file can be found according to the identifier of the target application.
  • the preset threshold may be set by default by the system, or may be manually set by the user, which is not specifically limited in the embodiment of the present invention. For example, the preset threshold is 50%.
  • FIG. 2 is a schematic diagram of the format of the TraceView file displayed in the Profile panel in the TraceView performance analysis tool.
  • the Name corresponding to the column 1 represents the function information, and the class name and the function name can be extracted from the Name. Listed are all the call items, the previous number is the number, double-click the "+" to the left of the function name to see that there are Parent and Children sub-items, which means that they are called and called. For example, if function A calls a function B, then function A is called “parents" of function B, and function B is called “children" of function A.
  • the "Incl Cpu Time%” corresponding to column 2 represents the percentage of the function's Inclusive Cpu Time as a percentage of the total time.
  • the “Inclusive Cpu Time” corresponding to column 3 refers to the time that the calling subfunction runs in addition to the time the statistical function itself runs.
  • the “Excl Cpu Time%” corresponding to column 4 refers to the white ratio of Exclusive Cpu Time to the total time.
  • the "Exclusive Cpu Time” corresponding to column 5 refers to the time when the statistical function itself runs. Take the name in Figure 2 as android.view.animation.Animation.getTransformation(JLandroid/view/animation/Transformation;)Z as an example.
  • the most recent field after () is the function name, ie getTransformation is The function name, a field before the function name, is the class name, that is, the Animation is the class name, or you can extract the entire field before () as the function name, ie android.view.animation.AnimationSet.getTransformation Function name.
  • the call time of the android.view.animation.Animation.getTransformation function is 326.998ms. If the call time is relatively long, look at the subfunction it calls. Among them, the call time of the sub-function android.view.animation.AnimationSet.getTransformation is 321.996ms, the relative time is longer. If you need to optimize the performance of the application, you need to execute the execution time of the function android.view.animation.AnimationSet.getTransformation. optimization.
  • the acquiring the function name in the function information of the target application operation includes: acquiring, by using the tracking information log file corresponding to the target application, a function in function information of the target application running name.
  • the function information corresponding to the target application is included in the tracking information log file corresponding to the target application, where the function information includes a name of a function that is run by the target application, and the function information may further include the target.
  • the function name may include, but is not limited to, the name of the animation function, the name of the interface update function, the name of the function that updates the time information, and the like.
  • a class can include multiple functions, and multiple classes can include the same function.
  • only the function name corresponding to the function run by the target application may be obtained, so that the function name is analyzed and the subsequent recording is performed.
  • the name of the function run by the target application and the class name corresponding to the name of the function may also be obtained, so as to facilitate analysis for the function name and subsequent recording.
  • the TraceView file can be used to generate a table of the TraceView file as shown in FIG. 2, and the function name and the class name corresponding to the function name are extracted from the generated table.
  • the acquiring the tracking information log file corresponding to the target application, and acquiring the function information of the target application running from the tracking information log file includes:
  • the HTML file is a parsable text file, and converting the TraceView file into a parsable HTML file is convenient for parsing the running function information of the target application, where the HTML file includes function information of the target application running,
  • the function information includes a function name of the target application, and further, the function information further includes a class name corresponding to the function name.
  • the file format of the HTML file can be seen in Figure 3.
  • FIG. 3 is a schematic diagram of a format of an HTML file according to an embodiment of the present invention.
  • the field corresponding to the Method item is the function information described in the embodiment of the present invention, and the Method item includes the function name and the class name corresponding to the function name, and the Method item is android.view.animation.AnimationSet .getTransformation(JLandroid/view/animation/Transformati on;)Z is an example.
  • the last field after () is the function name, that is, getTransformation is the function name, and the field after the function name.
  • AnimationSet is the class name
  • android.view.animation.AnimationSet.getTransformation is the function name
  • AnimationSet.java after the function name is extracted as Class name.
  • step S103 Determine whether the function name satisfies a preset function name recording condition. If yes, execute step S104.
  • the running state of the target application is analyzed according to the function name, and then information related to the abnormality of the CPU occupation is obtained.
  • the determining whether the function name meets a preset function name recording condition includes:
  • the system pre-establishes a blacklist and a whitelist, and the blacklist stores information that needs attention, such as an animation function name and an interface update function name.
  • the whitelist stores information that can be ignored, that is, information that is considered normal.
  • the obtained function name is analyzed. If the function name is information that belongs to the whitelist, the function name is not recorded; if the function name is blacklisted information, the record is a result that must be emphasized, the function name and the The class name corresponding to the function name is recorded.
  • the function name is neither a whitelist nor a blacklist, it may be recorded as a reference result or may not be recorded, which is not specifically limited in the embodiment of the present invention.
  • the function to be judged is If the field in the name includes the content in the blacklist, it is determined that the function name to be determined is in the blacklist. If the field in the function name to be determined includes the content in the whitelist, it is determined that the function name to be determined is in the Describe the white list.
  • the schematic diagram of the blacklist can be seen in FIG. 4, and the schematic diagram of the whitelist can be seen in FIG. 5.
  • the function names recorded in the blacklist are: Animation, Animator, MainLayout, weather toolbox, and deskbox.
  • the function names recorded in the whitelist are: Log and KLogBuffer.
  • the function name android.view.animation.AnimationSet.getTransformation contains the animation in the blacklist, therefore, it is determined that android.view.animation.AnimationSet.getTransformation is in the preset blacklist corresponding to the target application, then The function name satisfies the preset function name recording condition.
  • the function name is recorded, and after all the functions running by the target application are judged, the final detection result may be generated, and the detection result is generated. It can be stored in the form of a list, and the developer analyzes which functions of the target application are running according to the list, and a CPU occupation exception occurs.
  • the function name and the class name corresponding to the function name are recorded, thereby providing more developers with
  • the reference information can be used to generate a final detection result after all the functions running by the target application are judged, and the detection result can be stored in a list, thereby assisting the developer to record the function name and the class name.
  • a CPU usage exception occurs when analyzing which functions of which classes the target application is running.
  • the final result of the recording can be seen in FIG. 6.
  • the final result generated will record the name of the function to be concerned and the class name corresponding to the function name.
  • the recorded android.view.animation.AnimationSet.getTransformation is the function name
  • the recorded AnimationSet.java is the class name.
  • the function name is not recorded.
  • the CPU monitors the value of the CPU when the lock screen application is off. If the threshold value is exceeded, the TraceView file is captured. Convert the TraceView file to an HTML file. Automatically extract the function name of the HTML file and the corresponding class name, and match the blacklist and the whitelist according to the function name. The blacklist and the whitelist are pre-established, and the name of the function that needs attention is recorded in the blacklist, such as the name of the animation function. (When the screen is off, the name of the animation function is recognized as an exception call, which needs to be recorded.) The record in the whitelist is negligible.
  • the function name such as the function name of the update time information (automatic update of the execution system time information when the screen is off is recognized as a reasonable call, no need to record). If the function name to be judged belongs to the function name in the blacklist, the function name to be determined needs to be recorded; if the function name to be determined belongs to the function name in the white list, the function name to be determined need not be performed. recording. Provide the final generated records to the developer to assist developers in optimizing the lock screen application.
  • the tracking information log file corresponding to the target application is obtained, and the tracking information log file is used to obtain the a function name in the function information of the target application running, and determining whether the function name satisfies a preset function name recording condition, and if so, recording the function name; if not, not performing the function name recording.
  • the related function running information can be obtained by recording the name of the function running by the target application, so that the developer can optimize the application of the test according to the related information.
  • FIG. 7 is a schematic structural diagram of a device for detecting CPU usage according to an embodiment of the present invention.
  • the detecting device 70 occupied by the CPU includes: a first acquiring unit 701, a second obtaining unit 702, a first determining unit 703, and a recording unit 704, where
  • the first obtaining unit 701 is configured to acquire function information of the target application running when detecting that the CPU usage corresponding to the target application is greater than or equal to a preset threshold;
  • a second obtaining unit 702 configured to acquire a function name in function information of the target application running
  • the first determining unit 703 is configured to determine whether the function name satisfies a preset function name recording condition
  • the recording unit 704 is configured to record the function name if the first determining unit 703 determines that the function name satisfies the preset function name recording condition.
  • the CPU-used detecting device 70 further includes:
  • a third obtaining unit 705, configured to acquire a class name corresponding to the function name before the recording unit 704 records the function name;
  • the recording unit 704 is specifically configured to:
  • the first determining unit 703 determines that the function name satisfies the preset function name recording condition, the function name and the class name corresponding to the function name are recorded.
  • the first obtaining unit 701 is specifically configured to:
  • the first obtaining unit 701 is specifically configured to:
  • the first determining unit 703 is specifically configured to:
  • the function name If the function name is in the preset blacklist corresponding to the target application, the function name satisfies the preset function name recording condition.
  • the CPU-used detecting device 70 further includes:
  • the second determining unit 706 is configured to determine whether the current time reaches a preset time point
  • the detecting unit 707 is configured to: if the second determining unit 706 determines that the current time reaches the preset time point, and detects whether the CPU usage corresponding to the target application is greater than or equal to the preset threshold.
  • FIG. 8 is a schematic structural diagram of a detection device occupied by a CPU according to the present invention.
  • the detecting device 800 occupied by the CPU described in this embodiment includes: at least one processor 801, a communication interface 802, a user interface 803, and a memory 804, and the processor 801, the communication interface 802, the user interface 803, and the memory 804 can be connected through a bus or The other embodiments are connected, and the embodiment of the present invention is connected by a bus 805 as an example. among them,
  • the processor 801 can be a general purpose processor, such as a Central Processing Unit (CPU).
  • CPU Central Processing Unit
  • Communication interface 802 can be a wired interface (e.g., an Ethernet interface) or a wireless interface (e.g., a cellular network interface or a wireless local area network interface) for communicating with other devices or servers.
  • a wired interface e.g., an Ethernet interface
  • a wireless interface e.g., a cellular network interface or a wireless local area network interface
  • the user interface 803 may specifically be a touch panel, including a touch screen and a touch screen, for detecting an operation instruction on the touch panel, and the user interface 803 may also be a physical button or a mouse.
  • the user interface 803 can also be a display screen for outputting, displaying images or data.
  • the memory 804 may include a volatile memory (English: Volatile Memory), such as a random access memory (RAM); the memory may also include a non-volatile memory (English: Non-Volatile Memory), for example, only Read memory (English: Read-Only Memory, ROM), flash memory (English: Flash Memory), hard disk (English: Hard Disk Drive, HDD) or solid state drive (English: Solid-State Drive, SSD); A combination of memories of the above kind may be included.
  • the memory 804 is configured to store the preset threshold, the preset whitelist, the preset blacklist, and the preset time point described in the foregoing embodiments.
  • the memory 804 is configured to store the detection program code occupied by the CPU, and the processor 801 is configured to call the program code stored in the memory 804, and perform the following operations:
  • the processor 801 acquires function information of the target application running.
  • the processor 801 acquires a function name in the function information of the target application running
  • the processor 801 determines whether the function name satisfies a preset function name recording condition
  • the processor 801 If the function name satisfies the preset function name recording condition, the processor 801 records the function name.
  • the processor 801 is further configured to:
  • the processor 801 records the function name, including:
  • the processor 801 records the function name and the class name corresponding to the function name.
  • the processor 801 obtains function information about the running of the target application, including:
  • the processor 801 acquires a tracking information log file corresponding to the target application, and acquires function information of the target application running from the tracking information log file.
  • the processor 801 obtains the tracking information log file corresponding to the target application, and obtains the function information of the target application running from the tracking information log file, including:
  • the processor 801 acquires a tracking information log file corresponding to the target application, and converts the tracking information log file into an HTML file.
  • the processor 801 obtains function information of the target application running from the HTML file.
  • the processor 801 determines whether the function name meets a preset function name recording condition, including:
  • the processor 801 determines whether the function name is in a preset white list corresponding to the target application or a preset blacklist corresponding to the target application;
  • the function name If the function name is in the preset blacklist corresponding to the target application, the function name satisfies the preset function name recording condition.
  • the processor 801 before the processor 801 obtains the function information of the target application, the processor 801 is further configured to:
  • the processor 801 determines whether the current time reaches a preset time point
  • the processor 801 detects whether the CPU usage of the target application is greater than or equal to the preset threshold.
  • the function information corresponding to the target application is obtained, and the target is obtained from the function information. Applying the name of the running function, and determining whether the function name satisfies the preset function name recording condition, and if yes, the function The number is recorded.
  • the related function running information can be obtained by recording the name of the function running by the target application, so that the developer can optimize the application of the test according to the related information.
  • the storage medium may be a magnetic disk, an optical disk, a ROM, a RAM, or the like.
  • the units in the detecting device occupied by the CPU in the embodiment of the present invention may be combined, divided, and deleted according to actual needs.

Landscapes

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

Abstract

Disclosed are a method, device and apparatus for detecting CPU occupation. The method comprises: when it is detected that a CPU occupancy rate corresponding to a target application is greater than or equal to a pre-set threshold value, acquiring function information about the operation of the target application (S101); acquiring a function name in the function information about the operation of the target application (S102); determining whether the function name satisfies a pre-set function name record condition (S103); and if so, recording the function name (S104). Relevant information when CPU occupation is abnormal can be acquired, thereby facilitating a developer to optimize a test application according to the relevant information.

Description

一种CPU占用的检测方法、装置及设备Method, device and device for detecting CPU occupation
相关申请的交叉引用Cross-reference to related applications
本申请要求于北京金山安全软件有限公司2016年06月01日提交中国专利局、申请号为201610384122.4、发明名称为“一种CPU占用的检测方法、装置及设备”的中国专利申请的优先权。This application claims the priority of the Chinese patent application filed by the Chinese Patent Office, the application number is 201610384122.4, and the invention is entitled "a method, device and device for CPU usage".
技术领域Technical field
本发明涉及电子技术领域,具体涉及一种CPU占用的检测方法、装置及设备。The present invention relates to the field of electronic technologies, and in particular, to a method, device and device for detecting CPU usage.
背景技术Background technique
随着智能终端,如智能手机和平板电脑的普及和功能的增强,用户对于智能手机中安装的应用的性能要求越来越高。一个应用在发布之前,测试人员需要对这个应用的CPU占用值进行测试,测试是否出现CPU占用值异常突高的情况,只有测试出CPU占用值低于设定的阈值时,才能将该应用发布出去。但是在现有技术中,当监测到应用CPU占用值有异常突高的情况时,测试人员往往无法获知出现异常的原因,导致开发者没有可以参考的信息来对测试的应用进行优化。With the popularity and enhanced functionality of smart terminals, such as smartphones and tablets, users are increasingly demanding performance for applications installed in smartphones. Before an application is released, the tester needs to test the CPU usage of the application to test whether the CPU usage value is abnormally high. Only when the CPU usage value is lower than the set threshold, the application can be released. Go out. However, in the prior art, when it is detected that the application CPU usage value is abnormally high, the tester often cannot know the cause of the abnormality, and the developer has no information to refer to to optimize the application of the test.
发明内容Summary of the invention
本发明实施例提供了一种CPU占用的检测方法、装置及设备,可以获取CPU占用发生异常情况时的相关信息,便于开发者根据相关信息来对测试的应用进行优化。The embodiment of the invention provides a method, a device and a device for detecting CPU usage, which can obtain related information when an abnormality occurs in the CPU, so that the developer can optimize the application of the test according to the related information.
本发明实施例第一方面提供了一种CPU占用的检测方法,包括:A first aspect of the embodiments of the present invention provides a method for detecting CPU usage, including:
当检测到目标应用对应的CPU占用率大于或等于预设阈值时,获取所述目标应用运行的函数信息;Obtaining function information of the target application running when detecting that the CPU usage of the target application is greater than or equal to a preset threshold;
获取所述目标应用运行的函数信息中的函数名称;Obtaining a function name in function information of the target application running;
判断所述函数名称是否满足预设的函数名称记录条件;Determining whether the function name satisfies a preset function name recording condition;
若所述函数名称满足所述预设的函数名称记录条件,则对所述函数名称进行记录。If the function name satisfies the preset function name recording condition, the function name is recorded.
结合本发明实施例的第一方面的实施方式,在第一方面的第一种可能的实施方式中,所述对所述函数名称进行记录之前,还包括:In conjunction with the implementation of the first aspect of the embodiments of the present invention, in the first possible implementation manner of the first aspect, before the recording the function name, the method further includes:
获取所述函数名称对应的类名;Obtaining a class name corresponding to the function name;
所述对所述函数名称进行记录,包括: The recording the function name includes:
对所述函数名称以及所述函数名称对应的类名进行记录。The function name and the class name corresponding to the function name are recorded.
结合本发明实施例的第一方面的实施方式,在第一方面的第二种可能的实施方式中,所述获取所述目标应用运行的函数信息,包括:With reference to the implementation manner of the first aspect of the embodiment of the present invention, in the second possible implementation manner of the first aspect, the acquiring the function information of the target application running includes:
获取所述目标应用对应的跟踪信息日志文件,从所述跟踪信息日志文件中获取所述目标应用运行的函数信息。Obtaining a tracking information log file corresponding to the target application, and acquiring function information of the target application running from the tracking information log file.
结合本发明实施例的第一方面的第二种可能的实施方式,在第一方面的第三种可能的实施方式中,所述获取所述目标应用对应的跟踪信息日志文件,从所述跟踪信息日志文件中获取所述目标应用运行的函数信息,包括:With reference to the second possible implementation manner of the first aspect of the embodiments of the present disclosure, in a third possible implementation manner of the first aspect, the acquiring a tracking information log file corresponding to the target application, from the tracking Obtaining function information of the target application running in the information log file, including:
获取所述目标应用对应的跟踪信息日志文件,将所述跟踪信息日志文件转换为超文本标记语言(英文:Hyper Text Markup Language,HTML)文件;Obtaining a tracking information log file corresponding to the target application, and converting the tracking information log file into a Hyper Text Markup Language (HTML) file;
从所述HTML文件中获取所述目标应用运行的函数信息。Obtaining function information of the target application running from the HTML file.
结合本发明实施例的第一方面的实施方式,或第一方面的第一种可能的实施方式,或第一方面的第二种可能的实施方式,或第一方面的第三种可能的实施方式,在第一方面的第四种可能的实施方式中,所述判断所述函数名称是否满足预设的函数名称记录条件,包括:Embodiments in conjunction with the first aspect of the embodiments of the present invention, or the first possible implementation of the first aspect, or the second possible implementation of the first aspect, or the third possible implementation of the first aspect In a fourth possible implementation manner of the first aspect, the determining whether the function name meets a preset function name recording condition includes:
判断所述函数名称处于所述目标应用对应的预设白名单还是所述目标应用对应的预设黑名单中;Determining whether the function name is in a preset white list corresponding to the target application or in a preset blacklist corresponding to the target application;
若所述函数名称处于所述目标应用对应的预设黑名单中,则所述函数名称满足所述预设的函数名称记录条件。If the function name is in the preset blacklist corresponding to the target application, the function name satisfies the preset function name recording condition.
结合本发明实施例的第一方面的实施方式,或第一方面的第一种可能的实施方式,或第一方面的第二种可能的实施方式,或第一方面的第三种可能的实施方式,在第一方面的第五种可能的实施方式中,所述获取所述目标应用运行的函数信息之前,还包括:Embodiments in conjunction with the first aspect of the embodiments of the present invention, or the first possible implementation of the first aspect, or the second possible implementation of the first aspect, or the third possible implementation of the first aspect In a fifth possible implementation manner of the first aspect, before the acquiring the function information of the target application, the method further includes:
判断当前时刻是否到达预设时间点;Determining whether the current time has reached a preset time point;
若当前时刻到达所述预设时间点,检测所述目标应用对应的CPU占用率是否大于或等于所述预设阈值。If the current time reaches the preset time point, it is detected whether the CPU usage corresponding to the target application is greater than or equal to the preset threshold.
第二方面,本发明实施例提供了一种CPU占用的检测装置,包括:In a second aspect, an embodiment of the present invention provides a device for detecting CPU usage, including:
第一获取单元,用于当检测到目标应用对应的CPU占用率大于或等于预设阈值时,获取所述目标应用运行的函数信息;a first acquiring unit, configured to acquire function information of the target application running when detecting that a CPU usage corresponding to the target application is greater than or equal to a preset threshold;
第二获取单元,用于获取所述目标应用运行的函数信息中的函数名称;a second acquiring unit, configured to acquire a function name in function information of the target application running;
第一判断单元,用于判断所述函数名称是否满足预设的函数名称记录条件;a first determining unit, configured to determine whether the function name satisfies a preset function name recording condition;
记录单元,用于若所述第一判断单元判断出所述函数名称满足所述预设的函数名称记录条件,则对所述函数名称进行记录。a recording unit, configured to record the function name if the first determining unit determines that the function name satisfies the preset function name recording condition.
结合本发明实施例的第二方面的实施方式,在第二方面的第一种可能的实施方式中,还 包括:In conjunction with the embodiment of the second aspect of the embodiments of the present invention, in the first possible implementation of the second aspect, include:
第三获取单元,用于在所述记录单元对所述函数名称进行记录之前,获取所述函数名称对应的类名;a third obtaining unit, configured to acquire a class name corresponding to the function name before the recording unit records the function name;
所述记录单元具体用于:The recording unit is specifically configured to:
若所述第一判断单元判断出所述函数名称满足所述预设的函数名称记录条件,则对所述函数名称以及所述函数名称对应的类名进行记录。If the first determining unit determines that the function name satisfies the preset function name recording condition, records the function name and the class name corresponding to the function name.
结合本发明实施例的第二方面的实施方式,在第二方面的第二种可能的实施方式中,所述第一获取单元具体用于:With reference to the implementation of the second aspect of the embodiment of the present invention, in the second possible implementation manner of the second aspect, the first acquiring unit is specifically configured to:
获取所述目标应用对应的跟踪信息日志文件,从所述跟踪信息日志文件中获取所述目标应用运行的函数信息。Obtaining a tracking information log file corresponding to the target application, and acquiring function information of the target application running from the tracking information log file.
结合本发明实施例的第二方面的第二种可能的实施方式,在第二方面的第三种可能的实施方式中,所述第一获取单元具体用于:With reference to the second possible implementation manner of the second aspect of the embodiment of the present invention, in a third possible implementation manner of the second aspect, the first acquiring unit is specifically configured to:
获取所述目标应用对应的跟踪信息日志文件,将所述跟踪信息日志文件转换为HTML文件,并从所述HTML文件中获取所述目标应用运行的函数信息。Obtaining a tracking information log file corresponding to the target application, converting the tracking information log file into an HTML file, and acquiring function information of the target application running from the HTML file.
结合本发明实施例的第二方面,或第二方面的第一种可能的实施方式,或第二方面的第二种可能的实施方式,或第二方面的第三种可能的实施方式,在第二方面的第四种可能的实施方式中,所述第一判断单元具体用于:In conjunction with the second aspect of the embodiments of the present invention, or the first possible implementation of the second aspect, or the second possible implementation of the second aspect, or the third possible implementation of the second aspect, In a fourth possible implementation manner of the second aspect, the first determining unit is specifically configured to:
判断所述函数名称处于所述目标应用对应的预设白名单还是所述目标应用对应的预设黑名单中;Determining whether the function name is in a preset white list corresponding to the target application or in a preset blacklist corresponding to the target application;
若所述函数名称处于所述目标应用对应的预设黑名单中,则所述函数名称满足所述预设的函数名称记录条件。If the function name is in the preset blacklist corresponding to the target application, the function name satisfies the preset function name recording condition.
结合本发明实施例的第二方面,或第二方面的第一种可能的实施方式,或第二方面的第二种可能的实施方式,或第二方面的第三种可能的实施方式,在第二方面的第五种可能的实施方式中,还包括:In conjunction with the second aspect of the embodiments of the present invention, or the first possible implementation of the second aspect, or the second possible implementation of the second aspect, or the third possible implementation of the second aspect, In a fifth possible implementation manner of the second aspect, the method further includes:
第二判断单元,用于判断当前时刻是否到达预设时间点;a second determining unit, configured to determine whether the current time reaches a preset time point;
检测单元,用于若所述第二判断单元判断出当前时刻到达所述预设时间点,检测所述目标应用对应的CPU占用率是否大于或等于所述预设阈值。The detecting unit is configured to: if the second determining unit determines that the current time reaches the preset time point, and detects whether the CPU usage corresponding to the target application is greater than or equal to the preset threshold.
本发明实施例第三面提供了一种CPU占用的检测设备,包括:处理器、存储器、通信接口和总线;The third aspect of the embodiment of the present invention provides a detection device occupied by a CPU, including: a processor, a memory, a communication interface, and a bus;
所述处理器、所述存储器和所述通信接口通过所述总线连接并完成相互间的通信;所述存储器存储可执行程序代码;所述处理器通过读取所述存储器中存储的可执行程序代码来运行与所述可执行程序代码对应的程序,以用于执行一种CPU占用的检测方法;其中,所述 方法包括:The processor, the memory, and the communication interface are connected by the bus and complete communication with each other; the memory stores executable program code; the processor reads an executable program stored in the memory by reading Code for running a program corresponding to the executable program code for performing a CPU occupancy detection method; wherein Methods include:
当检测到目标应用对应的CPU占用率大于或等于预设阈值时,获取所述目标应用运行的函数信息;Obtaining function information of the target application running when detecting that the CPU usage of the target application is greater than or equal to a preset threshold;
获取所述目标应用运行的函数信息中的函数名称;Obtaining a function name in function information of the target application running;
判断所述函数名称是否满足预设的函数名称记录条件;Determining whether the function name satisfies a preset function name recording condition;
若所述函数名称满足所述预设的函数名称记录条件,则对所述函数名称进行记录。If the function name satisfies the preset function name recording condition, the function name is recorded.
本发明实施例第四方面提供一种存储介质,其中,该存储介质用于存储应用程序,所述应用程序用于在运行时执行本发明实施例的所述的一种CPU占用的检测方法。A fourth aspect of the embodiments of the present invention provides a storage medium, where the storage medium is used to store an application, and the application is configured to perform a CPU occupancy detection method according to an embodiment of the present invention at runtime.
本发明实施例第五方面提供一种应用程序,其中,该应用程序用于在运行时执行本发明实施例所述的一种CPU占用的检测方法。A fifth aspect of the embodiments of the present invention provides an application program, where the application is configured to perform a CPU occupancy detection method according to an embodiment of the present invention at runtime.
实施本发明实施例,具有如下有益效果:Embodiments of the present invention have the following beneficial effects:
当检测到目标应用对应的CPU占用率大于或等于预设阈值时,获取所述目标应用对应的函数信息,从所述函数信息中获取所述目标应用运行的的函数名称,并判断所述函数名称是否满足预设的函数名称记录条件,若满足,则对所述函数名称进行记录。在CPU占用发生异常时通过记录目标应用运行的函数的名称可以获取到相关的函数运行信息,便于开发者根据该相关信息来对测试的应用进行优化。When the CPU usage of the target application is greater than or equal to the preset threshold, the function information corresponding to the target application is obtained, the function name of the target application is obtained from the function information, and the function is determined. Whether the name satisfies the preset function name recording condition, and if so, records the function name. When the CPU usage is abnormal, the related function running information can be obtained by recording the name of the function running by the target application, so that the developer can optimize the application of the test according to the related information.
附图说明DRAWINGS
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are some embodiments of the present invention, Those skilled in the art can also obtain other drawings based on these drawings without paying any creative work.
图1是本发明实施例提供的一种CPU占用的检测方法的流程示意图;1 is a schematic flowchart of a method for detecting CPU usage according to an embodiment of the present invention;
图2是本发明实施例提供的一种TraceView文件的示意图;2 is a schematic diagram of a TraceView file according to an embodiment of the present invention;
图3是本发明实施例提供的HTML文件的示意图;3 is a schematic diagram of an HTML file provided by an embodiment of the present invention;
图4是本发明实施例提供的黑名单的示意图;4 is a schematic diagram of a blacklist provided by an embodiment of the present invention;
图5是本发明实施例提供的白名单的示意图;FIG. 5 is a schematic diagram of a white list provided by an embodiment of the present invention; FIG.
图6是本发明实施例提供的最终记录的结果的示意图;6 is a schematic diagram of results of final recording provided by an embodiment of the present invention;
图7是本发明实施例提供的一种CPU占用的检测装置的结构示意图;FIG. 7 is a schematic structural diagram of a device for detecting CPU usage according to an embodiment of the present invention;
图8是本发明实施例提供的一种CPU占用的检测设备的结构示意图。FIG. 8 is a schematic structural diagram of a detection device occupied by a CPU according to an embodiment of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描 述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. It is apparent that the described embodiments are a part of the embodiments of the invention, and not all of the 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.
本发明的说明书和权利要求书及所述附图中的术语“第一”、“第二”、“第三”和“第四”等是用于区别不同对象,而不是用于描述特定顺序。此外,术语“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second", "third", and "fourth" and the like in the specification and claims of the present invention are used to distinguish different objects, and are not intended to describe a specific order. . Furthermore, the terms "comprises" and "comprising" and "comprising" are intended to cover a non-exclusive inclusion. For example, a process, method, system, product, or device that comprises a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units not listed, or alternatively Other steps or units inherent to these processes, methods, products or equipment.
以下各发明实施例所描述的设备包括智能手机(如Android手机、iOS手机、Windows Phone手机等)、平板电脑、模拟器等。The devices described in the following embodiments of the invention include smart phones (such as Android phones, iOS phones, Windows Phone phones, etc.), tablets, emulators, and the like.
请参见图1,图1是本发明实施例提供的一种CPU占用的检测方法的流程示意图。如图1所示,该CPU占用的检测方法可以包括但不限于以下步骤。Referring to FIG. 1, FIG. 1 is a schematic flowchart of a method for detecting CPU usage according to an embodiment of the present invention. As shown in FIG. 1, the detection method occupied by the CPU may include, but is not limited to, the following steps.
S101、当检测到目标应用对应的CPU占用率大于或等于预设阈值时,获取所述目标应用运行的函数信息。S101. Acquire function information of the target application running when it is detected that the CPU usage of the target application is greater than or equal to a preset threshold.
作为一种可选的实施方式,所述获取所述目标应用运行的函数信息,包括:As an optional implementation manner, the acquiring function information of the target application running includes:
获取所述目标应用对应的跟踪信息日志文件,从所述跟踪信息日志文件中获取所述目标应用运行的函数信息。Obtaining a tracking information log file corresponding to the target application, and acquiring function information of the target application running from the tracking information log file.
本发明实施例中,所述跟踪信息日志文件具体为TraceView文件,所述跟踪信息日志文件包括所述目标应用运行的函数信息。系统运行某个应用程序(英文:Application,App)一段时间后,会在系统的存储空间,例如安全数码(英文:Secure Digital,SD)卡的根目录生成.trace这个跟踪信息日志(英文:log)文件,记录这段时间内该App的运行的函数信息。当检测到目标应用对应的CPU占用率大于或等于预设阈值时,从SD的目录中获取所述目标应用对应的TraceView文件,因此无论手机还是模拟器,都要有SD卡的支持,因为TraceView文件会存到SD卡上。对于手机需要插入SD卡,对于模拟器要在建立/启动模拟器的时候加入SD卡的支持就可以了。其中,系统在存储TraceView文件时,是针对每个应用进行单独存储TraceView文件的,根据目标应用的标识可以找到与其对应的TraceView文件。本发明实施例中,所述预设阈值可以由系统默认设定,也可以由用户手动设置,本发明实施例不作具体限定,例如,预设阈值为50%。In the embodiment of the present invention, the tracking information log file is specifically a TraceView file, and the tracking information log file includes function information of the target application running. After the system runs an application (English: Application, App) for a period of time, the trace information log of the .trace is generated in the system's storage space, such as the root directory of the Secure Digital (SD) card (English: log ) file, record the function information of the running of the app during this time. When it is detected that the CPU usage of the target application is greater than or equal to the preset threshold, the TraceView file corresponding to the target application is obtained from the directory of the SD, so whether the mobile phone or the simulator needs to support the SD card, because TraceView The file will be saved to the SD card. For the mobile phone, you need to insert the SD card. For the emulator, you need to add SD card support when setting up/starting the emulator. The system stores the TraceView file separately for each application when storing the TraceView file, and the corresponding TraceView file can be found according to the identifier of the target application. In the embodiment of the present invention, the preset threshold may be set by default by the system, or may be manually set by the user, which is not specifically limited in the embodiment of the present invention. For example, the preset threshold is 50%.
具体的,请参见图2,是通过TraceView性能分析工具中Profile面板中展示的TraceView文件的格式示意图,其中,列1对应的Name表示函数信息,从Name中可以提取出类名以及函数名,Name列出的是所有的调用项,前面的数字是编号,双击函数名左边的“+”展开后可以看到有Parent和Children子项,就是指被调用和调用。例如如果函数A调用函数 B,那么函数A称为函数B的“parents”,函数B称为函数A的“children”。列2对应的“Incl Cpu Time%”表示函数的Inclusive Cpu Time占总时间的百分比。列3对应的“Inclusive Cpu Time”是指除统计函数本身运行的时间外再加上调用子函数所运行的时间。列4对应的“Excl Cpu Time%”指的是Exclusive Cpu Time占总时间的白分比。列5对应的“Exclusive Cpu Time”指统计函数本身运行的时间。以图2中Name为android.view.animation.Animation.getTransformation(JLandroid/view/animation/Transformation;)Z为例进行说明,其中的()之前的最近一个.之后的字段为函数名,即getTransformation为函数名称,在函数名称之前的一个.之后的字段为类名,即Animation为类名,或者,还可以提取出()之前的整个字段作为函数名,即android.view.animation.AnimationSet.getTransformation为函数名。Specifically, please refer to FIG. 2, which is a schematic diagram of the format of the TraceView file displayed in the Profile panel in the TraceView performance analysis tool. The Name corresponding to the column 1 represents the function information, and the class name and the function name can be extracted from the Name. Listed are all the call items, the previous number is the number, double-click the "+" to the left of the function name to see that there are Parent and Children sub-items, which means that they are called and called. For example, if function A calls a function B, then function A is called "parents" of function B, and function B is called "children" of function A. The "Incl Cpu Time%" corresponding to column 2 represents the percentage of the function's Inclusive Cpu Time as a percentage of the total time. The "Inclusive Cpu Time" corresponding to column 3 refers to the time that the calling subfunction runs in addition to the time the statistical function itself runs. The "Excl Cpu Time%" corresponding to column 4 refers to the white ratio of Exclusive Cpu Time to the total time. The "Exclusive Cpu Time" corresponding to column 5 refers to the time when the statistical function itself runs. Take the name in Figure 2 as android.view.animation.Animation.getTransformation(JLandroid/view/animation/Transformation;)Z as an example. The most recent field after () is the function name, ie getTransformation is The function name, a field before the function name, is the class name, that is, the Animation is the class name, or you can extract the entire field before () as the function name, ie android.view.animation.AnimationSet.getTransformation Function name.
android.view.animation.Animation.getTransformation函数的调用时间为326.998ms,若该调用时间相对较久,再看它调用的子函数。其中,子函数android.view.animation.AnimationSet.getTransformation的调用时间为321.996ms,相对时间较长,若需要优化该应用的性能,则需要对函数android.view.animation.AnimationSet.getTransformation的执行时间进行优化。The call time of the android.view.animation.Animation.getTransformation function is 326.998ms. If the call time is relatively long, look at the subfunction it calls. Among them, the call time of the sub-function android.view.animation.AnimationSet.getTransformation is 321.996ms, the relative time is longer. If you need to optimize the performance of the application, you need to execute the execution time of the function android.view.animation.AnimationSet.getTransformation. optimization.
S102、获取所述目标应用运行的函数信息中的函数名称。S102. Acquire a function name in function information of the target application running.
作为一种可选的实施方式,所述获取所述目标应用运行的函数信息中的函数名称,包括:通过所述目标应用对应的跟踪信息日志文件获取所述目标应用运行的函数信息中的函数名称。As an optional implementation manner, the acquiring the function name in the function information of the target application operation includes: acquiring, by using the tracking information log file corresponding to the target application, a function in function information of the target application running name.
其中,所述目标应用对应的跟踪信息日志文件中包括所述目标应用运行的函数信息,所述函数信息中包括所述目标应用运行的函数的名称,所述函数信息中还可以包括所述目标应用运行的函数的名称所对应的类名称。其中,函数名称可以包括但不限于:动画函数的名称、界面更新函数的名称、更新时间信息的函数的名称等。一个类可以包括多个函数,多个类可以包括同一个函数。The function information corresponding to the target application is included in the tracking information log file corresponding to the target application, where the function information includes a name of a function that is run by the target application, and the function information may further include the target. The name of the class corresponding to the name of the function that the application is running. The function name may include, but is not limited to, the name of the animation function, the name of the interface update function, the name of the function that updates the time information, and the like. A class can include multiple functions, and multiple classes can include the same function.
作为一种可选的实施方式,可以只获取所述目标应用运行的函数对应的函数名称,便于针对函数名称进行分析,以及后续进行记录。As an optional implementation manner, only the function name corresponding to the function run by the target application may be obtained, so that the function name is analyzed and the subsequent recording is performed.
作为一种可选的实施方式,还可以获取所述目标应用运行的函数的名称以及函数的名称所对应的类名,便于针对函数名称进行分析,以及后续进行记录。As an optional implementation manner, the name of the function run by the target application and the class name corresponding to the name of the function may also be obtained, so as to facilitate analysis for the function name and subsequent recording.
作为一种可选的实施方式,可以通过TraceView性能分析工具将TraceView文件生成如图2所示的表,再从生成的表中提取出函数名称以及函数名称所对应的类名。As an optional implementation, the TraceView file can be used to generate a table of the TraceView file as shown in FIG. 2, and the function name and the class name corresponding to the function name are extracted from the generated table.
作为一种可选的实施方式,所述获取所述目标应用对应的跟踪信息日志文件,从所述跟踪信息日志文件中获取所述目标应用运行的函数信息,包括: As an optional implementation manner, the acquiring the tracking information log file corresponding to the target application, and acquiring the function information of the target application running from the tracking information log file, includes:
获取所述目标应用对应的跟踪信息日志文件,将所述跟踪信息日志文件转换为HTML文件;Obtaining a tracking information log file corresponding to the target application, and converting the tracking information log file into an HTML file;
从所述HTML文件中获取所述目标应用运行的函数信息。Obtaining function information of the target application running from the HTML file.
其中,HTML文件为可解析的文本文件,将TraceView文件转换为可解析的HTML文件便于对所述目标应用的运行的函数信息进行解析,HTML文件中包括所述目标应用运行的函数信息,所述函数信息包括所述目标应用运行的函数名称,进一步的,所述函数信息中还包括所述函数名称对应的类名。HTML文件的文件格式可参见图3所示。The HTML file is a parsable text file, and converting the TraceView file into a parsable HTML file is convenient for parsing the running function information of the target application, where the HTML file includes function information of the target application running, The function information includes a function name of the target application, and further, the function information further includes a class name corresponding to the function name. The file format of the HTML file can be seen in Figure 3.
具体的,可参见图3,是本发明实施例提供的一种HTML文件的格式示意图。在图3中,Method项对应的字段即为本发明实施例所描述的函数信息,Method项中包含函数名称以及所述函数名称所对应的类名,以Method项为android.view.animation.AnimationSet.getTransformation(JLandroid/view/animation/Transformati on;)Z为例进行说明,其中()之前的最近一个.之后的字段为函数名,即getTransformation为函数名称,在函数名称之前的一个.之后的字段为类名,即AnimationSet为类名,或者,还可以提取出()之前的整个字段作为函数名,即android.view.animation.AnimationSet.getTransformation为函数名,提取出函数名之后的AnimationSet.java作为类名。Specifically, FIG. 3 is a schematic diagram of a format of an HTML file according to an embodiment of the present invention. In FIG. 3, the field corresponding to the Method item is the function information described in the embodiment of the present invention, and the Method item includes the function name and the class name corresponding to the function name, and the Method item is android.view.animation.AnimationSet .getTransformation(JLandroid/view/animation/Transformati on;)Z is an example. The last field after () is the function name, that is, getTransformation is the function name, and the field after the function name. For the class name, that is, the AnimationSet is the class name, or you can extract the entire field before () as the function name, that is, android.view.animation.AnimationSet.getTransformation is the function name, and the AnimationSet.java after the function name is extracted as Class name.
S103、判断所述函数名称是否满足预设的函数名称记录条件,若满足,执行步骤S104。S103. Determine whether the function name satisfies a preset function name recording condition. If yes, execute step S104.
本发明实施例中,获取到所述目标应用运行的函数对应的函数名称之后,根据函数名称来分析目标应用的运行情况,进而获取到与CPU占用发生异常相关的信息。In the embodiment of the present invention, after the function name corresponding to the function run by the target application is obtained, the running state of the target application is analyzed according to the function name, and then information related to the abnormality of the CPU occupation is obtained.
作为一种可选的实施方式,所述判断所述函数名称是否满足预设的函数名称记录条件,包括:As an optional implementation manner, the determining whether the function name meets a preset function name recording condition includes:
判断所述函数名称处于所述目标应用对应的预设白名单还是所述目标应用对应的预设黑名单中;若所述函数名称处于所述目标应用对应的预设白名单中,则所述函数名称不满足预设的函数名称记录条件;若所述函数名称处于所述目标应用对应的预设黑名单中,则所述函数名称满足所述预设的函数名称记录条件。Determining whether the function name is in a preset whitelist corresponding to the target application or a preset blacklist corresponding to the target application; if the function name is in a preset whitelist corresponding to the target application, The function name does not satisfy the preset function name recording condition; if the function name is in the preset blacklist corresponding to the target application, the function name satisfies the preset function name recording condition.
其中,系统预先建立黑名单和白名单,黑名单中存放需要关注的信息,比如动画函数名称,界面更新函数名称。白名单中存放可以忽略的信息,即认为正常的函数的信息。对获取的函数名称进行分析,如果函数名称是属于白名单的信息,则不对该函数名称进行记录;如果函数名称是属于黑名单的信息,则记录为必须重视的结果,对该函数名称以及该函数名称对应的类名进行记录。可选的,如果函数名称既不属于白名单也不属于黑名单,则可以记录为参考结果,也可以不进行记录,本发明实施例不作具体限定。The system pre-establishes a blacklist and a whitelist, and the blacklist stores information that needs attention, such as an animation function name and an interface update function name. The whitelist stores information that can be ignored, that is, information that is considered normal. The obtained function name is analyzed. If the function name is information that belongs to the whitelist, the function name is not recorded; if the function name is blacklisted information, the record is a result that must be emphasized, the function name and the The class name corresponding to the function name is recorded. Optionally, if the function name is neither a whitelist nor a blacklist, it may be recorded as a reference result or may not be recorded, which is not specifically limited in the embodiment of the present invention.
具体的,在将函数名称与黑名单或白名单中记录的函数名称进行比对时,若待判断的函 数名称中的字段包括黑名单中的内容,则确定待判断的函数名称处于所述黑名单,若待判断的函数名称中的字段包括白名单中的内容,则确定待判断的函数名称处于所述白名单。Specifically, when the function name is compared with the function name recorded in the blacklist or whitelist, if the function to be judged is If the field in the name includes the content in the blacklist, it is determined that the function name to be determined is in the blacklist. If the field in the function name to be determined includes the content in the whitelist, it is determined that the function name to be determined is in the Describe the white list.
具体的,黑名单的示意图可参见图4,白名单的示意图可参见图5。其中,黑名单中记录的函数名称有:Animation、Animator、MainLayout、weather toolbox和deskbox。白名单中记录的函数名称有:Log和KLogBuffer。由图3可知,函数名称android.view.animation.AnimationSet.getTransformation中包含黑名单中Animation,因此,确定出android.view.animation.AnimationSet.getTransformation处于所述目标应用对应的预设黑名单中,则所述函数名称满足所述预设的函数名称记录条件。Specifically, the schematic diagram of the blacklist can be seen in FIG. 4, and the schematic diagram of the whitelist can be seen in FIG. 5. Among them, the function names recorded in the blacklist are: Animation, Animator, MainLayout, weather toolbox, and deskbox. The function names recorded in the whitelist are: Log and KLogBuffer. As can be seen from Figure 3, the function name android.view.animation.AnimationSet.getTransformation contains the animation in the blacklist, therefore, it is determined that android.view.animation.AnimationSet.getTransformation is in the preset blacklist corresponding to the target application, then The function name satisfies the preset function name recording condition.
S104、对所述函数名称进行记录。S104. Record the function name.
若判断出函数名称满足所述预设的函数名称记录条件,则对所述函数名称进行记录,在对所述目标应用运行的所有函数进行完判断后,可以生成最终的检测结果,该检测结果可以以一列表的形式进行存储,开发人员根据列表来分析所述目标应用运行哪些函数时发生了CPU占用异常。If it is determined that the function name satisfies the preset function name recording condition, the function name is recorded, and after all the functions running by the target application are judged, the final detection result may be generated, and the detection result is generated. It can be stored in the form of a list, and the developer analyzes which functions of the target application are running according to the list, and a CPU occupation exception occurs.
作为一种可选的实施方式,若判断出函数名称满足所述预设的函数名称记录条件,则对所述函数名称以及该函数名称对应的类名进行记录,从而为开发人员提供更多可参考的信息,在对所述目标应用运行的所有函数进行完判断后,可以生成最终的检测结果,该检测结果可以以一列表的形式进行存储,从而协助开发人员通过记录的函数名称以及类名来分析所述目标应用运行哪些类的哪些函数时发生了CPU占用异常。As an optional implementation manner, if it is determined that the function name satisfies the preset function name recording condition, the function name and the class name corresponding to the function name are recorded, thereby providing more developers with The reference information can be used to generate a final detection result after all the functions running by the target application are judged, and the detection result can be stored in a list, thereby assisting the developer to record the function name and the class name. A CPU usage exception occurs when analyzing which functions of which classes the target application is running.
具体的,记录的最终结果可参见图6。其中,生成的最终结果会记录需要关注的函数名称以及函数名称对应的类名。以第三行为例,记录的android.view.animation.AnimationSet.getTransformation为函数名称,记录的AnimationSet.java为类名。Specifically, the final result of the recording can be seen in FIG. 6. Among them, the final result generated will record the name of the function to be concerned and the class name corresponding to the function name. In the third behavior example, the recorded android.view.animation.AnimationSet.getTransformation is the function name, and the recorded AnimationSet.java is the class name.
可选的,若判断出函数名称不满足所述预设的函数名称记录条件,则不对该函数名称进行记录。Optionally, if it is determined that the function name does not satisfy the preset function name recording condition, the function name is not recorded.
系统在判断完之后,只将需要关注的函数名称进行记录,针对可以忽略的函数不进行记录,从而可以生成初步分析结果,协助开发人员更快更加准确的确定出所述目标应用在运行哪些函数时发生了CPU占用异常。After the system finishes judging, only the function name that needs attention is recorded, and the function that can be ignored is not recorded, so that preliminary analysis results can be generated, which helps the developer to determine more quickly and more accurately which functions the target application is running. A CPU usage exception occurred.
例如,监测一款锁屏应用的CPU占用值。定时监控锁屏应用在灭屏时的CPU占用值,如果超过阈值,则抓取TraceView文件。将TraceView文件转化成HTML文件。自动化提取出HTML文件的函数名称以及对应的类名,根据函数名称匹配黑名单和白名单,其中黑名单和白名单是预先建立的,黑名单中记录有需要关注的函数名称,如动画函数名称(在灭屏时执行动画函数名称被认定为是异常调用,需要进行记录),白名单中记录有可以忽略的 函数名称,如更新时间信息的函数名称(在灭屏时执行系统时间信息的自动更新被认定为是合理的调用,无需进行记录)。若待判断的函数名称属于黑名单中的函数名称,则需要将待判断的函数名称进行记录;若待判断的函数名称属于白名单中的函数名称,则不需要将该待判断的函数名称进行记录。将最终生成的记录提供给开发者,协助开发者对锁屏应用进行优化。For example, monitor the CPU usage of a lock screen application. The CPU monitors the value of the CPU when the lock screen application is off. If the threshold value is exceeded, the TraceView file is captured. Convert the TraceView file to an HTML file. Automatically extract the function name of the HTML file and the corresponding class name, and match the blacklist and the whitelist according to the function name. The blacklist and the whitelist are pre-established, and the name of the function that needs attention is recorded in the blacklist, such as the name of the animation function. (When the screen is off, the name of the animation function is recognized as an exception call, which needs to be recorded.) The record in the whitelist is negligible. The function name, such as the function name of the update time information (automatic update of the execution system time information when the screen is off is recognized as a reasonable call, no need to record). If the function name to be judged belongs to the function name in the blacklist, the function name to be determined needs to be recorded; if the function name to be determined belongs to the function name in the white list, the function name to be determined need not be performed. recording. Provide the final generated records to the developer to assist developers in optimizing the lock screen application.
可见,在图1所描述的方法中,当检测到目标应用对应的CPU占用率大于或等于预设阈值时,获取所述目标应用对应的跟踪信息日志文件,通过该跟踪信息日志文件获取所述目标应用运行的函数信息中的函数名称,并判断所述函数名称是否满足预设的函数名称记录条件,若满足,则对所述函数名称进行记录;若不满足,则不对所述函数名称进行记录。在CPU占用发生异常时通过记录目标应用运行的函数的名称可以获取到相关的函数运行信息,便于开发者根据该相关信息来对测试的应用进行优化。It can be seen that, in the method described in FIG. 1 , when the CPU usage of the target application is greater than or equal to the preset threshold, the tracking information log file corresponding to the target application is obtained, and the tracking information log file is used to obtain the a function name in the function information of the target application running, and determining whether the function name satisfies a preset function name recording condition, and if so, recording the function name; if not, not performing the function name recording. When the CPU usage is abnormal, the related function running information can be obtained by recording the name of the function running by the target application, so that the developer can optimize the application of the test according to the related information.
上述详细阐述了本发明实施例的方法,下面为了便于更好地实施本发明实施例的上述方案,相应地,下面还提供用于配合实施上述方案的相关装置。The foregoing describes the method of the embodiment of the present invention in detail. In the following, in order to facilitate the implementation of the above solution of the embodiment of the present invention, correspondingly, the related device for implementing the above solution is provided below.
请参见图7,图7是本发明实施例提供的一种CPU占用的检测装置的结构示意图。如图7所示,该CPU占用的检测装置70包括:第一获取单元701、第二获取单元702、第一判断单元703和记录单元704,其中,Referring to FIG. 7, FIG. 7 is a schematic structural diagram of a device for detecting CPU usage according to an embodiment of the present invention. As shown in FIG. 7, the detecting device 70 occupied by the CPU includes: a first acquiring unit 701, a second obtaining unit 702, a first determining unit 703, and a recording unit 704, where
第一获取单元701,用于当检测到目标应用对应的CPU占用率大于或等于预设阈值时,获取所述目标应用运行的函数信息;The first obtaining unit 701 is configured to acquire function information of the target application running when detecting that the CPU usage corresponding to the target application is greater than or equal to a preset threshold;
第二获取单元702,用于获取所述目标应用运行的函数信息中的函数名称;a second obtaining unit 702, configured to acquire a function name in function information of the target application running;
第一判断单元703,用于判断所述函数名称是否满足预设的函数名称记录条件;The first determining unit 703 is configured to determine whether the function name satisfies a preset function name recording condition;
记录单元704,用于若所述第一判断单元703判断出所述函数名称满足所述预设的函数名称记录条件,则对所述函数名称进行记录。The recording unit 704 is configured to record the function name if the first determining unit 703 determines that the function name satisfies the preset function name recording condition.
可选的,CPU占用的检测装置70还包括:Optionally, the CPU-used detecting device 70 further includes:
第三获取单元705,用于在所述记录单元704对所述函数名称进行记录之前,获取所述函数名称对应的类名;a third obtaining unit 705, configured to acquire a class name corresponding to the function name before the recording unit 704 records the function name;
所述记录单元704具体用于:The recording unit 704 is specifically configured to:
若所述第一判断单元703判断出所述函数名称满足所述预设的函数名称记录条件,则对所述函数名称以及所述函数名称对应的类名进行记录。If the first determining unit 703 determines that the function name satisfies the preset function name recording condition, the function name and the class name corresponding to the function name are recorded.
可选的,第一获取单元701具体用于:Optionally, the first obtaining unit 701 is specifically configured to:
获取所述目标应用对应的跟踪信息日志文件,从所述跟踪信息日志文件中获取所述目标应用运行的函数信息。 Obtaining a tracking information log file corresponding to the target application, and acquiring function information of the target application running from the tracking information log file.
可选的,第一获取单元701具体用于:Optionally, the first obtaining unit 701 is specifically configured to:
获取所述目标应用对应的跟踪信息日志文件,将所述跟踪信息日志文件转换为HTML文件,并从所述HTML文件中获取所述目标应用运行的函数信息。Obtaining a tracking information log file corresponding to the target application, converting the tracking information log file into an HTML file, and acquiring function information of the target application running from the HTML file.
可选的,所述第一判断单元703具体用于:Optionally, the first determining unit 703 is specifically configured to:
判断所述函数名称处于所述目标应用对应的预设白名单还是所述目标应用对应的预设黑名单中;Determining whether the function name is in a preset white list corresponding to the target application or in a preset blacklist corresponding to the target application;
若所述函数名称处于所述目标应用对应的预设黑名单中,则所述函数名称满足所述预设的函数名称记录条件。If the function name is in the preset blacklist corresponding to the target application, the function name satisfies the preset function name recording condition.
可选的,CPU占用的检测装置70还包括:Optionally, the CPU-used detecting device 70 further includes:
第二判断单元706,用于判断当前时刻是否到达预设时间点;The second determining unit 706 is configured to determine whether the current time reaches a preset time point;
检测单元707,用于若所述第二判断单元706判断出当前时刻到达所述预设时间点,检测所述目标应用对应的CPU占用率是否大于或等于所述预设阈值。The detecting unit 707 is configured to: if the second determining unit 706 determines that the current time reaches the preset time point, and detects whether the CPU usage corresponding to the target application is greater than or equal to the preset threshold.
可理解的是,本实施例的CPU占用的检测装置70的各功能单元的功能可根据上述图1方法实施例的方法具体实现,此处不再赘述。It can be understood that the functions of the functional units of the detecting device 70 occupied by the CPU of the embodiment may be specifically implemented according to the method in the foregoing method embodiment of FIG. 1, and details are not described herein again.
请参见图8,是本发明提供的一种CPU占用的检测设备的结构示意图。本实施例中所描述的CPU占用的检测设备800包括:至少一个处理器801、通信接口802、用户接口803和存储器804,处理器801、通信接口802、用户接口803和存储器804可通过总线或者其它方式连接,本发明实施例以通过总线805连接为例。其中,FIG. 8 is a schematic structural diagram of a detection device occupied by a CPU according to the present invention. The detecting device 800 occupied by the CPU described in this embodiment includes: at least one processor 801, a communication interface 802, a user interface 803, and a memory 804, and the processor 801, the communication interface 802, the user interface 803, and the memory 804 can be connected through a bus or The other embodiments are connected, and the embodiment of the present invention is connected by a bus 805 as an example. among them,
处理器801可以是通用处理器,例如中央处理器(Central Processing Unit,CPU)。The processor 801 can be a general purpose processor, such as a Central Processing Unit (CPU).
通信接口802可以为有线接口(例如以太网接口)或无线接口(例如蜂窝网络接口或使用无线局域网接口),用于与其他设备或服务器进行通信。 Communication interface 802 can be a wired interface (e.g., an Ethernet interface) or a wireless interface (e.g., a cellular network interface or a wireless local area network interface) for communicating with other devices or servers.
用户接口803具体可为触控面板,包括触摸屏和触控屏,用于检测触控面板上的操作指令,用户接口803也可以是物理按键或者鼠标。用户接口803还可以为显示屏,用于输出、显示图像或数据。The user interface 803 may specifically be a touch panel, including a touch screen and a touch screen, for detecting an operation instruction on the touch panel, and the user interface 803 may also be a physical button or a mouse. The user interface 803 can also be a display screen for outputting, displaying images or data.
存储器804可以包括易失性存储器(英文:Volatile Memory),例如随机存取存储器(英文:Random Access Memory,RAM);存储器也可以包括非易失性存储器(英文:Non-Volatile Memory),例如只读存储器(英文:Read-Only Memory,ROM)、快闪存储器(英文:Flash Memory)、硬盘(英文:Hard Disk Drive,HDD)或固态硬盘(英文:Solid-State Drive,SSD);存储器804还可以包括上述种类的存储器的组合。存储器804用于存储上述实施例中所描述的预设阈值、预设白名单、预设黑名单和预设时间点。存储器804用于存储CPU占用的检测程序代码,处理器801用于调用存储器804中存储的程序代码,执行如下操作: The memory 804 may include a volatile memory (English: Volatile Memory), such as a random access memory (RAM); the memory may also include a non-volatile memory (English: Non-Volatile Memory), for example, only Read memory (English: Read-Only Memory, ROM), flash memory (English: Flash Memory), hard disk (English: Hard Disk Drive, HDD) or solid state drive (English: Solid-State Drive, SSD); A combination of memories of the above kind may be included. The memory 804 is configured to store the preset threshold, the preset whitelist, the preset blacklist, and the preset time point described in the foregoing embodiments. The memory 804 is configured to store the detection program code occupied by the CPU, and the processor 801 is configured to call the program code stored in the memory 804, and perform the following operations:
当检测到目标应用对应的CPU占用率大于或等于预设阈值时,处理器801获取所述目标应用运行的函数信息;When it is detected that the CPU usage of the target application is greater than or equal to a preset threshold, the processor 801 acquires function information of the target application running.
处理器801获取所述目标应用运行的函数信息中的函数名称;The processor 801 acquires a function name in the function information of the target application running;
处理器801判断所述函数名称是否满足预设的函数名称记录条件;The processor 801 determines whether the function name satisfies a preset function name recording condition;
若所述函数名称满足所述预设的函数名称记录条件,则处理器801对所述函数名称进行记录。If the function name satisfies the preset function name recording condition, the processor 801 records the function name.
可选的,处理器801对所述函数名称进行记录之前,处理器801还用于:Optionally, before the processor 801 records the function name, the processor 801 is further configured to:
获取所述函数名称对应的类名;Obtaining a class name corresponding to the function name;
处理器801对所述函数名称进行记录,包括:The processor 801 records the function name, including:
处理器801对所述函数名称以及所述函数名称对应的类名进行记录。The processor 801 records the function name and the class name corresponding to the function name.
可选的,处理器801获取所述目标应用运行的函数信息,包括:Optionally, the processor 801 obtains function information about the running of the target application, including:
处理器801获取所述目标应用对应的跟踪信息日志文件,从所述跟踪信息日志文件中获取所述目标应用运行的函数信息。The processor 801 acquires a tracking information log file corresponding to the target application, and acquires function information of the target application running from the tracking information log file.
可选的,处理器801获取所述目标应用对应的跟踪信息日志文件,从所述跟踪信息日志文件中获取所述目标应用运行的函数信息,包括:Optionally, the processor 801 obtains the tracking information log file corresponding to the target application, and obtains the function information of the target application running from the tracking information log file, including:
处理器801获取所述目标应用对应的跟踪信息日志文件,将所述跟踪信息日志文件转换为HTML文件;The processor 801 acquires a tracking information log file corresponding to the target application, and converts the tracking information log file into an HTML file.
处理器801从所述HTML文件中获取所述目标应用运行的函数信息。The processor 801 obtains function information of the target application running from the HTML file.
可选的,处理器801判断所述函数名称是否满足预设的函数名称记录条件,包括:Optionally, the processor 801 determines whether the function name meets a preset function name recording condition, including:
处理器801判断所述函数名称处于所述目标应用对应的预设白名单还是所述目标应用对应的预设黑名单中;The processor 801 determines whether the function name is in a preset white list corresponding to the target application or a preset blacklist corresponding to the target application;
若所述函数名称处于所述目标应用对应的预设黑名单中,则所述函数名称满足所述预设的函数名称记录条件。If the function name is in the preset blacklist corresponding to the target application, the function name satisfies the preset function name recording condition.
可选的,处理器801获取所述目标应用运行的函数信息之前,处理器801还用于:Optionally, before the processor 801 obtains the function information of the target application, the processor 801 is further configured to:
处理器801判断当前时刻是否到达预设时间点;The processor 801 determines whether the current time reaches a preset time point;
若当前时刻到达所述预设时间点,处理器801检测所述目标应用对应的CPU占用率是否大于或等于所述预设阈值。If the current time reaches the preset time point, the processor 801 detects whether the CPU usage of the target application is greater than or equal to the preset threshold.
可理解的是,处理器801的执行步骤具体可参见图1实施例所述的内容,此处不再赘述。It can be understood that the execution steps of the processor 801 can be specifically referred to the content described in the embodiment of FIG. 1 , and details are not described herein again.
综上所述,通过实施本发明实施例,当检测到目标应用对应的CPU占用率大于或等于预设阈值时,获取所述目标应用对应的函数信息,从所述函数信息中获取所述目标应用运行的函数名称,并判断所述函数名称是否满足预设的函数名称记录条件,若满足,则对所述函 数名称进行记录。在CPU占用发生异常时通过记录目标应用运行的函数的名称可以获取到相关的函数运行信息,便于开发者根据该相关信息来对测试的应用进行优化。In summary, when the CPU usage of the target application is greater than or equal to the preset threshold, the function information corresponding to the target application is obtained, and the target is obtained from the function information. Applying the name of the running function, and determining whether the function name satisfies the preset function name recording condition, and if yes, the function The number is recorded. When the CPU usage is abnormal, the related function running information can be obtained by recording the name of the function running by the target application, so that the developer can optimize the application of the test according to the related information.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、ROM或RAM等。One of ordinary skill in the art can understand that all or part of the process of implementing the foregoing embodiments can be completed by a computer program to instruct related hardware, and the program can be stored in a computer readable storage medium. When executed, the flow of an embodiment of the methods as described above may be included. The storage medium may be a magnetic disk, an optical disk, a ROM, a RAM, or the like.
本发明实施例方法中的步骤可以根据实际需要进行顺序调整、合并和删减。The steps in the method of the embodiment of the present invention may be sequentially adjusted, merged, and deleted according to actual needs.
本发明实施例CPU占用的检测装置中的单元可以根据实际需要进行合并、划分和删减。The units in the detecting device occupied by the CPU in the embodiment of the present invention may be combined, divided, and deleted according to actual needs.
以上所揭露的仅为本发明一种较佳实施例而已,当然不能以此来限定本发明之权利范围,本领域普通技术人员可以理解实现上述实施例的全部或部分流程,并依本发明权利要求所作的等同变化,仍属于发明所涵盖的范围。 The above disclosure is only a preferred embodiment of the present invention, and of course, the scope of the present invention is not limited thereto, and those skilled in the art can understand all or part of the process of implementing the above embodiments, and according to the present invention. The equivalent changes required are still within the scope of the invention.

Claims (10)

  1. 一种CPU占用的检测方法,其特征在于,包括:A method for detecting CPU usage, characterized in that it comprises:
    当检测到目标应用对应的CPU占用率大于或等于预设阈值时,获取所述目标应用运行的函数信息;Obtaining function information of the target application running when detecting that the CPU usage of the target application is greater than or equal to a preset threshold;
    获取所述目标应用运行的函数信息中的函数名称;Obtaining a function name in function information of the target application running;
    判断所述函数名称是否满足预设的函数名称记录条件;Determining whether the function name satisfies a preset function name recording condition;
    若所述函数名称满足所述预设的函数名称记录条件,则对所述函数名称进行记录。If the function name satisfies the preset function name recording condition, the function name is recorded.
  2. 根据权利要求1所述的方法,其特征在于,所述对所述函数名称进行记录之前,还包括:The method according to claim 1, wherein before the recording of the function name, the method further comprises:
    获取所述函数名称对应的类名;Obtaining a class name corresponding to the function name;
    所述对所述函数名称进行记录,包括:The recording the function name includes:
    对所述函数名称以及所述函数名称对应的类名进行记录。The function name and the class name corresponding to the function name are recorded.
  3. 根据权利要求1或2所述的方法,其特征在于,所述获取所述目标应用运行的函数信息,包括:The method according to claim 1 or 2, wherein the acquiring the function information of the target application operation comprises:
    获取所述目标应用对应的跟踪信息日志文件,从所述跟踪信息日志文件中获取所述目标应用运行的函数信息。Obtaining a tracking information log file corresponding to the target application, and acquiring function information of the target application running from the tracking information log file.
  4. 根据权利要求3所述的方法,其特征在于,所述获取所述目标应用对应的跟踪信息日志文件,从所述跟踪信息日志文件中获取所述目标应用运行的函数信息,包括:The method according to claim 3, wherein the acquiring the tracking information log file corresponding to the target application, and acquiring the function information of the target application running from the tracking information log file, includes:
    获取所述目标应用对应的跟踪信息日志文件,将所述跟踪信息日志文件转换为超文本标记语言HTML文件;Obtaining a tracking information log file corresponding to the target application, and converting the tracking information log file into a hypertext markup language HTML file;
    从所述HTML文件中获取所述目标应用运行的函数信息。Obtaining function information of the target application running from the HTML file.
  5. 一种CPU占用的检测装置,其特征在于,包括:A device for detecting CPU usage, comprising:
    第一获取单元,用于当检测到目标应用对应的CPU占用率大于或等于预设阈值时,获取所述目标应用运行的函数信息;a first acquiring unit, configured to acquire function information of the target application running when detecting that a CPU usage corresponding to the target application is greater than or equal to a preset threshold;
    第二获取单元,用于获取所述目标应用运行的函数信息中的函数名称;a second acquiring unit, configured to acquire a function name in function information of the target application running;
    第一判断单元,用于判断所述函数名称是否满足预设的函数名称记录条件;a first determining unit, configured to determine whether the function name satisfies a preset function name recording condition;
    记录单元,用于若所述第一判断单元判断出所述函数名称满足所述预设的函数名称 记录条件,则对所述函数名称进行记录。a recording unit, configured to: if the first determining unit determines that the function name satisfies the preset function name Record the condition and record the function name.
  6. 根据权利要求5所述的装置,其特征在于,在所述记录单元对所述函数名称进行记录之前,获取所述函数名称对应的类名;The apparatus according to claim 5, wherein before the recording unit records the function name, acquiring a class name corresponding to the function name;
    所述记录单元具体用于:The recording unit is specifically configured to:
    若所述第一判断单元判断出所述函数名称满足所述预设的函数名称记录条件,则对所述函数名称以及所述函数名称对应的类名进行记录。If the first determining unit determines that the function name satisfies the preset function name recording condition, records the function name and the class name corresponding to the function name.
  7. 根据权利要求5或6所述的装置,其特征在于,所述第一获取单元具体用于:The device according to claim 5 or 6, wherein the first obtaining unit is specifically configured to:
    获取所述目标应用对应的跟踪信息日志文件,从所述跟踪信息日志文件中获取所述目标应用运行的函数信息。Obtaining a tracking information log file corresponding to the target application, and acquiring function information of the target application running from the tracking information log file.
  8. 根据权利要求7所述的装置,其特征在于,所述第一获取单元具体用于:The device according to claim 7, wherein the first obtaining unit is specifically configured to:
    获取所述目标应用对应的跟踪信息日志文件,将所述跟踪信息日志文件转换为超文本标记语言HTML文件,并从所述HTML文件中获取所述目标应用运行的函数信息。Obtaining a tracking information log file corresponding to the target application, converting the tracking information log file into a hypertext markup language HTML file, and acquiring function information of the target application running from the HTML file.
  9. 一种CPU占用的检测设备,其特征在于,包括:处理器、存储器、通信接口和总线;A detecting device occupied by a CPU, comprising: a processor, a memory, a communication interface, and a bus;
    所述处理器、所述存储器和所述通信接口通过所述总线连接并完成相互间的通信;所述存储器存储可执行程序代码;所述处理器通过读取所述存储器中存储的可执行程序代码来运行与所述可执行程序代码对应的程序,以用于执行一种CPU占用的检测方法;其中,所述方法包括:The processor, the memory, and the communication interface are connected by the bus and complete communication with each other; the memory stores executable program code; the processor reads an executable program stored in the memory by reading Codes for running a program corresponding to the executable program code for performing a CPU occupancy detection method; wherein the method includes:
    当检测到目标应用对应的CPU占用率大于或等于预设阈值时,获取所述目标应用运行的函数信息;Obtaining function information of the target application running when detecting that the CPU usage of the target application is greater than or equal to a preset threshold;
    获取所述目标应用运行的函数信息中的函数名称;Obtaining a function name in function information of the target application running;
    判断所述函数名称是否满足预设的函数名称记录条件;Determining whether the function name satisfies a preset function name recording condition;
    若所述函数名称满足所述预设的函数名称记录条件,则对所述函数名称进行记录。If the function name satisfies the preset function name recording condition, the function name is recorded.
  10. 一种存储介质,其特征在于,用于存储应用程序,所述应用程序用于执行权利要求1至4中任一项所述的CPU占用的检测方法。 A storage medium for storing an application for executing the CPU occupancy detection method according to any one of claims 1 to 4.
PCT/CN2016/109542 2016-06-01 2016-12-12 Method, device and apparatus for detecting cpu occupation WO2017206476A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610384122.4 2016-06-01
CN201610384122.4A CN106021069A (en) 2016-06-01 2016-06-01 CPU occupation detection method, device and equipment

Publications (1)

Publication Number Publication Date
WO2017206476A1 true WO2017206476A1 (en) 2017-12-07

Family

ID=57089526

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/109542 WO2017206476A1 (en) 2016-06-01 2016-12-12 Method, device and apparatus for detecting cpu occupation

Country Status (2)

Country Link
CN (1) CN106021069A (en)
WO (1) WO2017206476A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109939437A (en) * 2019-03-18 2019-06-28 北京智明星通科技股份有限公司 Games running optimizatin method and device
CN109982144A (en) * 2019-03-12 2019-07-05 四川长虹电器股份有限公司 Monitor and judge the automated testing method that application process CPU occupies superelevation and alarms

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106021069A (en) * 2016-06-01 2016-10-12 北京金山安全软件有限公司 CPU occupation detection method, device and equipment
CN113127051B (en) * 2021-04-28 2024-02-27 上海米哈游璃月科技有限公司 Application resource packaging process monitoring method, device, equipment and medium
CN113778516A (en) * 2021-09-15 2021-12-10 山东派盟网络科技有限公司 Method, device and equipment for optimizing performance

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101344865A (en) * 2008-08-15 2009-01-14 中兴通讯股份有限公司 CPU occupancy rate measuring method and apparatus
CN104021046A (en) * 2014-05-29 2014-09-03 深圳市深信服电子科技有限公司 Method and device for processing applications
CN104239196A (en) * 2014-09-17 2014-12-24 北京金山安全软件有限公司 Method and device for detecting abnormal operation of application program and mobile terminal
CN105224439A (en) * 2014-07-02 2016-01-06 北京金山安全软件有限公司 Method and device for detecting CPU occupancy rate of terminal APP and terminal
CN106021069A (en) * 2016-06-01 2016-10-12 北京金山安全软件有限公司 CPU occupation detection method, device and equipment

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8799861B2 (en) * 2008-01-30 2014-08-05 Intuit Inc. Performance-testing a system with functional-test software and a transformation-accelerator
CN102521098B (en) * 2011-11-23 2014-12-10 中兴通讯股份有限公司 Processing method and processing device for monitoring dead halt of CPU (Central Processing Unit)
CN102999374B (en) * 2012-12-10 2016-05-25 北京神州绿盟信息安全科技股份有限公司 A kind of information recording method based on virtual machine
CN102968352B (en) * 2012-12-14 2015-07-22 杨晓松 System and method for process monitoring and multi-stage recovery
CN105335280A (en) * 2014-07-16 2016-02-17 北京奇虎科技有限公司 Program performance test method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101344865A (en) * 2008-08-15 2009-01-14 中兴通讯股份有限公司 CPU occupancy rate measuring method and apparatus
CN104021046A (en) * 2014-05-29 2014-09-03 深圳市深信服电子科技有限公司 Method and device for processing applications
CN105224439A (en) * 2014-07-02 2016-01-06 北京金山安全软件有限公司 Method and device for detecting CPU occupancy rate of terminal APP and terminal
CN104239196A (en) * 2014-09-17 2014-12-24 北京金山安全软件有限公司 Method and device for detecting abnormal operation of application program and mobile terminal
CN106021069A (en) * 2016-06-01 2016-10-12 北京金山安全软件有限公司 CPU occupation detection method, device and equipment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109982144A (en) * 2019-03-12 2019-07-05 四川长虹电器股份有限公司 Monitor and judge the automated testing method that application process CPU occupies superelevation and alarms
CN109982144B (en) * 2019-03-12 2020-06-30 四川长虹电器股份有限公司 Automatic testing method for monitoring and judging CPU occupancy of application process and alarming
CN109939437A (en) * 2019-03-18 2019-06-28 北京智明星通科技股份有限公司 Games running optimizatin method and device
CN109939437B (en) * 2019-03-18 2022-10-25 北京智明星通科技股份有限公司 Game program operation optimization method and device

Also Published As

Publication number Publication date
CN106021069A (en) 2016-10-12

Similar Documents

Publication Publication Date Title
WO2017206476A1 (en) Method, device and apparatus for detecting cpu occupation
US10838838B2 (en) Method and apparatus for dealing with abnormality of application program and storage medium
US9342237B2 (en) Automated testing of gesture-based applications
US10481964B2 (en) Monitoring activity of software development kits using stack trace analysis
US10713437B2 (en) Method and apparatus for identifying questionable line break characters in an application
WO2018120721A1 (en) Method and system for testing user interface, electronic device, and computer readable storage medium
CN110955428A (en) Page display method and device, electronic equipment and medium
CN105472417B (en) Method and device for acquiring video player abnormity
US20150242380A1 (en) Checking testing coverage
US9459989B2 (en) Method and apparatus for reverse debugging source code using causal analysis
KR20140091555A (en) Measuring web page rendering time
CN107741902B (en) Program application detection method and program application detection device
CN111552633A (en) Interface abnormal call testing method and device, computer equipment and storage medium
CN104899131A (en) Detection method and device of webpage loading in browser, and mobile terminal
CN106959919B (en) Software testing method and device based on testing path diagram
US20130290934A1 (en) Monitoring applications executing on a computer device using programmatic triggers
CN107797922B (en) Application page testing method, electronic device and electronic equipment
CN109271323B (en) Page element processing method and device, test equipment and storage medium
US10445397B2 (en) Method and apparatus for uploading information
CN114036501A (en) APP detection method, system, device, equipment and storage medium
Wu et al. AppCheck: a crowdsourced testing service for android applications
CN112527643A (en) Front-end error detection method and device, electronic equipment and readable storage medium
CN106708705B (en) Terminal background process monitoring method and system
CN107391267B (en) Process detection method and device, electronic equipment and readable storage medium
CN111435326A (en) Method and device for analyzing crash logs

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: 16903856

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 22/03/2019)

122 Ep: pct application non-entry in european phase

Ref document number: 16903856

Country of ref document: EP

Kind code of ref document: A1