XXPerformanceMonitor
Swift 版轻量级卡顿监控工具,支持主线程和子线程,一行代码即可轻松集成。
上手指南
根据项目需要,在适当的位置启动,通常可以在 AppDelegate
的 didFinishLaunching
方法中。一行代码即可启动主线程监控:
XXPerformanceMonitor.sharedInstance.startMonitorMain()
如果想要监听子线程队列,只需将其添加到监控器中:
let testQueue = OperationQueue()
XXPerformanceMonitor.sharedInstance.addMonitorChild(testQueue)
如果想停止监听,可以直接调用以下方法,关闭所有监控:
XXPerformanceMonitor.sharedInstance.clean()
同时也提供了单独移除子线程监控的方法:
XXPerformanceMonitor.sharedInstance.removeMonitorChild(testQueue)
并且提供了代理方法供外部获取卡顿信息:
public protocol XXPerformanceMonitorDelegate: class {
func handleThread(reason: String, domain: XXPerformanceMonitorDomain)
}
更多详细信息请参考《天罗地网? iOS卡顿监控实战》
安装
- CocoaPods
pod 'XXPerformanceMonitor'
- 下载源码,将 Source 文件夹添加到项目中。
其他
本库未引入其他第三方库,请放心使用。
如有Bug或建议,欢迎提交 issue。
如果使用过程中还算顺利,欢迎 star :)