Attach to all RelayProfiler events
Summary: public Dynamically profile events from RelayProfiler if available. This will expose time spent in Relay in the systraces. Reviewed By: tadeuzagallo Differential Revision: D2674215 fb-gh-sync-id: d5f9d529b86d267a80b0cda2223f6a28a08ac385
This commit is contained in:
parent
155a609781
commit
7febd13676
|
@ -160,7 +160,9 @@ function setUpWebSockets() {
|
|||
|
||||
function setUpProfile() {
|
||||
if (__DEV__) {
|
||||
require('BridgeProfiling').swizzleReactPerf();
|
||||
var BridgeProfiling = require('BridgeProfiling');
|
||||
BridgeProfiling.swizzleReactPerf();
|
||||
BridgeProfiling.attachToRelayProfiler();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,24 @@ var BridgeProfiling = {
|
|||
swizzleReactPerf() {
|
||||
ReactPerf().injection.injectMeasure(BridgeProfiling.reactPerfMeasure);
|
||||
},
|
||||
|
||||
attachToRelayProfiler() {
|
||||
// We don't want to create a dependency on `RelayProfiler`, so that's why
|
||||
// we require it indirectly (rather than using a literal string). Since
|
||||
// there's no guarantee that the module will be present, we must wrap
|
||||
// everything in a try-catch block as requiring a non-existing module
|
||||
// will just throw.
|
||||
try {
|
||||
var rpName = 'RelayProfiler';
|
||||
var RelayProfiler = require(rpName);
|
||||
RelayProfiler.attachProfileHandler('*', (name) => {
|
||||
BridgeProfiling.profile(name);
|
||||
return () => {
|
||||
BridgeProfiling.profileEnd();
|
||||
};
|
||||
});
|
||||
} catch(err) {}
|
||||
}
|
||||
};
|
||||
|
||||
BridgeProfiling.setEnabled(global.__RCTProfileIsProfiling || false);
|
||||
|
|
Loading…
Reference in New Issue