Permalink
Browse files

Add more profiling, fix existing profiling, perf fix

Reviewed By: javache

Differential Revision: D3807467

fbshipit-source-id: 3ff6feebd6d7966952152bac708389506de721e6
  • Loading branch information...
1 parent d7fdc44 commit 3940f06211faf4fc34270d5cf2c5d57d43ed762e @mhorowitz mhorowitz committed with Facebook Github Bot 4 Sep 2, 2016
Showing with 11 additions and 4 deletions.
  1. +3 −3 React/Base/RCTModuleData.mm
  2. +6 −1 ReactCommon/cxxreact/JSCExecutor.cpp
  3. +2 −0 ReactCommon/cxxreact/JSCHelpers.cpp
@@ -83,7 +83,7 @@ - (instancetype)initWithModuleInstance:(id<RCTBridgeModule>)instance
- (void)setUpInstanceAndBridge
{
- RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"[RCTModuleData setUpInstanceAndBridge] [_instanceLock lock]", @{ @"moduleClass": _moduleClass });
+ RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"[RCTModuleData setUpInstanceAndBridge] [_instanceLock lock]", @{ @"moduleClass": NSStringFromClass(_moduleClass) });
{
std::unique_lock<std::mutex> lock(_instanceLock);
@@ -92,7 +92,7 @@ - (void)setUpInstanceAndBridge
if (RCT_DEBUG && _requiresMainQueueSetup) {
RCTAssertMainQueue();
}
- RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"[RCTModuleData setUpInstanceAndBridge] [_moduleClass new]", @{ @"moduleClass": _moduleClass });
+ RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"[RCTModuleData setUpInstanceAndBridge] [_moduleClass new]", @{ @"moduleClass": NSStringFromClass(_moduleClass) });
_instance = [_moduleClass new];
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil);
if (!_instance) {
@@ -293,8 +293,8 @@ - (void)gatherConstants
self->_constantsToExport = [self->_instance constantsToExport] ?: @{};
}, YES);
#pragma clang diagnostic pop
+ RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil);
}
- RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil);
}
- (NSArray *)config
@@ -332,6 +332,7 @@ void JSCExecutor::setJSModulesUnbundle(std::unique_ptr<JSModulesUnbundle> unbund
}
void JSCExecutor::bindBridge() throw(JSException) {
+ SystraceSection s("JSCExecutor::bindBridge");
auto global = Object::getGlobalObject(m_context);
auto batchedBridgeValue = global.getProperty("__fbBatchedBridge");
if (batchedBridgeValue.isUndefined()) {
@@ -345,11 +346,12 @@ void JSCExecutor::bindBridge() throw(JSException) {
}
void JSCExecutor::callNativeModules(Value&& value) {
+ SystraceSection s("JSCExecutor::callNativeModules");
try {
auto calls = value.toJSONString();
m_delegate->callNativeModules(*this, std::move(calls), true);
} catch (...) {
- std::string message = "Error in flush()";
+ std::string message = "Error in callNativeModules()";
try {
message += ":" + value.toString().str();
} catch (...) {
@@ -360,10 +362,12 @@ void JSCExecutor::callNativeModules(Value&& value) {
}
void JSCExecutor::flush() {
+ SystraceSection s("JSCExecutor::flush");
callNativeModules(m_flushedQueueJS->callAsFunction({}));
}
void JSCExecutor::callFunction(const std::string& moduleId, const std::string& methodId, const folly::dynamic& arguments) {
+ SystraceSection s("JSCExecutor::callFunction");
// This weird pattern is because Value is not default constructible.
// The lambda is inlined, so there's no overhead.
@@ -384,6 +388,7 @@ void JSCExecutor::callFunction(const std::string& moduleId, const std::string& m
}
void JSCExecutor::invokeCallback(const double callbackId, const folly::dynamic& arguments) {
+ SystraceSection s("JSCExecutor::invokeCallback");
auto result = [&] {
try {
return m_invokeCallbackAndReturnFlushedQueueJS->callAsFunction({
@@ -6,6 +6,7 @@
#include <folly/String.h>
#include <glog/logging.h>
+#include "SystraceSection.h"
#include "Value.h"
namespace facebook {
@@ -41,6 +42,7 @@ String jsStringFromBigString(const JSBigString& bigstr) {
}
JSValueRef evaluateScript(JSContextRef context, JSStringRef script, JSStringRef source) {
+ SystraceSection s("evaluateScript");
JSValueRef exn, result;
result = JSEvaluateScript(context, script, NULL, source, 0, &exn);
if (result == nullptr) {

0 comments on commit 3940f06

Please sign in to comment.