Prevent Systrace from including React in the preloaded modules section
Reviewed By: tadeuzagallo Differential Revision: D3304923 fbshipit-source-id: 25dea5b57002578ccb3e38e8946c6b73db008ed0
This commit is contained in:
parent
8f9a3aa0e2
commit
4880309e72
|
@ -23,55 +23,44 @@ type RelayProfiler = {
|
|||
): void,
|
||||
};
|
||||
|
||||
var TRACE_TAG_REACT_APPS = 1 << 17;
|
||||
var TRACE_TAG_JSC_CALLS = 1 << 27;
|
||||
/* eslint no-bitwise: 0 */
|
||||
const TRACE_TAG_REACT_APPS = 1 << 17;
|
||||
const TRACE_TAG_JSC_CALLS = 1 << 27;
|
||||
|
||||
var _enabled = false;
|
||||
var _asyncCookie = 0;
|
||||
var _ReactDebugTool = null;
|
||||
var _ReactComponentTreeDevtool = null;
|
||||
function ReactDebugTool() {
|
||||
if (!_ReactDebugTool) {
|
||||
_ReactDebugTool = require('ReactDebugTool');
|
||||
}
|
||||
return _ReactDebugTool;
|
||||
}
|
||||
function ReactComponentTreeDevtool() {
|
||||
if (!_ReactComponentTreeDevtool) {
|
||||
_ReactComponentTreeDevtool = require('ReactComponentTreeDevtool');
|
||||
}
|
||||
return _ReactComponentTreeDevtool;
|
||||
}
|
||||
let _enabled = false;
|
||||
let _asyncCookie = 0;
|
||||
|
||||
var ReactSystraceDevtool = {
|
||||
const ReactSystraceDevtool = __DEV__ ? {
|
||||
onBeginReconcilerTimer(debugID, timerType) {
|
||||
var displayName = ReactComponentTreeDevtool().getDisplayName(debugID);
|
||||
const displayName = require('ReactComponentTreeDevtool').getDisplayName(debugID);
|
||||
Systrace.beginEvent(`ReactReconciler.${timerType}(${displayName})`);
|
||||
},
|
||||
onEndReconcilerTimer(debugID, timerType) {
|
||||
Systrace.endEvent();
|
||||
},
|
||||
onBeginLifeCycleTimer(debugID, timerType) {
|
||||
var displayName = ReactComponentTreeDevtool().getDisplayName(debugID);
|
||||
const displayName = require('ReactComponentTreeDevtool').getDisplayName(debugID);
|
||||
Systrace.beginEvent(`${displayName}.${timerType}()`);
|
||||
},
|
||||
onEndLifeCycleTimer(debugID, timerType) {
|
||||
Systrace.endEvent();
|
||||
},
|
||||
};
|
||||
} : null;
|
||||
|
||||
var Systrace = {
|
||||
const Systrace = {
|
||||
setEnabled(enabled: boolean) {
|
||||
if (_enabled !== enabled) {
|
||||
if (__DEV__) {
|
||||
if (enabled) {
|
||||
global.nativeTraceBeginLegacy && global.nativeTraceBeginLegacy(TRACE_TAG_JSC_CALLS);
|
||||
ReactDebugTool().addDevtool(ReactSystraceDevtool);
|
||||
require('ReactDebugTool').addDevtool(ReactSystraceDevtool);
|
||||
} else {
|
||||
global.nativeTraceEndLegacy && global.nativeTraceEndLegacy(TRACE_TAG_JSC_CALLS);
|
||||
ReactDebugTool().removeDevtool(ReactSystraceDevtool);
|
||||
require('ReactDebugTool').removeDevtool(ReactSystraceDevtool);
|
||||
}
|
||||
}
|
||||
_enabled = enabled;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -97,7 +86,7 @@ var Systrace = {
|
|||
* the returned cookie variable should be used as input into the endAsyncEvent call to end the profile
|
||||
**/
|
||||
beginAsyncEvent(profileName?: any): any {
|
||||
var cookie = _asyncCookie;
|
||||
const cookie = _asyncCookie;
|
||||
if (_enabled) {
|
||||
_asyncCookie++;
|
||||
profileName = typeof profileName === 'function' ?
|
||||
|
@ -133,7 +122,7 @@ var Systrace = {
|
|||
**/
|
||||
attachToRelayProfiler(relayProfiler: RelayProfiler) {
|
||||
relayProfiler.attachProfileHandler('*', (name) => {
|
||||
var cookie = Systrace.beginAsyncEvent(name);
|
||||
const cookie = Systrace.beginAsyncEvent(name);
|
||||
return () => {
|
||||
Systrace.endAsyncEvent(name, cookie);
|
||||
};
|
||||
|
@ -191,14 +180,14 @@ var Systrace = {
|
|||
return func;
|
||||
}
|
||||
|
||||
var profileName = `${objName}.${fnName}`;
|
||||
const profileName = `${objName}.${fnName}`;
|
||||
return function() {
|
||||
if (!_enabled) {
|
||||
return func.apply(this, arguments);
|
||||
}
|
||||
|
||||
Systrace.beginEvent(profileName);
|
||||
var ret = func.apply(this, arguments);
|
||||
const ret = func.apply(this, arguments);
|
||||
Systrace.endEvent();
|
||||
return ret;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue