Set up Systrace during initialization

Summary: When we're profiling, we want to load Systrace immediately and profile all the startup and initial render code. The code here used to load Systrace during startup only if `__DEV__` but would always start profiling once Systrace was otherwise required. That seems pretty hard to reason about, so I'm switching to always requiring Systrace during the startup path and enabling profiling if appropriate. In actual production that'll always be false, of course.

Reviewed By: javache

Differential Revision: D3338216

fbshipit-source-id: f173e82f34e110d83e7ff04f11af9b302a54b859
This commit is contained in:
Ben Alpert 2016-05-24 12:02:31 -07:00 committed by Facebook Github Bot 7
parent 11449359e5
commit 8876eaaea0
2 changed files with 6 additions and 2 deletions

View File

@ -40,6 +40,11 @@ function setUpProcess() {
}
}
function setUpProfile() {
const Systrace = require('Systrace');
Systrace.setEnabled(global.__RCTProfileIsProfiling || false);
}
function setUpConsole() {
// ExceptionsManager transitively requires Promise so we install it after
const ExceptionsManager = require('ExceptionsManager');
@ -229,6 +234,7 @@ function getPropertyDescriptor(object, name) {
}
setUpProcess();
setUpProfile();
setUpConsole();
setUpTimers();
setUpAlert();

View File

@ -194,8 +194,6 @@ const Systrace = {
},
};
Systrace.setEnabled(global.__RCTProfileIsProfiling || false);
if (__DEV__) {
// This is needed, because require callis in polyfills are not processed as
// other files. Therefore, calls to `require('moduleId')` are not replaced