Track native modules which use the main thread for initialization or gathering constants

Reviewed By: majak

Differential Revision: D3054146

fb-gh-sync-id: fd4f4c0dff3144d22357ea798d3131aee578d509
shipit-source-id: fd4f4c0dff3144d22357ea798d3131aee578d509
This commit is contained in:
Alexey Lang 2016-03-16 09:46:55 -07:00 committed by Facebook Github Bot 9
parent c1762c7bdb
commit 26d9417f2b
3 changed files with 7 additions and 0 deletions

View File

@ -364,6 +364,7 @@ RCT_EXTERN NSArray<Class> *RCTGetModuleClasses(void);
// Set up modules that require main thread init or constants export
RCTPerformanceLoggerSet(RCTPLNativeModuleMainThread, 0);
NSUInteger modulesOnMainThreadCount = 0;
for (RCTModuleData *moduleData in _moduleDataByID) {
__weak RCTBatchedBridge *weakSelf = self;
if (moduleData.requiresMainThreadSetup) {
@ -380,6 +381,7 @@ RCT_EXTERN NSArray<Class> *RCTGetModuleClasses(void);
RCTPerformanceLoggerAppendEnd(RCTPLNativeModuleMainThread);
}
});
modulesOnMainThreadCount++;
} else if (moduleData.hasConstantsToExport) {
// Constants must be exported on the main thread, but module setup can
// be done on any queue
@ -391,10 +393,12 @@ RCT_EXTERN NSArray<Class> *RCTGetModuleClasses(void);
RCTPerformanceLoggerAppendEnd(RCTPLNativeModuleMainThread);
}
});
modulesOnMainThreadCount++;
}
}
RCTPerformanceLoggerEnd(RCTPLNativeModuleInit);
RCTPerformanceLoggerSet(RCTPLNativeModuleMainThreadUsesCount, modulesOnMainThreadCount);
}
- (void)setUpExecutor

View File

@ -18,6 +18,7 @@ typedef NS_ENUM(NSUInteger, RCTPLTag) {
RCTPLNativeModuleMainThread,
RCTPLNativeModulePrepareConfig,
RCTPLNativeModuleInjectConfig,
RCTPLNativeModuleMainThreadUsesCount,
RCTPLJSCExecutorSetup,
RCTPLTTI,
RCTPLBundleSize,

View File

@ -78,6 +78,8 @@ NSArray<NSNumber *> *RCTPerformanceLoggerOutput(void)
@(RCTPLData[RCTPLNativeModulePrepareConfig][1]),
@(RCTPLData[RCTPLNativeModuleInjectConfig][0]),
@(RCTPLData[RCTPLNativeModuleInjectConfig][1]),
@(RCTPLData[RCTPLNativeModuleMainThreadUsesCount][0]),
@(RCTPLData[RCTPLNativeModuleMainThreadUsesCount][1]),
@(RCTPLData[RCTPLJSCExecutorSetup][0]),
@(RCTPLData[RCTPLJSCExecutorSetup][1]),
@(RCTPLData[RCTPLTTI][0]),