Skip to content

Commit

Permalink
add marker surrounding entire native module creation
Browse files Browse the repository at this point in the history
Reviewed By: javache

Differential Revision: D5200856

fbshipit-source-id: 35b0e627224d518126a1cfdd36d6af264dd186cf
  • Loading branch information
bnham authored and facebook-github-bot committed Jun 9, 2017
1 parent 80bc07f commit 2984628
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions React/CxxBridge/RCTCxxBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ static void registerPerformanceLoggerHooks(RCTPerformanceLogger *performanceLogg
case ReactMarker::CREATE_REACT_CONTEXT_STOP:
case ReactMarker::JS_BUNDLE_STRING_CONVERT_START:
case ReactMarker::JS_BUNDLE_STRING_CONVERT_STOP:
case ReactMarker::NATIVE_MODULE_SETUP_START:
case ReactMarker::NATIVE_MODULE_SETUP_STOP:
// These are not used on iOS.
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public enum ReactMarkerConstants {
CREATE_VIEW_MANAGERS_END,
CREATE_UI_MANAGER_MODULE_CONSTANTS_START,
CREATE_UI_MANAGER_MODULE_CONSTANTS_END,
NATIVE_MODULE_SETUP_START,
NATIVE_MODULE_SETUP_END,
CREATE_MODULE_START,
CREATE_MODULE_END,
PROCESS_CORE_REACT_PACKAGE_START,
Expand Down
6 changes: 6 additions & 0 deletions ReactAndroid/src/main/jni/react/jni/OnLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ static void logPerfMarker(const ReactMarker::ReactMarkerId markerId, const char*
case ReactMarker::JS_BUNDLE_STRING_CONVERT_STOP:
JReactMarker::logMarker("loadApplicationScript_endStringConvert");
break;
case ReactMarker::NATIVE_MODULE_SETUP_START:
JReactMarker::logMarker("NATIVE_MODULE_SETUP_START", tag);
break;
case ReactMarker::NATIVE_MODULE_SETUP_STOP:
JReactMarker::logMarker("NATIVE_MODULE_SETUP_END", tag);
break;
case ReactMarker::NATIVE_REQUIRE_START:
case ReactMarker::NATIVE_REQUIRE_STOP:
// These are not used on Android.
Expand Down
10 changes: 9 additions & 1 deletion ReactCommon/cxxreact/JSCNativeModules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include <string>

#include "Platform.h"

namespace facebook {
namespace react {

Expand Down Expand Up @@ -41,6 +43,8 @@ void JSCNativeModules::reset() {
}

folly::Optional<Object> JSCNativeModules::createModule(const std::string& name, JSContextRef context) {
ReactMarker::logTaggedMarker(ReactMarker::NATIVE_MODULE_SETUP_START, name.c_str());

if (!m_genNativeModuleJS) {
auto global = Object::getGlobalObject(context);
m_genNativeModuleJS = global.getProperty("__fbGenNativeModule").asObject();
Expand All @@ -58,7 +62,11 @@ folly::Optional<Object> JSCNativeModules::createModule(const std::string& name,
});
CHECK(!moduleInfo.isNull()) << "Module returned from genNativeModule is null";

return moduleInfo.asObject().getProperty("module").asObject();
folly::Optional<Object> module(moduleInfo.asObject().getProperty("module").asObject());

ReactMarker::logTaggedMarker(ReactMarker::NATIVE_MODULE_SETUP_STOP, name.c_str());

return module;
}

} }
2 changes: 2 additions & 0 deletions ReactCommon/cxxreact/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ enum ReactMarkerId {
CREATE_REACT_CONTEXT_STOP,
JS_BUNDLE_STRING_CONVERT_START,
JS_BUNDLE_STRING_CONVERT_STOP,
NATIVE_MODULE_SETUP_START,
NATIVE_MODULE_SETUP_STOP,
};

using LogTaggedMarker = std::function<void(const ReactMarkerId, const char* tag)>;
Expand Down

0 comments on commit 2984628

Please sign in to comment.