mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
[ReactNative] Update JS profiler to be compatible with Android
Summary: Use nativeTraceBeginSection and nativeTraceEndSection with a more dynamic signature to be compatible with Android.
This commit is contained in:
@@ -12,26 +12,20 @@
|
||||
'use strict';
|
||||
|
||||
var GLOBAL = GLOBAL || this;
|
||||
var TRACE_TAG_REACT_APPS = 1 << 17;
|
||||
|
||||
var BridgeProfiling = {
|
||||
profile(profileName?: any, args?: any) {
|
||||
profile(profileName?: any) {
|
||||
if (GLOBAL.__BridgeProfilingIsProfiling) {
|
||||
if (args) {
|
||||
try {
|
||||
args = JSON.stringify(args);
|
||||
} catch(err) {
|
||||
args = err.message;
|
||||
}
|
||||
}
|
||||
profileName = typeof profileName === 'function' ?
|
||||
profileName() : profileName;
|
||||
console.profile(profileName, args);
|
||||
console.profile(TRACE_TAG_REACT_APPS, profileName);
|
||||
}
|
||||
},
|
||||
|
||||
profileEnd() {
|
||||
if (GLOBAL.__BridgeProfilingIsProfiling) {
|
||||
console.profileEnd();
|
||||
console.profileEnd(TRACE_TAG_REACT_APPS);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -39,7 +33,7 @@ var BridgeProfiling = {
|
||||
var ReactPerf = require('ReactPerf');
|
||||
var originalMeasure = ReactPerf.measure;
|
||||
ReactPerf.measure = function (objName, fnName, func) {
|
||||
func = originalMeasure.call(ReactPerf, objName, fnName, func);
|
||||
func = originalMeasure.apply(ReactPerf, arguments);
|
||||
return function (component) {
|
||||
if (GLOBAL.__BridgeProfilingIsProfiling) {
|
||||
var name = this._instance && this._instance.constructor &&
|
||||
|
||||
Reference in New Issue
Block a user