in non-lazy mode, log instantiation time for each native module

Reviewed By: alexeylang

Differential Revision: D4640157

fbshipit-source-id: cfc1c3114ef97b8ba12839c3814a72b8ece869d6
This commit is contained in:
Aaron Chiu 2017-03-02 15:41:26 -08:00 committed by Facebook Github Bot
parent 13b4c2d77b
commit f9a3ed3793
1 changed files with 9 additions and 1 deletions

View File

@ -16,6 +16,8 @@ import java.util.List;
import com.facebook.react.bridge.ModuleSpec;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants;
import com.facebook.react.module.model.ReactModuleInfoProvider;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.systrace.Systrace;
@ -69,14 +71,20 @@ public abstract class LazyReactPackage implements ReactPackage {
public final List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
for (ModuleSpec holder : getNativeModules(reactContext)) {
NativeModule nativeModule;
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createNativeModule")
.arg("module", holder.getType())
.flush();
try {
modules.add(holder.getProvider().get());
ReactMarker.logMarker(
ReactMarkerConstants.CREATE_MODULE_START,
holder.getType().getSimpleName());
nativeModule = holder.getProvider().get();
ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END);
} finally {
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
modules.add(nativeModule);
}
return modules;
}