iOS:Add PerformanceProfile

This commit is contained in:
pengfei.zhou
2021-03-29 17:53:27 +08:00
committed by osborn
parent 51719d3fc7
commit a40413f991
7 changed files with 174 additions and 0 deletions

View File

@@ -28,6 +28,7 @@
#import <sys/utsname.h>
#import "DoricContext.h"
#import "DoricContextManager.h"
#import "DoricPerformanceProfile.h"
@interface DoricDefaultMonitor : NSObject <DoricMonitorProtocol>
@end
@@ -49,6 +50,7 @@ @interface DoricJSEngine ()
@property(nonatomic, strong) NSThread *jsThread;
@property(nonatomic, assign) BOOL destroyed;
@property(nonatomic, assign) BOOL initialized;
@property(nonatomic, strong) DoricPerformanceProfile *profile;
@end
@implementation DoricJSEngine
@@ -56,6 +58,8 @@ @implementation DoricJSEngine
- (instancetype)init {
if (self = [super init]) {
_initialized = NO;
_profile = [[DoricPerformanceProfile alloc] initWithName:@"JSEngine"];
[_profile prepare:@"Init"];
_jsThread = [[NSThread alloc] initWithTarget:self selector:@selector(threadRun) object:nil];
[_jsThread start];
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
@@ -93,6 +97,7 @@ - (instancetype)init {
}.mutableCopy;
self.registry = [[DoricRegistry alloc] initWithJSEngine:self];
[self ensureRunOnJSThread:^() {
[_profile start:@"Init"];
self.timers = [[NSMutableDictionary alloc] init];
self.bridgeExtension = [DoricBridgeExtension new];
self.bridgeExtension.registry = self.registry;
@@ -100,6 +105,7 @@ - (instancetype)init {
[self initJSExecutor];
[self initDoricEnvironment];
self.initialized = YES;
[_profile end:@"Init"];
}];
[self.registry registerMonitor:[DoricDefaultMonitor new]];
}