mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 04:35:36 +08:00
Update to React 15.1.0-alpha.1
Reviewed By: zpao Differential Revision: D3283057 fbshipit-source-id: c37ea3818597e5c0f37ed3c7502c791c02183ea8
This commit is contained in:
committed by
Facebook Github Bot 8
parent
68b2f49a31
commit
a95405f419
@@ -28,26 +28,50 @@ var TRACE_TAG_JSC_CALLS = 1 << 27;
|
||||
|
||||
var _enabled = false;
|
||||
var _asyncCookie = 0;
|
||||
var _ReactPerf = null;
|
||||
function ReactPerf() {
|
||||
if (!_ReactPerf) {
|
||||
_ReactPerf = require('ReactPerf');
|
||||
var _ReactDebugTool = null;
|
||||
var _ReactComponentTreeDevtool = null;
|
||||
function ReactDebugTool() {
|
||||
if (!_ReactDebugTool) {
|
||||
_ReactDebugTool = require('ReactDebugTool');
|
||||
}
|
||||
return _ReactPerf;
|
||||
return _ReactDebugTool;
|
||||
}
|
||||
function ReactComponentTreeDevtool() {
|
||||
if (!_ReactComponentTreeDevtool) {
|
||||
_ReactComponentTreeDevtool = require('ReactComponentTreeDevtool');
|
||||
}
|
||||
return _ReactComponentTreeDevtool;
|
||||
}
|
||||
|
||||
var ReactSystraceDevtool = {
|
||||
onBeginReconcilerTimer(debugID, timerType) {
|
||||
var displayName = ReactComponentTreeDevtool().getDisplayName(debugID);
|
||||
Systrace.beginEvent(`ReactReconciler.${timerType}(${displayName})`);
|
||||
},
|
||||
onEndReconcilerTimer(debugID, timerType) {
|
||||
Systrace.endEvent();
|
||||
},
|
||||
onBeginLifeCycleTimer(debugID, timerType) {
|
||||
var displayName = ReactComponentTreeDevtool().getDisplayName(debugID);
|
||||
Systrace.beginEvent(`${displayName}.${timerType}()`);
|
||||
},
|
||||
onEndLifeCycleTimer(debugID, timerType) {
|
||||
Systrace.endEvent();
|
||||
},
|
||||
};
|
||||
|
||||
var Systrace = {
|
||||
setEnabled(enabled: boolean) {
|
||||
if (_enabled !== enabled) {
|
||||
if (enabled) {
|
||||
global.nativeTraceBeginLegacy && global.nativeTraceBeginLegacy(TRACE_TAG_JSC_CALLS);
|
||||
ReactDebugTool().addDevtool(ReactSystraceDevtool);
|
||||
} else {
|
||||
global.nativeTraceEndLegacy && global.nativeTraceEndLegacy(TRACE_TAG_JSC_CALLS);
|
||||
ReactDebugTool().removeDevtool(ReactSystraceDevtool);
|
||||
}
|
||||
}
|
||||
_enabled = enabled;
|
||||
|
||||
ReactPerf().enableMeasure = enabled;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -103,24 +127,6 @@ var Systrace = {
|
||||
}
|
||||
},
|
||||
|
||||
reactPerfMeasure(objName: string, fnName: string, func: any): any {
|
||||
return function (component) {
|
||||
if (!_enabled) {
|
||||
return func.apply(this, arguments);
|
||||
}
|
||||
|
||||
var name = objName === 'ReactCompositeComponent' && this.getName() || '';
|
||||
Systrace.beginEvent(`${objName}.${fnName}(${name})`);
|
||||
var ret = func.apply(this, arguments);
|
||||
Systrace.endEvent();
|
||||
return ret;
|
||||
};
|
||||
},
|
||||
|
||||
swizzleReactPerf() {
|
||||
ReactPerf().injection.injectMeasure(Systrace.reactPerfMeasure);
|
||||
},
|
||||
|
||||
/**
|
||||
* Relay profiles use await calls, so likely occur out of current stack frame
|
||||
* therefore async variant of profiling is used
|
||||
|
||||
Reference in New Issue
Block a user