mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-29 07:48:17 +08:00
Refactor measuring native requires
Reviewed By: javache Differential Revision: D3829204 fbshipit-source-id: 9a3a29bfc12e3af60eeac1e03b93a626d0d256c8
This commit is contained in:
committed by
Facebook Github Bot 7
parent
66abc86c9a
commit
d6fe78fc25
@@ -433,7 +433,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)dele
|
||||
}
|
||||
|
||||
// Set up modules that require main thread init or constants export
|
||||
[_performanceLogger setValue:0 forTag:RCTPLNativeModuleMainThread];
|
||||
for (RCTModuleData *moduleData in _moduleDataByID) {
|
||||
if (whitelistedModules && ![whitelistedModules containsObject:[moduleData moduleClass]]) {
|
||||
continue;
|
||||
@@ -541,6 +540,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)dele
|
||||
NSRunLoop *targetRunLoop = [self->_javaScriptExecutor isKindOfClass:[RCTJSCExecutor class]] ? [NSRunLoop currentRunLoop] : [NSRunLoop mainRunLoop];
|
||||
[self->_displayLink addToRunLoop:targetRunLoop];
|
||||
|
||||
// Log metrics about native requires during the bridge startup.
|
||||
uint64_t nativeRequiresCount = [self->_performanceLogger valueForTag:RCTPLRAMNativeRequiresCount];
|
||||
[self->_performanceLogger setValue:nativeRequiresCount forTag:RCTPLRAMStartupNativeRequiresCount];
|
||||
uint64_t nativeRequires = [self->_performanceLogger valueForTag:RCTPLRAMNativeRequires];
|
||||
[self->_performanceLogger setValue:nativeRequires forTag:RCTPLRAMStartupNativeRequires];
|
||||
|
||||
[self->_performanceLogger markStopForTag:RCTPLBridgeStartup];
|
||||
|
||||
// Perform the notification on the main thread, so we can't run into
|
||||
|
||||
@@ -14,9 +14,10 @@ typedef NS_ENUM(NSUInteger, RCTPLTag) {
|
||||
RCTPLScriptExecution,
|
||||
RCTPLRAMBundleLoad,
|
||||
RCTPLRAMStartupCodeSize,
|
||||
RCTPLRAMStartupNativeRequires,
|
||||
RCTPLRAMStartupNativeRequiresCount,
|
||||
RCTPLRAMNativeRequires,
|
||||
RCTPLRAMNativeRequiresCount,
|
||||
RCTPLRAMNativeRequiresSize,
|
||||
RCTPLNativeModuleInit,
|
||||
RCTPLNativeModuleMainThread,
|
||||
RCTPLNativeModulePrepareConfig,
|
||||
|
||||
@@ -34,9 +34,10 @@
|
||||
@"ScriptExecution",
|
||||
@"RAMBundleLoad",
|
||||
@"RAMStartupCodeSize",
|
||||
@"RAMStartupNativeRequires",
|
||||
@"RAMStartupNativeRequiresCount",
|
||||
@"RAMNativeRequires",
|
||||
@"RAMNativeRequiresCount",
|
||||
@"RAMNativeRequiresSize",
|
||||
@"NativeModuleInit",
|
||||
@"NativeModuleMainThread",
|
||||
@"NativeModulePrepareConfig",
|
||||
|
||||
@@ -770,11 +770,6 @@ static NSData *loadPossiblyBundledApplicationScript(NSData *script, NSURL *sourc
|
||||
script = loadRAMBundle(sourceURL, error, randomAccessBundle);
|
||||
[performanceLogger markStopForTag:RCTPLRAMBundleLoad];
|
||||
[performanceLogger setValue:script.length forTag:RCTPLRAMStartupCodeSize];
|
||||
|
||||
// Reset the counters that the native require implementation uses
|
||||
[performanceLogger setValue:0 forTag:RCTPLRAMNativeRequires];
|
||||
[performanceLogger setValue:0 forTag:RCTPLRAMNativeRequiresCount];
|
||||
[performanceLogger setValue:0 forTag:RCTPLRAMNativeRequiresSize];
|
||||
} else {
|
||||
// JSStringCreateWithUTF8CString expects a null terminated C string.
|
||||
// RAM Bundling already provides a null terminated one.
|
||||
@@ -936,7 +931,6 @@ static void executeRandomAccessModule(RCTJSCExecutor *executor, uint32_t moduleI
|
||||
return;
|
||||
}
|
||||
|
||||
[_performanceLogger addValue:size forTag:RCTPLRAMNativeRequiresSize];
|
||||
executeRandomAccessModule(self, ID, NSSwapLittleIntToHost(moduleData->offset), size);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user