Remove last arg from RCTProfileEnd, make macro's function-like

Reviewed By: tadeuzagallo

Differential Revision: D3801302

fbshipit-source-id: 297a58db876366e21e232094c1361aa0dcd9016d
This commit is contained in:
Pieter De Baets 2016-09-05 11:11:37 -07:00 коммит произвёл Facebook Github Bot 9
Родитель 3f5a263307
Коммит 1a7c231ef3
11 изменённых файлов: 73 добавлений и 95 удалений

Просмотреть файл

@ -146,7 +146,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)dele
[performanceLogger markStartForTag:RCTPLNativeModulePrepareConfig]; [performanceLogger markStartForTag:RCTPLNativeModulePrepareConfig];
config = [weakSelf moduleConfig]; config = [weakSelf moduleConfig];
[performanceLogger markStopForTag:RCTPLNativeModulePrepareConfig]; [performanceLogger markStopForTag:RCTPLNativeModulePrepareConfig];
RCT_PROFILE_END_EVENT(0, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
}); });
@ -174,7 +174,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)dele
} }
}); });
RCT_PROFILE_END_EVENT(0, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
- (void)loadSource:(RCTSourceLoadBlock)_onSourceLoad - (void)loadSource:(RCTSourceLoadBlock)_onSourceLoad
@ -334,7 +334,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)dele
_javaScriptExecutor = (id<RCTJavaScriptExecutor>)module; _javaScriptExecutor = (id<RCTJavaScriptExecutor>)module;
} }
} }
RCT_PROFILE_END_EVENT(0, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
// The executor is a bridge module, but we want it to be instantiated before // The executor is a bridge module, but we want it to be instantiated before
// any other module has access to the bridge, in case they need the JS thread. // any other module has access to the bridge, in case they need the JS thread.
@ -352,7 +352,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)dele
// NOTE: _javaScriptExecutor is a weak reference // NOTE: _javaScriptExecutor is a weak reference
_javaScriptExecutor = executorModule; _javaScriptExecutor = executorModule;
} }
RCT_PROFILE_END_EVENT(0, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
// Set up moduleData for automatically-exported modules // Set up moduleData for automatically-exported modules
RCT_PROFILE_BEGIN_EVENT(0, @"ModuleData", nil); RCT_PROFILE_BEGIN_EVENT(0, @"ModuleData", nil);
@ -388,7 +388,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)dele
_moduleDataByID = [moduleDataByID copy]; _moduleDataByID = [moduleDataByID copy];
_moduleDataByName = [moduleDataByName copy]; _moduleDataByName = [moduleDataByName copy];
_moduleClassesByID = [moduleClassesByID copy]; _moduleClassesByID = [moduleClassesByID copy];
RCT_PROFILE_END_EVENT(0, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
// Synchronously set up the pre-initialized modules // Synchronously set up the pre-initialized modules
RCT_PROFILE_BEGIN_EVENT(0, @"extraModules", nil); RCT_PROFILE_BEGIN_EVENT(0, @"extraModules", nil);
@ -404,7 +404,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)dele
(void)[moduleData instance]; (void)[moduleData instance];
} }
} }
RCT_PROFILE_END_EVENT(0, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
// From this point on, RCTDidInitializeModuleNotification notifications will // From this point on, RCTDidInitializeModuleNotification notifications will
// be sent the first time a module is accessed. // be sent the first time a module is accessed.
@ -413,7 +413,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)dele
[self prepareModulesWithDispatchGroup:dispatchGroup]; [self prepareModulesWithDispatchGroup:dispatchGroup];
[_performanceLogger markStopForTag:RCTPLNativeModuleInit]; [_performanceLogger markStopForTag:RCTPLNativeModuleInit];
RCT_PROFILE_END_EVENT(0, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
- (void)prepareModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup - (void)prepareModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup
@ -471,7 +471,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)dele
} }
[_performanceLogger setValue:_modulesInitializedOnMainQueue forTag:RCTPLNativeModuleMainThreadUsesCount]; [_performanceLogger setValue:_modulesInitializedOnMainQueue forTag:RCTPLNativeModuleMainThreadUsesCount];
RCT_PROFILE_END_EVENT(0, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
- (void)whitelistedModulesDidChange - (void)whitelistedModulesDidChange
@ -580,7 +580,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)dele
for (dispatch_block_t call in pendingCalls) { for (dispatch_block_t call in pendingCalls) {
call(); call();
} }
RCT_PROFILE_END_EVENT(0, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
- (void)stopLoadingWithError:(NSError *)error - (void)stopLoadingWithError:(NSError *)error
@ -676,7 +676,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
block(); block();
} }
RCT_PROFILE_END_EVENT(0, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
}]; }];
} else if (queue) { } else if (queue) {
dispatch_async(queue, block); dispatch_async(queue, block);
@ -780,7 +780,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
completion(); completion();
} }
} queue:RCTJSThread]; } queue:RCTJSThread];
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
/** /**
@ -833,13 +833,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"FetchApplicationScriptCallbacks", nil); RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"FetchApplicationScriptCallbacks", nil);
[self->_javaScriptExecutor flushedQueue:^(id json, NSError *error) [self->_javaScriptExecutor flushedQueue:^(id json, NSError *error)
{ {
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,init", @{ RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,init");
@"json": RCTNullIfNil(json),
@"error": RCTNullIfNil(error),
});
[self handleBuffer:json batchEnded:YES]; [self handleBuffer:json batchEnded:YES];
onComplete(error); onComplete(error);
}]; }];
}]; }];
@ -957,9 +952,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
dispatch_block_t block = ^{ dispatch_block_t block = ^{
RCTProfileEndFlowEvent(); RCTProfileEndFlowEvent();
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTBatchedBridge handleBuffer:]", nil);
NSOrderedSet *calls = [buckets objectForKey:queue]; NSOrderedSet *calls = [buckets objectForKey:queue];
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTBatchedBridge handleBuffer:]", (@{
@"calls": @(calls.count),
}));
@autoreleasepool { @autoreleasepool {
for (NSNumber *indexObj in calls) { for (NSNumber *indexObj in calls) {
NSUInteger index = indexObj.unsignedIntegerValue; NSUInteger index = indexObj.unsignedIntegerValue;
@ -978,9 +976,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
} }
} }
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call,dispatch_async", @{ RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call,dispatch_async");
@"calls": @(calls.count),
});
}; };
[self dispatchBlock:block queue:queue]; [self dispatchBlock:block queue:queue];

Просмотреть файл

@ -251,7 +251,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
[self createBatchedBridge]; [self createBatchedBridge];
RCT_PROFILE_END_EVENT(0, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
- (void)createBatchedBridge - (void)createBatchedBridge

Просмотреть файл

@ -127,7 +127,7 @@
RCTProfileImmediateEvent(RCTProfileTagAlways, @"JS Thread Tick", displayLink.timestamp, 'g'); RCTProfileImmediateEvent(RCTProfileTagAlways, @"JS Thread Tick", displayLink.timestamp, 'g');
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call");
} }
- (void)updateJSDisplayLinkState - (void)updateJSDisplayLinkState

Просмотреть файл

@ -94,7 +94,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
} }
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"[RCTModuleData setUpInstanceAndBridge] [_moduleClass new]", @{ @"moduleClass": NSStringFromClass(_moduleClass) }); RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"[RCTModuleData setUpInstanceAndBridge] [_moduleClass new]", @{ @"moduleClass": NSStringFromClass(_moduleClass) });
_instance = [_moduleClass new]; _instance = [_moduleClass new];
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
if (!_instance) { if (!_instance) {
// Module init returned nil, probably because automatic instantatiation // Module init returned nil, probably because automatic instantatiation
// of the module is not supported, and it is supposed to be passed in to // of the module is not supported, and it is supposed to be passed in to
@ -118,7 +118,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
[self setUpMethodQueue]; [self setUpMethodQueue];
} }
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
// This is called outside of the lock in order to prevent deadlock issues // This is called outside of the lock in order to prevent deadlock issues
// because the logic in `finishSetupForInstance` can cause // because the logic in `finishSetupForInstance` can cause
@ -151,7 +151,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
"permitted. You must either @synthesize the bridge property, " "permitted. You must either @synthesize the bridge property, "
"or provide your own setter method.", self.name); "or provide your own setter method.", self.name);
} }
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
} }
@ -164,7 +164,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
[[NSNotificationCenter defaultCenter] postNotificationName:RCTDidInitializeModuleNotification [[NSNotificationCenter defaultCenter] postNotificationName:RCTDidInitializeModuleNotification
object:_bridge object:_bridge
userInfo:@{@"module": _instance}]; userInfo:@{@"module": _instance}];
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
} }
@ -194,7 +194,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
} }
} }
} }
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
} }
@ -208,7 +208,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
- (id<RCTBridgeModule>)instance - (id<RCTBridgeModule>)instance
{ {
if (!_setupComplete) { if (!_setupComplete) {
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, [NSString stringWithFormat:@"[RCTModuleData instanceForClass:%@]", _moduleClass], nil); RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"[RCTModuleData instanceForClass:%@]", _moduleClass]), nil);
if (_requiresMainQueueSetup) { if (_requiresMainQueueSetup) {
// The chances of deadlock here are low, because module init very rarely // The chances of deadlock here are low, because module init very rarely
// calls out to other threads, however we can't control when a module might // calls out to other threads, however we can't control when a module might
@ -225,11 +225,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
[self setUpInstanceAndBridge]; [self setUpInstanceAndBridge];
}, YES); }, YES);
#pragma clang diagnostic pop #pragma clang diagnostic pop
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} else { } else {
[self setUpInstanceAndBridge]; [self setUpInstanceAndBridge];
} }
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
return _instance; return _instance;
} }
@ -281,7 +281,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
- (void)gatherConstants - (void)gatherConstants
{ {
if (_hasConstantsToExport && !_constantsToExport) { if (_hasConstantsToExport && !_constantsToExport) {
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, [NSString stringWithFormat:@"[RCTModuleData gatherConstants] %@", _moduleClass], nil); RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"[RCTModuleData gatherConstants] %@", _moduleClass]), nil);
(void)[self instance]; (void)[self instance];
if (!RCTIsMainQueue()) { if (!RCTIsMainQueue()) {
RCTLogWarn(@"Required dispatch_sync to load constants for %@. This may lead to deadlocks", _moduleClass); RCTLogWarn(@"Required dispatch_sync to load constants for %@. This may lead to deadlocks", _moduleClass);
@ -292,7 +292,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
self->_constantsToExport = [self->_instance constantsToExport] ?: @{}; self->_constantsToExport = [self->_instance constantsToExport] ?: @{};
}, YES); }, YES);
#pragma clang diagnostic pop #pragma clang diagnostic pop
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
} }
@ -306,7 +306,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
return (id)kCFNull; // Nothing to export return (id)kCFNull; // Nothing to export
} }
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, [NSString stringWithFormat:@"[RCTModuleData config] %@", _moduleClass], nil); RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"[RCTModuleData config] %@", _moduleClass]), nil);
NSMutableArray<NSString *> *methods = self.methods.count ? [NSMutableArray new] : nil; NSMutableArray<NSString *> *methods = self.methods.count ? [NSMutableArray new] : nil;
NSMutableArray<NSNumber *> *promiseMethods = nil; NSMutableArray<NSNumber *> *promiseMethods = nil;
@ -335,7 +335,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init);
RCTNullIfNil(promiseMethods), RCTNullIfNil(promiseMethods),
RCTNullIfNil(syncMethods) RCTNullIfNil(syncMethods)
]; ];
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"[RCTModuleData config] %@", _moduleClass]), nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"[RCTModuleData config] %@", _moduleClass]));
return config; return config;
} }

Просмотреть файл

@ -18,6 +18,7 @@
#import "RCTLog.h" #import "RCTLog.h"
#import "RCTParserUtils.h" #import "RCTParserUtils.h"
#import "RCTUtils.h" #import "RCTUtils.h"
#import "RCTProfile.h"
typedef BOOL (^RCTArgumentBlock)(RCTBridge *, NSUInteger, id); typedef BOOL (^RCTArgumentBlock)(RCTBridge *, NSUInteger, id);
@ -399,7 +400,10 @@ SEL RCTParseMethodSignature(NSString *methodSignature, NSArray<RCTMethodArgument
- (SEL)selector - (SEL)selector
{ {
if (_selector == NULL) { if (_selector == NULL) {
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"", (@{ @"module": NSStringFromClass(_moduleClass),
@"method": _methodSignature }));
[self processMethodSignature]; [self processMethodSignature];
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
return _selector; return _selector;
} }

Просмотреть файл

@ -70,7 +70,7 @@
#if RCT_PROFILE #if RCT_PROFILE
if (RCTProfileIsProfiling()) { if (RCTProfileIsProfiling()) {
NSString *label =_labelsForTags[tag]; NSString *label =_labelsForTags[tag];
RCTProfileEndAsyncEvent(RCTProfileTagAlways, @"native", _cookies[tag], label, @"RCTPerformanceLogger", nil); RCTProfileEndAsyncEvent(RCTProfileTagAlways, @"native", _cookies[tag], label, @"RCTPerformanceLogger");
} }
#endif #endif
if (_data[tag][0] != 0 && _data[tag][1] == 0) { if (_data[tag][0] != 0 && _data[tag][1] == 0) {

Просмотреть файл

@ -99,7 +99,7 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotificat
[self showLoadingView]; [self showLoadingView];
} }
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
return self; return self;
} }

Просмотреть файл

@ -314,7 +314,7 @@ static NSThread *newJavaScriptThread(void)
_javaScriptThread = newJavaScriptThread(); _javaScriptThread = newJavaScriptThread();
} }
RCT_PROFILE_END_EVENT(0, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
return self; return self;
} }
@ -429,10 +429,10 @@ static NSThread *newJavaScriptThread(void)
return nil; return nil;
} }
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"nativeRequireModuleConfig", nil); RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"nativeRequireModuleConfig", @{ @"moduleName": moduleName });
NSArray *config = [strongSelf->_bridge configForModuleName:moduleName]; NSArray *config = [strongSelf->_bridge configForModuleName:moduleName];
NSString *result = config ? RCTJSONStringify(config, NULL) : nil; NSString *result = config ? RCTJSONStringify(config, NULL) : nil;
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,config", @{ @"moduleName": moduleName }); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,config");
return result; return result;
}; };
@ -444,7 +444,7 @@ static NSThread *newJavaScriptThread(void)
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"nativeFlushQueueImmediate", nil); RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"nativeFlushQueueImmediate", nil);
[strongSelf->_bridge handleBuffer:calls batchEnded:NO]; [strongSelf->_bridge handleBuffer:calls batchEnded:NO];
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call");
}; };
context[@"nativeCallSyncHook"] = ^id(NSUInteger module, NSUInteger method, NSArray *args) { context[@"nativeCallSyncHook"] = ^id(NSUInteger module, NSUInteger method, NSArray *args) {
@ -455,7 +455,7 @@ static NSThread *newJavaScriptThread(void)
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"nativeCallSyncHook", nil); RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"nativeCallSyncHook", nil);
id result = [strongSelf->_bridge callNativeModule:module method:method params:args]; id result = [strongSelf->_bridge callNativeModule:module method:method params:args];
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,config", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,config");
return result; return result;
}; };
@ -543,7 +543,7 @@ static void installBasicSynchronousHooksOnContext(JSContext *context)
RCT_PROFILE_BEGIN_EVENT(tag.longLongValue, profileName, args); RCT_PROFILE_BEGIN_EVENT(tag.longLongValue, profileName, args);
}; };
context[@"nativeTraceEndSection"] = ^(NSNumber *tag) { context[@"nativeTraceEndSection"] = ^(NSNumber *tag) {
RCT_PROFILE_END_EVENT(tag.longLongValue, @"console", nil); RCT_PROFILE_END_EVENT(tag.longLongValue, @"console");
}; };
RCTCookieMap *cookieMap = [RCTCookieMap new]; RCTCookieMap *cookieMap = [RCTCookieMap new];
context[@"nativeTraceBeginAsyncSection"] = ^(uint64_t tag, NSString *name, NSUInteger cookie) { context[@"nativeTraceBeginAsyncSection"] = ^(uint64_t tag, NSString *name, NSUInteger cookie) {
@ -557,7 +557,7 @@ static void installBasicSynchronousHooksOnContext(JSContext *context)
newCookie = it->second; newCookie = it->second;
cookieMap->_cookieMap.erase(it); cookieMap->_cookieMap.erase(it);
} }
RCTProfileEndAsyncEvent(tag, @"js,async", newCookie, name, @"JS async", nil); RCTProfileEndAsyncEvent(tag, @"js,async", newCookie, name, @"JS async");
}; };
#endif #endif
} }
@ -654,7 +654,7 @@ static void installBasicSynchronousHooksOnContext(JSContext *context)
return; return;
} }
RCT_PROFILE_BEGIN_EVENT(0, @"executeJSCall", @{@"method": method, @"args": arguments}); RCT_PROFILE_BEGIN_EVENT(0, @"executeJSCall", (@{@"method": method, @"args": arguments}));
RCTJSCWrapper *jscWrapper = strongSelf->_jscWrapper; RCTJSCWrapper *jscWrapper = strongSelf->_jscWrapper;
JSContext *context = strongSelf->_context.context; JSContext *context = strongSelf->_context.context;
@ -711,7 +711,7 @@ static void installBasicSynchronousHooksOnContext(JSContext *context)
} }
} }
RCT_PROFILE_END_EVENT(0, @"js_call", nil); RCT_PROFILE_END_EVENT(0, @"js_call");
onComplete(objcValue, error); onComplete(objcValue, error);
}]; }];
@ -785,7 +785,7 @@ static NSData *loadPossiblyBundledApplicationScript(NSData *script, NSURL *sourc
script = nullTerminatedScript; script = nullTerminatedScript;
} }
RCT_PROFILE_END_EVENT(0, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
return script; return script;
} }
@ -798,8 +798,9 @@ static void registerNativeRequire(JSContext *context, RCTJSCExecutor *executor)
static NSError *executeApplicationScript(NSData *script, NSURL *sourceURL, RCTJSCWrapper *jscWrapper, static NSError *executeApplicationScript(NSData *script, NSURL *sourceURL, RCTJSCWrapper *jscWrapper,
RCTPerformanceLogger *performanceLogger, JSGlobalContextRef ctx) RCTPerformanceLogger *performanceLogger, JSGlobalContextRef ctx)
{ {
RCT_PROFILE_BEGIN_EVENT(0, @"executeApplicationScript / execute script", RCT_PROFILE_BEGIN_EVENT(0, @"executeApplicationScript / execute script", (@{
@{ @"url": sourceURL.absoluteString, @"size": @(script.length) }); @"url": sourceURL.absoluteString, @"size": @(script.length)
}));
[performanceLogger markStartForTag:RCTPLScriptExecution]; [performanceLogger markStartForTag:RCTPLScriptExecution];
JSValueRef jsError = NULL; JSValueRef jsError = NULL;
JSStringRef execJSString = jscWrapper->JSStringCreateWithUTF8CString((const char *)script.bytes); JSStringRef execJSString = jscWrapper->JSStringCreateWithUTF8CString((const char *)script.bytes);
@ -809,7 +810,7 @@ static NSError *executeApplicationScript(NSData *script, NSURL *sourceURL, RCTJS
jscWrapper->JSStringRelease(execJSString); jscWrapper->JSStringRelease(execJSString);
[performanceLogger markStopForTag:RCTPLScriptExecution]; [performanceLogger markStopForTag:RCTPLScriptExecution];
NSError *error = result ? nil : RCTNSErrorFromJSError(jscWrapper, ctx, jsError); NSError *error = result ? nil : RCTNSErrorFromJSError(jscWrapper, ctx, jsError);
RCT_PROFILE_END_EVENT(0, @"js_call", nil); RCT_PROFILE_END_EVENT(0, @"js_call");
return error; return error;
} }
@ -872,7 +873,7 @@ static NSError *executeApplicationScript(NSData *script, NSURL *sourceURL, RCTJS
error = RCTNSErrorFromJSError(jscWrapper, ctx, jsError); error = RCTNSErrorFromJSError(jscWrapper, ctx, jsError);
} }
} }
RCT_PROFILE_END_EVENT(0, @"js_call,json_call", nil); RCT_PROFILE_END_EVENT(0, @"js_call,json_call");
if (onComplete) { if (onComplete) {
onComplete(error); onComplete(error);
@ -923,8 +924,7 @@ static void executeRandomAccessModule(RCTJSCExecutor *executor, uint32_t moduleI
[_performanceLogger addValue:1 forTag:RCTPLRAMNativeRequiresCount]; [_performanceLogger addValue:1 forTag:RCTPLRAMNativeRequiresCount];
[_performanceLogger appendStartForTag:RCTPLRAMNativeRequires]; [_performanceLogger appendStartForTag:RCTPLRAMNativeRequires];
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, ([@"nativeRequire_" stringByAppendingFormat:@"%@", moduleID]), nil);
[@"nativeRequire_" stringByAppendingFormat:@"%@", moduleID], nil);
const uint32_t ID = [moduleID unsignedIntValue]; const uint32_t ID = [moduleID unsignedIntValue];
@ -941,7 +941,7 @@ static void executeRandomAccessModule(RCTJSCExecutor *executor, uint32_t moduleI
executeRandomAccessModule(self, ID, NSSwapLittleIntToHost(moduleData->offset), size); executeRandomAccessModule(self, ID, NSSwapLittleIntToHost(moduleData->offset), size);
} }
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call");
[_performanceLogger appendStopForTag:RCTPLRAMNativeRequires]; [_performanceLogger appendStopForTag:RCTPLRAMNativeRequires];
} }

Просмотреть файл

@ -278,7 +278,7 @@ RCT_EXPORT_MODULE()
self->_bridge = nil; self->_bridge = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
}); });
} }
@ -1150,7 +1150,9 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag
RCTProfileBeginFlowEvent(); RCTProfileBeginFlowEvent();
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
RCTProfileEndFlowEvent(); RCTProfileEndFlowEvent();
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[UIManager flushUIBlocks]", nil); RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[UIManager flushUIBlocks]", (@{
@"count": @(previousPendingUIBlocks.count),
}));
@try { @try {
for (RCTViewManagerUIBlock block in previousPendingUIBlocks) { for (RCTViewManagerUIBlock block in previousPendingUIBlocks) {
block(self, self->_viewRegistry); block(self, self->_viewRegistry);
@ -1159,9 +1161,6 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag
@catch (NSException *exception) { @catch (NSException *exception) {
RCTLogError(@"Exception thrown while executing UI block: %@", exception); RCTLogError(@"Exception thrown while executing UI block: %@", exception);
} }
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call", @{
@"count": @(previousPendingUIBlocks.count),
});
}); });
} }
} }

Просмотреть файл

@ -69,12 +69,12 @@ RCT_EXTERN void _RCTProfileBeginEvent(NSThread *calleeThread,
uint64_t tag, uint64_t tag,
NSString *name, NSString *name,
NSDictionary *args); NSDictionary *args);
#define RCT_PROFILE_BEGIN_EVENT(...) \ #define RCT_PROFILE_BEGIN_EVENT(tag, name, args) \
do { \ do { \
if (RCTProfileIsProfiling()) { \ if (RCTProfileIsProfiling()) { \
NSThread *__calleeThread = [NSThread currentThread]; \ NSThread *__calleeThread = [NSThread currentThread]; \
NSTimeInterval __time = CACurrentMediaTime(); \ NSTimeInterval __time = CACurrentMediaTime(); \
_RCTProfileBeginEvent(__calleeThread, __time, __VA_ARGS__); \ _RCTProfileBeginEvent(__calleeThread, __time, tag, name, args); \
} \ } \
} while(0) } while(0)
@ -87,16 +87,15 @@ RCT_EXTERN void _RCTProfileEndEvent(NSThread *calleeThread,
NSString *threadName, NSString *threadName,
NSTimeInterval time, NSTimeInterval time,
uint64_t tag, uint64_t tag,
NSString *category, NSString *category);
NSDictionary *args);
#define RCT_PROFILE_END_EVENT(...) \ #define RCT_PROFILE_END_EVENT(tag, category) \
do { \ do { \
if (RCTProfileIsProfiling()) { \ if (RCTProfileIsProfiling()) { \
NSThread *__calleeThread = [NSThread currentThread]; \ NSThread *__calleeThread = [NSThread currentThread]; \
NSString *__threadName = RCTCurrentThreadName(); \ NSString *__threadName = RCTCurrentThreadName(); \
NSTimeInterval __time = CACurrentMediaTime(); \ NSTimeInterval __time = CACurrentMediaTime(); \
_RCTProfileEndEvent(__calleeThread, __threadName, __time, __VA_ARGS__); \ _RCTProfileEndEvent(__calleeThread, __threadName, __time, tag, category); \
} \ } \
} while(0) } while(0)
@ -116,8 +115,7 @@ RCT_EXTERN void RCTProfileEndAsyncEvent(uint64_t tag,
NSString *category, NSString *category,
NSUInteger cookie, NSUInteger cookie,
NSString *name, NSString *name,
NSString *threadName, NSString *threadName);
NSDictionary *args);
/** /**
* An event that doesn't have a duration (i.e. Notification, VSync, etc) * An event that doesn't have a duration (i.e. Notification, VSync, etc)

Просмотреть файл

@ -136,22 +136,6 @@ static NSDictionary *RCTProfileGetMemoryUsage(void)
} }
} }
static NSDictionary *RCTProfileMergeArgs(NSDictionary *args0, NSDictionary *args1)
{
args0 = RCTNilIfNull(args0);
args1 = RCTNilIfNull(args1);
if (!args0 && args1) {
args0 = args1;
} else if (args0 && args1) {
NSMutableDictionary *d = [args0 mutableCopy];
[d addEntriesFromDictionary:args1];
args0 = [d copy];
}
return RCTNullIfNil(args0);
}
#pragma mark - Module hooks #pragma mark - Module hooks
static const char *RCTProfileProxyClassName(Class class) static const char *RCTProfileProxyClassName(Class class)
@ -207,13 +191,13 @@ void RCTProfileTrampolineStart(id self, SEL cmd)
* block. * block.
*/ */
Class klass = [self class]; Class klass = [self class];
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, [NSString stringWithFormat:@"-[%s %s]", class_getName(klass), sel_getName(cmd)], nil); RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"-[%s %s]", class_getName(klass), sel_getName(cmd)]), nil);
} }
RCT_EXTERN void RCTProfileTrampolineEnd(void); RCT_EXTERN void RCTProfileTrampolineEnd(void);
void RCTProfileTrampolineEnd(void) void RCTProfileTrampolineEnd(void)
{ {
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call,modules,auto", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call,modules,auto");
} }
static UIView *(*originalCreateView)(RCTComponentData *, SEL, NSNumber *); static UIView *(*originalCreateView)(RCTComponentData *, SEL, NSNumber *);
@ -331,7 +315,7 @@ void RCTProfileHookModules(RCTBridge *bridge)
} queue:moduleData.methodQueue]; } queue:moduleData.methodQueue];
} }
} }
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil); RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
} }
static void RCTProfileUnhookInstance(id instance) static void RCTProfileUnhookInstance(id instance)
@ -569,13 +553,12 @@ void _RCTProfileEndEvent(
NSString *threadName, NSString *threadName,
NSTimeInterval time, NSTimeInterval time,
uint64_t tag, uint64_t tag,
NSString *category, NSString *category
NSDictionary *args
) { ) {
CHECK(); CHECK();
if (callbacks != NULL) { if (callbacks != NULL) {
callbacks->end_section(tag, args.count, RCTProfileSystraceArgsFromNSDictionary(args)); callbacks->end_section(tag, 0, nil);
return; return;
} }
@ -589,7 +572,6 @@ void _RCTProfileEndEvent(
} }
NSNumber *start = event[0]; NSNumber *start = event[0];
RCTProfileAddEvent(RCTProfileTraceEvents, RCTProfileAddEvent(RCTProfileTraceEvents,
@"tid": threadName, @"tid": threadName,
@"name": event[1], @"name": event[1],
@ -597,7 +579,7 @@ void _RCTProfileEndEvent(
@"ph": @"X", @"ph": @"X",
@"ts": start, @"ts": start,
@"dur": @(RCTProfileTimestamp(time).doubleValue - start.doubleValue), @"dur": @(RCTProfileTimestamp(time).doubleValue - start.doubleValue),
@"args": RCTProfileMergeArgs(event[2], args), @"args": event[2],
); );
}); });
} }
@ -634,13 +616,12 @@ void RCTProfileEndAsyncEvent(
NSString *category, NSString *category,
NSUInteger cookie, NSUInteger cookie,
NSString *name, NSString *name,
NSString *threadName, NSString *threadName
NSDictionary *args
) { ) {
CHECK(); CHECK();
if (callbacks != NULL) { if (callbacks != NULL) {
callbacks->end_async_section(tag, name.UTF8String, (int)(cookie % INT_MAX), args.count, RCTProfileSystraceArgsFromNSDictionary(args)); callbacks->end_async_section(tag, name.UTF8String, (int)(cookie % INT_MAX), 0, nil);
return; return;
} }
@ -659,7 +640,7 @@ void RCTProfileEndAsyncEvent(
@"ph": @"X", @"ph": @"X",
@"ts": event[0], @"ts": event[0],
@"dur": @(endTimestamp.doubleValue - [event[0] doubleValue]), @"dur": @(endTimestamp.doubleValue - [event[0] doubleValue]),
@"args": RCTProfileMergeArgs(event[2], args), @"args": event[2],
); );
[RCTProfileOngoingEvents removeObjectForKey:@(cookie)]; [RCTProfileOngoingEvents removeObjectForKey:@(cookie)];
} }