mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
[ReactNative] Add ReactPerf info to profiler timeline
Summary:
@public
Hook into ReactPerf to add markers to `RCTProfile` timeline.
Test Plan: {F22569628}
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
var GLOBAL = GLOBAL || this;
|
||||
|
||||
var BridgeProfiling = {
|
||||
profile(profileName: string, args?: any) {
|
||||
profile(profileName?: string, args?: any) {
|
||||
if (GLOBAL.__BridgeProfilingIsProfiling) {
|
||||
if (args) {
|
||||
try {
|
||||
@@ -27,11 +27,30 @@ var BridgeProfiling = {
|
||||
}
|
||||
},
|
||||
|
||||
profileEnd() {
|
||||
profileEnd(profileName?: string) {
|
||||
if (GLOBAL.__BridgeProfilingIsProfiling) {
|
||||
console.profileEnd();
|
||||
console.profileEnd(profileName);
|
||||
}
|
||||
},
|
||||
|
||||
swizzleReactPerf() {
|
||||
var ReactPerf = require('ReactPerf');
|
||||
var originalMeasure = ReactPerf.measure;
|
||||
ReactPerf.measure = function (objName, fnName, func) {
|
||||
func = originalMeasure.call(ReactPerf, objName, fnName, func);
|
||||
return function (component) {
|
||||
BridgeProfiling.profile();
|
||||
var ret = func.apply(this, arguments);
|
||||
if (GLOBAL.__BridgeProfilingIsProfiling) {
|
||||
var name = this._instance && this._instance.constructor &&
|
||||
(this._instance.constructor.displayName ||
|
||||
this._instance.constructor.name);
|
||||
BridgeProfiling.profileEnd(`${objName}.${fnName}(${name})`);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = BridgeProfiling;
|
||||
|
||||
Reference in New Issue
Block a user