[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:
Tadeu Zagallo
2015-08-25 01:31:22 -07:00
parent 4382c0e8f4
commit fe0143eb20
3 changed files with 54 additions and 47 deletions

View File

@@ -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 &&