Add systrace markers to module require

Summary: public

Show modules' dependencies and time to load.

Reviewed By: davidaurelio

Differential Revision: D2603245

fb-gh-sync-id: a1d5067a8522b908b87fdfdd51ff4c4fdbc2edfc
This commit is contained in:
Tadeu Zagallo 2015-11-21 11:08:31 -08:00 committed by facebook-github-bot-0
parent f02d6c1848
commit 97f0432de5
1 changed files with 14 additions and 0 deletions

View File

@ -54,9 +54,13 @@
// require cycles inside the factory from causing an infinite require loop. // require cycles inside the factory from causing an infinite require loop.
mod.isInitialized = true; mod.isInitialized = true;
__DEV__ && BridgeProfiling().profile(id);
// keep args in sync with with defineModuleCode in // keep args in sync with with defineModuleCode in
// packager/react-packager/src/Resolver/index.js // packager/react-packager/src/Resolver/index.js
mod.factory.call(global, global, require, mod.module, mod.module.exports); mod.factory.call(global, global, require, mod.module, mod.module.exports);
__DEV__ && BridgeProfiling().profileEnd();
} catch (e) { } catch (e) {
mod.hasError = true; mod.hasError = true;
mod.isInitialized = false; mod.isInitialized = false;
@ -66,6 +70,16 @@
return mod.module.exports; return mod.module.exports;
} }
const BridgeProfiling = __DEV__ && (() => {
var _BridgeProfiling;
try {
_BridgeProfiling = require('BridgeProfiling');
} catch(e) {}
return _BridgeProfiling && _BridgeProfiling.profile ?
_BridgeProfiling : { profile: () => {}, profileEnd: () => {} };
});
global.__d = define; global.__d = define;
global.require = require; global.require = require;
})(this); })(this);