Skip to content

App性能监测,包含主线程卡顿、CPU消耗过高记录、以及函数调用耗时等功能。提供本地缓存能力,使用者可选合适的时机上传给后台以供分析。

License

Notifications You must be signed in to change notification settings

iBlackStone/ISAppMonitor

Repository files navigation

AppMonitor

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

DemoCode

卡顿监测 & CPU消耗

typedef NS_OPTIONS(NSUInteger, AppMonitorOptions) {
    AppMonitorCPUUsage = 1 << 0,
    AppMonitorMainRunLoopStuck = 1 << 1,
};

@interface AppMonitor : NSObject

+ (instancetype)sharedInstance;

- (void)startMointor:(AppMonitorOptions)options;

- (void)stopMointor:(AppMonitorOptions)options;

@end

函数调用分析

@interface AppMonitor (FuncTime)

- (void)start;
- (void)startWithMaxDepth:(int)depth;
- (void)startWithMinTimeCost:(double)ms;
- (void)startWithMaxDepth:(int)depth minTimeCost:(double)ms;

- (void)saveToDB;

- (void)stop;
- (void)clearMemory;

@end

线程安全的本地缓存

// 本类只负责本地记录,上传需求比较灵活,此处不再封装
@interface AppMonitor (Record)

- (void)recordStackInfo:(AMStackModel *)model;
- (void)clearStackInfo;

- (void)recordFuncInfo:(AMFuncCostModel *)model;
- (void)clearFuncInfo;

@end

Tasks

  • 程序有消耗性能的地方 thread get state。这个也会被监控检查出,所以可以过滤掉这样的堆栈信息

Requirements

Installation

AppMonitor is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ISAppMonitor'

Search

-> ISAppMonitor (0.1.9)
   集成有关App的性能监控功能
   pod 'ISAppMonitor', '~> 0.1.9'
   - Homepage: https://github.com/iBlackStone/AppMonitor
   - Source:   https://github.com/iBlackStone/AppMonitor.git
   - Versions: 0.1.9 [Master repo]
   - Subspecs:
     - ISAppMonitor/Core (0.1.9)
     - ISAppMonitor/Database (0.1.9)
     - ISAppMonitor/Model (0.1.9)
     - ISAppMonitor/Utils (0.1.9)
(END)

Author

参考大牛代码,感谢他们无私的分享

  1. 戴铭 - iOS开发高手课

License

AppMonitor is available under the MIT license. See the LICENSE file for more info.

About

App性能监测,包含主线程卡顿、CPU消耗过高记录、以及函数调用耗时等功能。提供本地缓存能力,使用者可选合适的时机上传给后台以供分析。

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published