WO2019144498A1 - Ios应用的实时帧数监测方法、存储介质、设备及系统 - Google Patents
Ios应用的实时帧数监测方法、存储介质、设备及系统 Download PDFInfo
- Publication number
- WO2019144498A1 WO2019144498A1 PCT/CN2018/081309 CN2018081309W WO2019144498A1 WO 2019144498 A1 WO2019144498 A1 WO 2019144498A1 CN 2018081309 W CN2018081309 W CN 2018081309W WO 2019144498 A1 WO2019144498 A1 WO 2019144498A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- cadisplaylink
- timestamp
- frame number
- accumulated
- class
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/34—Recording 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/3409—Recording 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 for performance assessment
- G06F11/3419—Recording 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 for performance assessment by assessing time
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
- G06F11/302—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3051—Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
Definitions
- the present invention relates to the field of IOS application technologies, and in particular, to a real-time frame number monitoring method, a storage medium, a device and a system for an IOS application.
- Xcode's own Instrument tool is a set of tools in the form of a stand-alone application, including a lot of powerful detection functions: including performance testing on real machines and simulators, performance analysis of APP, inspection of one or more applications Or the behavior of the process.
- the Instrument tool is mainly used to find problems at any time during the debugging process and optimize them in time.
- the Instrument tool can only be used by programmers with application source code. Therefore, it is necessary to connect to the computer and not be able to measure the performance under the user's real use scenario. That is, the IOS application cannot be effectively managed after the IOS application is released.
- the present invention aims to provide a real-time frame number monitoring method, a storage medium, a device and a system for an IOS application, and implement effective management of the real-time frame number of the IOS application after the IOS application is released.
- the technical solution adopted by the present invention is: a real-time frame number monitoring method for an IOS application:
- the callback method bound to CADisplayLink is called to calculate the current frame number; the callback method includes:
- Read the attribute frame interval from CADisplayLink calculate the time interval between two calls according to the timestamp of the current call CADisplayLink and the timestamp of the last call to CADisplayLink, and accumulate the attribute frame interval of CADisplayLink every time during the time interval.
- the number of accumulated frames in the time interval, the number of accumulated frames is divided by the time interval to calculate the current number of frames.
- Calling the callback method bound on CADisplayLink to calculate the current frame number includes:
- the preset difference threshold is 0.5 seconds.
- the attribute frame interval defaults to 1.
- the present invention also discloses a storage medium having stored thereon a computer program that implements a real-time frame number monitoring method of an IOS application when executed by the processor.
- the invention also discloses an electronic device comprising a memory and a processor, wherein the memory stores a computer program running on the processor: the real-time frame number monitoring method of the IOS application is implemented when the processor executes the computer program.
- the invention also discloses a real-time frame number monitoring system for an IOS application, comprising:
- a class creation module that defines an Objective-C class and implements the singleton loading of the class
- a timer creation module configured to create a CADisplayLink when the Objective-C class is initialized, and bind the CADisplayLink callback method to register the CADisplayLink to the IOS running loop;
- the current frame number calculation module is configured to call a callback method bound on CADisplayLink to calculate a current frame number every time the IOS running loop ends; the callback method includes:
- Read the attribute frame interval from CADisplayLink calculate the time interval between two calls according to the timestamp of the current call CADisplayLink and the timestamp of the last call to CADisplayLink, and accumulate the attribute frame interval of CADisplayLink every time during the time interval.
- the number of accumulated frames in the time interval, the number of accumulated frames is divided by the time interval to calculate the current number of frames.
- the class creation module is configured to add three attributes in the class of the Objective-C: an accumulated frame number, a cumulative time interval, and a timestamp of the last call;
- the current frame number calculation module is configured to call a callback method bound on the CADisplayLink, read a timestamp when the CADisplayLink is called, and accumulate the attribute frame interval of the CADisplayLink to the accumulated frame number;
- the preset difference threshold is 0.5 seconds.
- the attribute frame interval defaults to 1.
- the invention defines an Objective-C class and implements the singleton loading of the class, creates a CADisplayLink when the Objective-C class is initialized, registers the CADisplayLink into the IOS running loop, and calls CADisplayLink every time the IOS running loop ends.
- the bound callback method calculates the current number of frames.
- This scheme realizes the real-time frame number monitoring by defining the Objective-C class.
- the code required to develop the Objective-C class in the IOS mobile terminal is small, and the running memory is also small. Therefore, the solution can realize the IOS application after the mobile terminal is released. Effective management of the real-time frame number of the IOS application on the mobile side.
- FIG. 1 is a schematic flowchart of a real-time frame number monitoring method for an IOS application according to an embodiment of the present invention
- FIG. 2 is a schematic structural diagram of a real-time frame number monitoring system for an IOS application according to an embodiment of the present invention.
- Objective-C is mainly used in the writing of IOS operating systems and IOS applications. It is a small runtime library written in C, which makes the size of the application small, and most OO (Object Oriented) systems use a huge VM execution time to replace the operation of the entire system. Objective Programs written in -C are usually not much larger than their original code. The library is also the opposite of the case where the Smalltalk system uses a lot of memory to open a window. At the same time, Objective-C is fully compatible with the standard C language.
- Classes are core features that support object-oriented programming and Objective-C, often referred to as user-defined types. Classes are used to specify the form of an object, which combines data representations and methods to manipulate the data into a neat package.
- the properties of a class are instance variables that are used to provide access to classes of other classes.
- Timer CADisplayLink
- CADisplayLink is a timer that draws content onto the screen at the same frequency as the screen refresh rate. Create a new CADisplayLink object in the application, add it to a runloop, and give it a target and selector to call when the screen is refreshed. Once CADisplayLink registers with the runloop in a specific mode, whenever the screen needs to be refreshed, the runloop will call the selector on the target of the CADisplayLink binding. At this time, the target can read the timestamp of each call of CADisplayLink. Prepare the next frame to display the required data.
- Attribute interval frame attribute interval frame, ie frameInterval.
- the frameInterval attribute is a readable and writable NSInteger type value. It identifies how many frames are used to call the CADisplayLink selector method. The default value is 1, that is, it is called once per frame. If each frame is called once, for IOS devices, the refresh rate is 60HZ or 60 times per second. If frameInterval is set to 2, then two frames will be called, that is, it will be refreshed 30 times per second.
- an embodiment of the present invention provides a real-time frame number monitoring method for an IOS application:
- S1 defines an Objective-C class, and implements the singleton loading of the class
- the callback method bound to CADisplayLink is called to calculate the current frame number; the callback method includes:
- the attribute frame interval is read from CADisplayLink, and the time interval between the two calls is calculated according to the timestamp of the current call CADisplayLink and the timestamp of the last call of CADisplayLink.
- the time interval of each call to the CADisplayLink attribute frame interval is obtained during the accumulated time interval.
- the number of accumulated frames in the frame can be calculated by dividing the number of accumulated frames by the time interval.
- Calling the callback method bound on CADisplayLink to calculate the current frame number includes:
- the difference between the timestamp and the last timestamp is determined. If the difference is less than the preset difference threshold, the difference between the current timestamp and the last timestamp is accumulated into the accumulated time interval; if it is greater than or equal to the preset
- the difference threshold is the number of accumulated frames divided by the cumulative time interval, which is the current number of frames, and the number of accumulated frames and the accumulated time interval are set, and the value of the last timestamp is set to a timestamp.
- the preset difference threshold is 0.5 seconds.
- the attribute frame interval defaults to 1. That is, it is called once every frame. If each frame is called once, the refresh rate is 60HZ or 60 times per second for IOS devices. If frameInterval is set to 2, then two frames will be called, that is, it will be refreshed 30 times per second.
- This scheme realizes the real-time frame number monitoring by defining the Objective-C class.
- the code required to develop the Objective-C class in the IOS mobile terminal is small, and the running memory is also small. Therefore, the solution can realize the IOS application after the mobile terminal is released. Effective management of the real-time frame number of the IOS application on the mobile side.
- the embodiment of the invention discloses a storage medium on which a computer program is stored, and when the computer program is executed by the processor, a real-time frame number monitoring method of the IOS application is implemented.
- the storage medium of the embodiment of the present invention stores a real-time frame number monitoring method for implementing an IOS application.
- the code required for developing the Objective-C class on the IOS mobile terminal is small, and the memory occupied during operation is also small, so the solution can implement the IOS application on the mobile. Effective management of the real-time frame number of the IOS application on the mobile side after the terminal is released.
- the embodiment of the invention discloses an electronic device, which comprises a memory and a processor.
- the memory stores a computer program running on the processor, and the real-time frame number monitoring method of the IOS application is implemented when the processor executes the computer program.
- the memory of the embodiment of the invention stores a computer program running on the processor, and the real-time frame number monitoring method of the IOS application is implemented when the processor executes the computer program.
- the code for developing the Objective-C class on the IOS mobile terminal is small, and the memory occupied by the runtime is also small. Therefore, the solution can effectively manage the real-time frame number of the IOS application of the mobile terminal after the IOS application is released on the mobile terminal.
- an embodiment of the present invention discloses a real-time frame number monitoring system for an IOS application, including:
- a class creation module that defines an Objective-C class and implements the singleton loading of the class
- a timer creation module for creating a CADisplayLink when the Objective-C class is initialized, and binding the CADisplayLink callback method to register the CADisplayLink to the IOS runtime loop;
- the current frame number calculation module is configured to call the callback method bound on CADisplayLink to calculate the current frame number every time the IOS running loop ends; the callback method includes:
- the attribute frame interval is read from CADisplayLink, and the time interval between the two calls is calculated according to the timestamp of the current call CADisplayLink and the timestamp of the last call of CADisplayLink.
- the time interval of each call to the CADisplayLink attribute frame interval is obtained during the accumulated time interval.
- the number of accumulated frames in the frame can be calculated by dividing the number of accumulated frames by the time interval.
- the class creation module is used to add three attributes to the Objective-C class: the cumulative number of frames, the cumulative time interval, and the timestamp of the last call;
- the current frame number calculation module is used to call the callback method bound on the CADisplayLink, read the timestamp when calling CADisplayLink, and accumulate the CADisplayLink attribute frame interval to the accumulated frame number;
- the difference between the timestamp and the last timestamp is determined. If the difference is less than the preset difference threshold, the difference between the current timestamp and the last timestamp is accumulated into the accumulated time interval; if it is greater than or equal to the preset
- the difference threshold is the number of accumulated frames divided by the cumulative time interval, which is the current number of frames, and the number of accumulated frames and the accumulated time interval are set, and the value of the last timestamp is set to a timestamp.
- the preset difference threshold is 0.5 seconds.
- the attribute frame interval defaults to 1.
- the real-time frame number monitoring system of the IOS application in the embodiment of the present invention calculates the current frame number in real time through the class creation module, the timer creation module, and the current frame number calculation module, and the code required to develop the Objective-C class on the IOS mobile terminal is small and runs.
- the occupied memory is also small, so this solution can realize the effective management of the real-time frame number of the IOS application of the mobile terminal after the IOS application is released on the mobile terminal.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Computing Systems (AREA)
- General Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Computer Hardware Design (AREA)
- Debugging And Monitoring (AREA)
Abstract
本发明公开了一种IOS应用的实时帧数监测方法、存储介质、设备及系统,涉及IOS应用技术领域,本发明通过定义一个Objective-C的类,并实现该类单例加载,在Objective-C的类初始化时创建CADisplayLink,将CADisplayLink注册到IOS运行循环中;每次IOS运行循环结束时,调用CADisplayLink上绑定的回调方法计算当前帧数。本方案通过定义Objective-C的类实现实时帧数监测,在IOS移动端开发Objective-C的类所需代码小,运行时占用内存也小,因此本方案可实现IOS应用在移动端发布之后对移动端的IOS应用的实时帧数的有效管理。
Description
本发明涉及IOS应用技术领域,具体涉及一种IOS应用的实时帧数监测方法、存储介质、设备及系统。
在移动应用的开发过程中,可能会遇到一些性能瓶颈,例如程序运行的卡顿或内存无法正确的释放,都无法得到很好的监控或反馈。一般的方法是将手机连上电脑,利用Xcode(一种Mac OS X操作系统上的集成开发工具)所带的Instrument工具进行监控。Xcode自带的Instrument工具是一个以独立APP形式存在的工具集,包含了很多强大的检测功能:其中包括在真机和模拟器上进行性能测试,对APP进行性能分析,检查一个或多个应用或进程的行为。Instrument工具主要用于在调试过程中随时发现问题,及时优化。但是Instrument工具只能供有应用源码的程序员使用,因此必须连接电脑,无法测量用户真实使用场景下的性能,即无法在IOS应用发布之后依然对IOS应用的运行情况进行有效的管理。
发明内容
针对现有技术中存在的缺陷,本发明的目的在于提供一种IOS应用的实时帧数监测方法、存储介质、设备及系统,实现IOS应用发布之后对IOS应用的实时帧数的有效管理。
为达到以上目的,本发明采取的技术方案是:一种IOS应用的实时帧数监测方法:
定义一个Objective-C的类,并实现该类单例加载;在所述Objective-C的类初始化时创建定时器CADisplayLink,并绑定好CADisplayLink的回调方法,将CADisplayLink注册到IOS运行循环中;
每次IOS运行循环结束时,调用CADisplayLink上绑定的回调方法计算出当前帧数;所述回调方法包括:
从CADisplayLink中读取属性帧间隔,根据当前调用CADisplayLink的时间戳与上一次调用CADisplayLink的时间戳计算出两次调用的时间间隔,累计所述时间间隔内每次调用CADisplayLink的属性帧间隔得出该时间间隔内的累计帧数,用累计帧数除以时间间隔即可计算出当前帧数。
在上述技术方案的基础上,在所述Objective-C的类中增加三个属性:累计帧数量、累计时间间隔和上一次调用的时间戳;
调用CADisplayLink上绑定的回调方法计算当前帧数包括:
调用CADisplayLink上绑定的回调方法,读取调用CADisplayLink时的时间戳,将CADisplayLink的属性帧间隔累计至所述累计帧数量;
判断所述时间戳与所述上一次调用的时间戳之差值,若小于预设的差值阈值,则将当前时间戳与所述上一次调用的时间戳之差值累计至累计时间间隔中;若大于等于预设的差值阈值,则用累计帧数量除以累计时间间隔即为当前帧数,并置空累计帧数量和累计时间间隔,将所述上一次调用的时间戳的值设置为所述时间戳。
在上述技术方案的基础上,所述预设的差值阈值为0.5秒。
在上述技术方案的基础上,所述属性帧间隔默认值为1。
本发明还公开了一种存储介质,该存储介质上存储有计算机程序:所述计算机程序被处理器执行时实现IOS应用的实时帧数监测方 法。
本发明还公开了一种电子设备,包括存储器和处理器,存储器上储存有在处理器上运行的计算机程序:处理器执行计算机程序时实现IOS应用的实时帧数监测方法。
本发明还公开了一种IOS应用的实时帧数监测系统,包括:
类创建模块,其用于定义一个Objective-C的类,并实现该类单例加载;
定时器创建模块,其用于在所述Objective-C的类初始化时创建CADisplayLink,并绑定好CADisplayLink的回调方法,将CADisplayLink注册到IOS运行循环中;
当前帧数计算模块,其用于每次IOS运行循环结束时,调用CADisplayLink上绑定的回调方法计算当前帧数;所述回调方法包括:
从CADisplayLink中读取属性帧间隔,根据当前调用CADisplayLink的时间戳与上一次调用CADisplayLink的时间戳计算出两次调用的时间间隔,累计所述时间间隔内每次调用CADisplayLink的属性帧间隔得出该时间间隔内的累计帧数,用累计帧数除以时间间隔即可计算出当前帧数。
在上述技术方案的基础上,类创建模块用于在所述Objective-C的类中增加三个属性:累计帧数量、累计时间间隔和上一次调用的时间戳;
所述当前帧数计算模块用于调用CADisplayLink上绑定的回调方法,读取调用CADisplayLink时的时间戳,将CADisplayLink的属性帧间隔累计至所述累计帧数量;
判断所述时间戳与所述上一次调用的时间戳之差值,若小于预设的差值阈值,则将当前时间戳与所述上一次调用的时间戳之差值累计 至累计时间间隔中;若大于等于预设的差值阈值,则用累计帧数量除以累计时间间隔即为当前帧数,并置空累计帧数量和累计时间间隔,将所述上一次调用的时间戳的值设置为所述时间戳。
在上述技术方案的基础上,所述预设的差值阈值为0.5秒。
在上述技术方案的基础上,所述属性帧间隔默认值为1。
与现有技术相比,本发明的优点在于:
本发明通过定义一个Objective-C的类,并实现该类单例加载,在Objective-C的类初始化时创建CADisplayLink,将CADisplayLink注册到IOS运行循环中;每次IOS运行循环结束时,调用CADisplayLink上绑定的回调方法计算当前帧数。本方案通过定义Objective-C的类实现实时帧数监测,在IOS移动端开发Objective-C的类所需代码小,运行时占用内存也小,因此本方案可实现IOS应用在移动端发布之后对移动端的IOS应用的实时帧数的有效管理。
图1为本发明实施例中IOS应用的实时帧数监测方法的流程示意图;
图2为本发明实施例中IOS应用的实时帧数监测系统的结构示意图。
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。此外,下面所描述的本发明各个实施方式中所涉及到的技术特征只要彼此之间未构成冲突就可以相互组合。
以下首先就本发明的术语进行解释和说明:
Objective-C:Objective-C主要应用于IOS操作系统和IOS应用程序的编写。它是一个用C写成很小的运行库,令应用程序的尺寸增加很小,和大部分OO(Object Oriented,面向对象)系统使用极大的VM执行时间会取代了整个系统的运作相反,Objective-C写成的程序通常不会比其原始码大很多。而其函式库亦和Smalltalk系统要使用极大的内存来开启一个窗口的情况相反。同时,Objective-C完全兼容标准C语言。
Objective-C的类和属性:类是核心支持面向对象编程及Objective-C的特点,通常被称为用户定义的类型。类是用来指定对象的形式,它结合了数据表示和方法操纵这些数据转换成一个整齐的包。类的属性是用来提供访问其他类的类的实例变量。
实现类单例加载:即保证一个类只生成一个实例对象。
定时器:即CADisplayLink,CADisplayLink是一个能以和屏幕刷新率相同的频率将内容画到屏幕上的定时器。在应用中创建一个新的CADisplayLink对象,把它添加到一个runloop中,并给它提供一个target和selector在屏幕刷新的时候调用。一但CADisplayLink以特定的模式注册到runloop之后,每当屏幕需要刷新的时候,runloop就会调用CADisplayLink绑定的target上的selector,这时target可以读到CADisplayLink的每次调用的时间戳,用来准备下一帧显示需要的数据。
属性间隔帧:属性间隔帧,即frameInterval。frameInterval属性是可读可写的NSInteger型值,标识间隔多少帧调用一次CADisplayLink的selector方法,默认值是1,即每帧都调用一次。如果每帧都调用一次的话,对于IOS设备来说那刷新频率就是60HZ也 就是每秒60次,如果将frameInterval设为2那么就会两帧调用一次,也就是变成了每秒刷新30次。
实施例1:
参见图1所示,本发明实施例提供一种IOS应用的实时帧数监测方法:
S1,定义一个Objective-C的类,并实现该类单例加载;
S2,在Objective-C的类初始化时创建CADisplayLink,并绑定好CADisplayLink的回调方法,将CADisplayLink注册到IOS运行循环中;
S3,每次IOS运行循环结束时,调用CADisplayLink上绑定的回调方法计算出当前帧数;回调方法包括:
从CADisplayLink中读取属性帧间隔,根据当前调用CADisplayLink的时间戳与上一次调用CADisplayLink的时间戳计算出两次调用的时间间隔,累计时间间隔内每次调用CADisplayLink的属性帧间隔得出该时间间隔内的累计帧数,用累计帧数除以时间间隔即可计算出当前帧数。
在Objective-C的类中增加三个属性:累计帧数量、累计时间间隔和上一次调用的时间戳;
调用CADisplayLink上绑定的回调方法计算当前帧数包括:
调用CADisplayLink上绑定的回调方法,读取调用CADisplayLink时的时间戳,将CADisplayLink的属性帧间隔累计至累计帧数量;
判断时间戳与上一次调用的时间戳之差值,若小于预设的差值阈值,则将当前时间戳与上一次调用的时间戳之差值累计至累计时间间隔中;若大于等于预设的差值阈值,则用累计帧数量除以累计时间间隔即为当前帧数,并置空累计帧数量和累计时间间隔,将上一次调用 的时间戳的值设置为时间戳。
其中,预设的差值阈值为0.5秒。属性帧间隔默认值为1。即每帧都调用一次。如果每帧都调用一次的话,对于IOS设备来说那刷新频率就是60HZ也就是每秒60次,如果将frameInterval设为2那么就会两帧调用一次,也就是变成了每秒刷新30次。
本方案通过定义Objective-C的类实现实时帧数监测,在IOS移动端开发Objective-C的类所需代码小,运行时占用内存也小,因此本方案可实现IOS应用在移动端发布之后对移动端的IOS应用的实时帧数的有效管理。
实施例2:
本发明实施例公开了一种存储介质,该存储介质上存储有计算机程序,计算机程序被处理器执行时实现IOS应用的实时帧数监测方法。
本发明实施例的存储介质存储有实现IOS应用的实时帧数监测方法,在IOS移动端开发Objective-C的类所需代码小,运行时占用内存也小,因此本方案可实现IOS应用在移动端发布之后对移动端的IOS应用的实时帧数的有效管理。
实施例3:
本发明实施例公开了一种电子设备,包括存储器和处理器,存储器上储存有在处理器上运行的计算机程序,处理器执行计算机程序时实现IOS应用的实时帧数监测方法。
本发明实施例的存储器上储存有在处理器上运行的计算机程序,处理器执行计算机程序时实现IOS应用的实时帧数监测方法。在IOS移动端开发Objective-C的类所需代码小,运行时占用内存也小,因此本方案可实现IOS应用在移动端发布之后对移动端的IOS应用的 实时帧数的有效管理。
实施例4:
参见图2所示,本发明实施例公开了一种IOS应用的实时帧数监测系统,包括:
类创建模块,其用于定义一个Objective-C的类,并实现该类单例加载;
定时器创建模块,其用于在Objective-C的类初始化时创建CADisplayLink,并绑定好CADisplayLink的回调方法,将CADisplayLink注册到IOS运行循环中;
当前帧数计算模块,其用于每次IOS运行循环结束时,调用CADisplayLink上绑定的回调方法计算当前帧数;回调方法包括:
从CADisplayLink中读取属性帧间隔,根据当前调用CADisplayLink的时间戳与上一次调用CADisplayLink的时间戳计算出两次调用的时间间隔,累计时间间隔内每次调用CADisplayLink的属性帧间隔得出该时间间隔内的累计帧数,用累计帧数除以时间间隔即可计算出当前帧数。
类创建模块用于在Objective-C的类中增加三个属性:累计帧数量、累计时间间隔和上一次调用的时间戳;
当前帧数计算模块用于调用CADisplayLink上绑定的回调方法,读取调用CADisplayLink时的时间戳,将CADisplayLink的属性帧间隔累计至累计帧数量;
判断时间戳与上一次调用的时间戳之差值,若小于预设的差值阈值,则将当前时间戳与上一次调用的时间戳之差值累计至累计时间间隔中;若大于等于预设的差值阈值,则用累计帧数量除以累计时间间隔即为当前帧数,并置空累计帧数量和累计时间间隔,将上一次调用 的时间戳的值设置为时间戳。预设的差值阈值为0.5秒。属性帧间隔默认值为1。
本发明实施例的IOS应用的实时帧数监测系统通过类创建模块、定时器创建模块和当前帧数计算模块实时计算当前帧数,在IOS移动端开发Objective-C的类所需代码小,运行时占用内存也小,因此本方案可实现IOS应用在移动端发布之后对移动端的IOS应用的实时帧数的有效管理。
本发明不局限于上述实施方式,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也视为本发明的保护范围之内。本说明书中未作详细描述的内容属于本领域专业技术人员公知的现有技术。
Claims (10)
- 一种IOS应用的实时帧数监测方法,其特征在于:定义一个Objective-C的类,并实现该类单例加载;在所述Objective-C的类初始化时创建定时器CADisplayLink,并绑定好CADisplayLink的回调方法,将CADisplayLink注册到IOS运行循环中;每次IOS运行循环结束时,调用CADisplayLink上绑定的回调方法计算出当前帧数;所述回调方法包括:从CADisplayLink中读取属性帧间隔,根据当前调用CADisplayLink的时间戳与上一次调用CADisplayLink的时间戳计算出两次调用的时间间隔,累计所述时间间隔内每次调用CADisplayLink的属性帧间隔得出该时间间隔内的累计帧数,用累计帧数除以时间间隔即可计算出当前帧数。
- 如权利要求1所述的一种IOS应用的实时帧数监测方法,其特征在于:在所述Objective-C的类中增加三个属性:累计帧数量、累计时间间隔和上一次调用的时间戳;调用CADisplayLink上绑定的回调方法计算当前帧数包括:调用CADisplayLink上绑定的回调方法,读取调用CADisplayLink时的时间戳,将CADisplayLink的属性帧间隔累计至所述累计帧数量;判断所述时间戳与所述上一次调用的时间戳之差值,若小于预设的差值阈值,则将当前时间戳与所述上一次调用的时间戳之差值累计至累计时间间隔中;若大于等于预设的差值阈值,则用累计帧数量除以累计时间间隔即为当前帧数,并置空累计帧数量和累计时间间隔,将所述上一次调用的时间戳的值设置为所述时间戳。
- 如权利要求2所述的一种IOS应用的实时帧数监测方法,其特征在于:所述预设的差值阈值为0.5秒。
- 如权利要求1所述的一种IOS应用的实时帧数监测方法,其特征在于:所述属性帧间隔默认值为1。
- 一种存储介质,该存储介质上存储有计算机程序,其特征在于:所述计算机程序被处理器执行时实现权利要求1至4任一项所述的方法。
- 一种电子设备,包括存储器和处理器,存储器上储存有在处理器上运行的计算机程序,其特征在于:处理器执行计算机程序时实现权利要求1至4任一项所述的方法。
- 一种IOS应用的实时帧数监测系统,其特征在于,包括:类创建模块,其用于定义一个Objective-C的类,并实现该类单例加载;定时器创建模块,其用于在所述Objective-C的类初始化时创建CADisplayLink,并绑定好CADisplayLink的回调方法,将CADisplayLink注册到IOS运行循环中;当前帧数计算模块,其用于每次IOS运行循环结束时,调用CADisplayLink上绑定的回调方法计算当前帧数;所述回调方法包括:从CADisplayLink中读取属性帧间隔,根据当前调用CADisplayLink的时间戳与上一次调用CADisplayLink的时间戳计算出两次调用的时间间隔,累计所述时间间隔内每次调用CADisplayLink的属性帧间隔得出该时间间隔内的累计帧数,用累计帧数除以时间间隔即可计算出当前帧数。
- 如权利要求7所述的一种IOS应用的实时帧数监测系统,其特征在于:类创建模块用于在所述Objective-C的类中增加三个属性:累计帧数量、累计时间间隔和上一次调用的时间戳;所述当前帧数计算模块用于调用CADisplayLink上绑定的回调方法,读取调用CADisplayLink时的时间戳,将CADisplayLink的属性帧间隔累计至所述累计帧数量;判断所述时间戳与所述上一次调用的时间戳之差值,若小于预设的差值阈值,则将当前时间戳与所述上一次调用的时间戳之差值累计至累计时间间隔中;若大于等于预设的差值阈值,则用累计帧数量除以累计时间间隔即为当前帧数,并置空累计帧数量和累计时间间隔,将所述上一次调用的时间戳的值设置为所述时间戳。
- 如权利要求8所述的一种IOS应用的实时帧数监测系统,其特征在于:所述预设的差值阈值为0.5秒。
- 如权利要求7所述的一种IOS应用的实时帧数监测系统,其特征在于:所述属性帧间隔默认值为1。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810064284.9 | 2018-01-23 | ||
CN201810064284.9A CN108304294B (zh) | 2018-01-23 | 2018-01-23 | Ios应用的实时帧数监测方法、存储介质、设备及系统 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2019144498A1 true WO2019144498A1 (zh) | 2019-08-01 |
Family
ID=62866264
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2018/081309 WO2019144498A1 (zh) | 2018-01-23 | 2018-03-30 | Ios应用的实时帧数监测方法、存储介质、设备及系统 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN108304294B (zh) |
WO (1) | WO2019144498A1 (zh) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112052146A (zh) * | 2020-07-24 | 2020-12-08 | 北京奇艺世纪科技有限公司 | 页面帧率测试方法、应用的安装文件生成方法及装置 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106557426A (zh) * | 2016-11-30 | 2017-04-05 | 武汉斗鱼网络科技有限公司 | 一种用于分析Android端应用运行流畅度的方法和系统 |
CN107038107A (zh) * | 2017-03-09 | 2017-08-11 | 武汉斗鱼网络科技有限公司 | 一种获取应用卡顿信息的方法及装置 |
CN107102936A (zh) * | 2017-05-27 | 2017-08-29 | 腾讯科技(深圳)有限公司 | 一种流畅度的评估方法和移动终端以及存储介质 |
US20170352325A1 (en) * | 2016-06-03 | 2017-12-07 | Apple Inc. | Controlling Display Performance Using Animation Based Refresh Rates |
CN107783886A (zh) * | 2016-08-25 | 2018-03-09 | 平安科技(深圳)有限公司 | 一种获取运行帧率的方法及终端 |
-
2018
- 2018-01-23 CN CN201810064284.9A patent/CN108304294B/zh active Active
- 2018-03-30 WO PCT/CN2018/081309 patent/WO2019144498A1/zh active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170352325A1 (en) * | 2016-06-03 | 2017-12-07 | Apple Inc. | Controlling Display Performance Using Animation Based Refresh Rates |
CN107783886A (zh) * | 2016-08-25 | 2018-03-09 | 平安科技(深圳)有限公司 | 一种获取运行帧率的方法及终端 |
CN106557426A (zh) * | 2016-11-30 | 2017-04-05 | 武汉斗鱼网络科技有限公司 | 一种用于分析Android端应用运行流畅度的方法和系统 |
CN107038107A (zh) * | 2017-03-09 | 2017-08-11 | 武汉斗鱼网络科技有限公司 | 一种获取应用卡顿信息的方法及装置 |
CN107102936A (zh) * | 2017-05-27 | 2017-08-29 | 腾讯科技(深圳)有限公司 | 一种流畅度的评估方法和移动终端以及存储介质 |
Also Published As
Publication number | Publication date |
---|---|
CN108304294A (zh) | 2018-07-20 |
CN108304294B (zh) | 2020-05-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8938729B2 (en) | Two pass automated application instrumentation | |
US8561033B2 (en) | Selective branch-triggered trace generation apparatus and method | |
US11055197B2 (en) | Tentative execution of code in a debugger | |
US8522213B2 (en) | Debugger and debugging methods using breakpoints conditioned on the static identity of data | |
US8745596B2 (en) | Program debugging with dynamically inserted instrumentation | |
US9588872B2 (en) | Discovery of code paths | |
US10949332B2 (en) | Data race analysis based on altering function internal loads during time-travel debugging | |
US20060059486A1 (en) | Call stack capture in an interrupt driven architecture | |
US9792402B1 (en) | Method and system for debugging a system on chip under test | |
US10725889B2 (en) | Testing multi-threaded applications | |
US9824000B1 (en) | Testing calling code dynamically with random error injection based on user-specified configuration | |
US10209984B2 (en) | Identifying a defect density | |
US6978399B2 (en) | Debug thread termination control points | |
US20130152042A1 (en) | Automated and heuristically managed solution to quantify cpu and path length cost of instructions added, changed or removed by a service team | |
US20160062875A1 (en) | Method for altering execution of a program, debugger, and computer-readable medium | |
EP3942418A1 (en) | Emulating non-traced code with a recorded execution of traced code | |
WO2019144498A1 (zh) | Ios应用的实时帧数监测方法、存储介质、设备及系统 | |
CN108197005B (zh) | Ios应用的底层运行性能监测方法、介质、设备及系统 | |
CN113778838A (zh) | 二进制程序动态污点分析方法及装置 | |
WO2020073200A1 (zh) | 调试程序的方法和系统 | |
US11847433B2 (en) | Source code editing combining edit and continue with hot reload | |
CN109343953B (zh) | 内存管理方法、装置及电子设备 | |
US10514969B2 (en) | Bit-accurate-tracing analysis with applied memory region lifetimes | |
CN101650688A (zh) | 一种访问vm_io地址空间的方法和用户态调试器 | |
CN113157513B (zh) | 一种堆内存破坏检测方法、装置、电子设备及存储介质 |
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: 18902748 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 18902748 Country of ref document: EP Kind code of ref document: A1 |