测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | MIT |
发布最后发布 | 2017年5月 |
由 Anton Bukov 维护。
依赖 | |
PLCrashReporter-DynamicFramework | ~> 1.3.0.1 |
RuntimeRoutines | >= 0 |
主线程性能监控器
请仅在 DEBUG
下使用
#ifdef DEBUG
#import <PuppyWatchdog/PuppyWatchdog.h>
#endif
@interface AppDelegate ()
#ifdef DEBUG
@property (strong, nonatomic) MLWPuppyWatchdog *watchdog;
#endif
@end
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#ifdef DEBUG
self.watchdog = [[MLWPuppyWatchdog alloc] init];
#endif
}
测试代码
- (NSUInteger)innerLoop {
NSUInteger count = 0;
for (NSUInteger i = 0; i < 100000000; i++) {
count++;
}
return count;
}
- (NSUInteger)innerLoop2 {
NSUInteger count = 0;
for (NSUInteger i = 0; i < 50000000; i++) {
count++;
}
return count;
}
测试输出
2017-01-16 23:27:11.100 xctest[79336:418608] 🐶 Main thread was blocked for 0.10 sec
2017-01-16 23:27:11.200 xctest[79336:418608] 🐶 Main thread is still blocked for 0.20 sec
2017-01-16 23:27:11.301 xctest[79336:418608] 🐶 Main thread is still blocked for 0.30 sec
2017-01-16 23:27:11.401 xctest[79336:418608] 🐶 Main thread is still blocked for 0.40 sec
2017-01-16 23:27:11.502 xctest[79336:418608]
🐶🐶🐶🐶🐶🐶🐶🐶🐶🐶 Collected 730 reports for 0.49 sec processed for 0.02 sec:
99.863% start (in libdyld.dylib)
| 99.863% <Unknown> (in <Unknown>)
| | 99.863% _XCTestMain (in XCTest)
| | | 99.863% -[XCTestDriver _checkForTestManager] (in XCTest)
| | | | 99.863% -[XCTestDriver _runSuite] (in XCTest)
| | | | | 99.863% -[XCTestObservationCenter _observeTestExecutionForBlock:] (in XCTest)
| | | | | | 99.863% __25-[XCTestDriver _runSuite]_block_invoke (in XCTest)
| | | | | | | 99.863% -[XCTestSuite performTest:] (in XCTest)
| | | | | | | | 99.863% -[XCTestSuite performTest:] (in XCTest)
| | | | | | | | | 99.863% -[XCTestSuite performTest:] (in XCTest)
| | | | | | | | | | 99.863% -[XCTestCase performTest:] (in XCTest)
| | | | | | | | | | | 99.863% -[XCTestCase invokeTest] (in XCTest)
| | | | | | | | | | | | 99.863% -[XCTestContext performInScope:] (in XCTest)
| | | | | | | | | | | | | 99.863% __24-[XCTestCase invokeTest]_block_invoke_2 (in XCTest)
| | | | | | | | | | | | | | 99.863% -[NSInvocation invoke] (in CoreFoundation)
| | | | | | | | | | | | | | | 99.863% __invoking___ (in CoreFoundation)
| | | | | | | | | | | | | | | | 99.863% -[Tests testExample] (in PuppyWatchdog_Tests)
| | | | | | | | | | | | | | | | | 56.521% -[Tests innerLoop] (in PuppyWatchdog_Tests)
| | | | | | | | | | | | | | | | | 43.342% -[Tests innerLoop2] (in PuppyWatchdog_Tests)
🐶🐶🐶🐶🐶🐶🐶🐶🐶🐶
支持 iOS 和 macOS 平台,watchOS 和 tvOS 的支持需要在 PLCrashReporter 支持它们之后实现。
PuppyWatchdog 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'PuppyWatchdog', :configurations => ['Debug']
如果您使用 use_frameworks!
,您可能在 Podfile 中还需要此代码
pre_install do |installer|
def installer.verify_no_static_framework_transitive_dependencies; end
end
post_install do |installer|
installer.pods_project.targets.flat_map(&:build_configurations).each { |bc|
bc.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'Yes'
}
end
如果您使用 Carthage,请报告您遇到的问题。 将很快添加 Carthage 指令。
Anton Bukov,[email protected]
PuppyWatchdog 在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。