-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to new ReactPerf #7283
Update to new ReactPerf #7283
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,26 +29,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'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ReactComponentTreeDevtool Required module not found There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ReactComponentTreeDevtool Required module not found There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ReactComponentTreeDevtool Required module not found |
||
} | ||
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; | ||
}, | ||
|
||
/** | ||
|
@@ -104,24 +128,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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReactComponentTreeDevtool Required module not found