mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
Initial commit
This commit is contained in:
41
Libraries/Utilities/RCTRenderingPerf.js
Normal file
41
Libraries/Utilities/RCTRenderingPerf.js
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright 2004-present Facebook. All Rights Reserved.
|
||||
*
|
||||
* @providesModule RCTRenderingPerf
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ReactDefaultPerf = require('ReactDefaultPerf');
|
||||
var ReactPerf = require('ReactPerf');
|
||||
|
||||
var invariant = require('invariant');
|
||||
var perfModules = [];
|
||||
|
||||
var RCTRenderingPerf = {
|
||||
toggle: function() {
|
||||
if (ReactPerf.enableMeasure) {
|
||||
ReactDefaultPerf.stop();
|
||||
ReactDefaultPerf.printInclusive();
|
||||
ReactDefaultPerf.printWasted();
|
||||
perfModules.forEach((module) => module.stop());
|
||||
} else {
|
||||
ReactDefaultPerf.start();
|
||||
console.log('Render perfomance measurements started');
|
||||
perfModules.forEach((module) => module.start());
|
||||
}
|
||||
},
|
||||
|
||||
register: function(module) {
|
||||
invariant(
|
||||
typeof module.start === 'function',
|
||||
'Perf module should have start() function'
|
||||
);
|
||||
invariant(
|
||||
typeof module.stop === 'function',
|
||||
'Perf module should have stop() function'
|
||||
);
|
||||
perfModules.push(module);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = RCTRenderingPerf;
|
||||
Reference in New Issue
Block a user