Cleanup markers in getConstants

Summary:
* Only add the moduleName to the outer marker
* Include module init in the marker time
* Include the WritableNativeArray time in CONVERT_CONSTANTS
* Stop all markers from finally block in case of exception

Reviewed By: kathryngray

Differential Revision: D5031411

fbshipit-source-id: bf86ee3d59f2cb38866afd52e84af5699db1a003
This commit is contained in:
Pieter De Baets 2017-05-26 09:23:50 -07:00 committed by Facebook Github Bot
parent 2de2133014
commit e9fc7311c4
2 changed files with 22 additions and 24 deletions

View File

@ -129,29 +129,32 @@ public class JavaModuleWrapper {
if (!mModuleHolder.getHasConstants()) { if (!mModuleHolder.getHasConstants()) {
return null; return null;
} }
BaseJavaModule baseJavaModule = getModule();
ReactMarker.logMarker(GET_CONSTANTS_START, getName()); final String moduleName = getName();
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "Map constants") SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "JavaModuleWrapper.getConstants")
.arg("moduleName", getName()) .arg("moduleName", moduleName)
.flush(); .flush();
ReactMarker.logMarker(GET_CONSTANTS_START, moduleName);
BaseJavaModule baseJavaModule = getModule();
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "module.getConstants");
Map<String, Object> map = baseJavaModule.getConstants(); Map<String, Object> map = baseJavaModule.getConstants();
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "WritableNativeMap constants") Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "create WritableNativeMap");
.arg("moduleName", getName()) ReactMarker.logMarker(CONVERT_CONSTANTS_START, moduleName);
.flush();
ReactMarker.logMarker(CONVERT_CONSTANTS_START, getName());
WritableNativeMap writableNativeMap;
try { try {
writableNativeMap = Arguments.makeNativeMap(map); WritableNativeArray array = new WritableNativeArray();
array.pushMap(Arguments.makeNativeMap(map));
return array;
} finally { } finally {
ReactMarker.logMarker(CONVERT_CONSTANTS_END);
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
ReactMarker.logMarker(GET_CONSTANTS_END);
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
} }
WritableNativeArray array = new WritableNativeArray();
array.pushMap(writableNativeMap);
ReactMarker.logMarker(CONVERT_CONSTANTS_END);
ReactMarker.logMarker(GET_CONSTANTS_END);
return array;
} }
@DoNotStrip @DoNotStrip

View File

@ -99,7 +99,7 @@ public class ModuleHolder {
SoftAssertions.assertCondition(mModule == null, "Creating an already created module."); SoftAssertions.assertCondition(mModule == null, "Creating an already created module.");
int instanceKey = sInstanceKeyCounter.getAndIncrement(); int instanceKey = sInstanceKeyCounter.getAndIncrement();
ReactMarker.logMarker(CREATE_MODULE_START, mName, instanceKey); ReactMarker.logMarker(CREATE_MODULE_START, mName, instanceKey);
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createModule") SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ModuleHolder.createModule")
.arg("name", mName) .arg("name", mName)
.flush(); .flush();
NativeModule module; NativeModule module;
@ -118,14 +118,9 @@ public class ModuleHolder {
} }
private void doInitialize(NativeModule module) { private void doInitialize(NativeModule module) {
SystraceMessage.Builder section = SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ModuleHolder.initialize")
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "initialize"); .arg("name", mName)
if (module instanceof CxxModuleWrapper) { .flush();
section.arg("className", module.getClass().getSimpleName());
} else {
section.arg("name", mName);
}
section.flush();
ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_START, mName); ReactMarker.logMarker(ReactMarkerConstants.INITIALIZE_MODULE_START, mName);
try { try {
module.initialize(); module.initialize();