mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Instrument events emitted by TurboModuleManager
Summary: TurboModuleManager can emit the following events: - JS Require Beginning - JS Require Ending - Module Create (for C++-only TurboModules) This diff instruments JS Require beginning, and JS Require ending. It also serves as a good stopgap to verify that TurboModule perf logging is set up correctly. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D22485529 fbshipit-source-id: a41b88b56627ad2bbcaadac87bf9d530bf07ae81
This commit is contained in:
committed by
Facebook GitHub Bot
parent
41d948c8d6
commit
ec18e35cd3
+15
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <ReactCommon/TurboCxxModule.h>
|
||||
#include <ReactCommon/TurboModuleBinding.h>
|
||||
#include <ReactCommon/TurboModulePerfLogger.h>
|
||||
#include <react/jni/JMessageQueueThread.h>
|
||||
|
||||
#include "TurboModuleManager.h"
|
||||
@@ -81,11 +82,19 @@ void TurboModuleManager::installJSIBindings() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *moduleName = name.c_str();
|
||||
|
||||
TurboModulePerfLogger::moduleJSRequireBeginningStart(moduleName);
|
||||
|
||||
auto turboModuleLookup = turboModuleCache->find(name);
|
||||
if (turboModuleLookup != turboModuleCache->end()) {
|
||||
TurboModulePerfLogger::moduleJSRequireBeginningCacheHit(moduleName);
|
||||
TurboModulePerfLogger::moduleJSRequireBeginningEnd(moduleName);
|
||||
return turboModuleLookup->second;
|
||||
}
|
||||
|
||||
TurboModulePerfLogger::moduleJSRequireBeginningEnd(moduleName);
|
||||
|
||||
auto cxxModule = delegate->cthis()->getTurboModule(name, jsCallInvoker);
|
||||
if (cxxModule) {
|
||||
turboModuleCache->insert({name, cxxModule});
|
||||
@@ -99,9 +108,13 @@ void TurboModuleManager::installJSIBindings() {
|
||||
auto legacyCxxModule = getLegacyCxxModule(javaPart.get(), name);
|
||||
|
||||
if (legacyCxxModule) {
|
||||
TurboModulePerfLogger::moduleJSRequireEndingStart(moduleName);
|
||||
|
||||
auto turboModule = std::make_shared<react::TurboCxxModule>(
|
||||
legacyCxxModule->cthis()->getModule(), jsCallInvoker);
|
||||
turboModuleCache->insert({name, turboModule});
|
||||
|
||||
TurboModulePerfLogger::moduleJSRequireEndingEnd(moduleName);
|
||||
return turboModule;
|
||||
}
|
||||
|
||||
@@ -112,6 +125,7 @@ void TurboModuleManager::installJSIBindings() {
|
||||
auto moduleInstance = getJavaModule(javaPart.get(), name);
|
||||
|
||||
if (moduleInstance) {
|
||||
TurboModulePerfLogger::moduleJSRequireEndingStart(moduleName);
|
||||
JavaTurboModule::InitParams params = {.moduleName = name,
|
||||
.instance = moduleInstance,
|
||||
.jsInvoker = jsCallInvoker,
|
||||
@@ -119,6 +133,7 @@ void TurboModuleManager::installJSIBindings() {
|
||||
|
||||
auto turboModule = delegate->cthis()->getTurboModule(name, params);
|
||||
turboModuleCache->insert({name, turboModule});
|
||||
TurboModulePerfLogger::moduleJSRequireEndingEnd(moduleName);
|
||||
return turboModule;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user