mirror of
https://github.com/status-im/react-native.git
synced 2025-01-15 12:05:06 +00:00
06a87bec25
- [ReactNative] Add AsyncStorageTest | Spencer Ahrens - [ReactNative] Add timers integration test | Spencer Ahrens - [ReactNative] Remove ExpandingText | Tadeu Zagallo - [TouchableHighlight] Preserve underlay style when restoring inactive props | Christopher Chedeau - clean flow errors in react-native-github | Basil Hosmer - [ReactNative] Sort React Native exports into two groups, Components and APIs | Christopher Chedeau - [ReactNative] Rename Slider to SliderIOS | Tadeu Zagallo - [react_native] JS files from D1919491: Improve JS logging | Martin Kosiba - [ReactNative] Add TimerExample | Spencer Ahrens - [RFC][ReactNative] increase timer resolution | Spencer Ahrens - [ReactNative] Strip prefixes from NativeModules keys | Spencer Ahrens - [ReactNative] Small docs cleanup in ActivityIndicatorIOS and DatePickerIOS | Christopher Chedeau - [ReactNative] Improvements on perf measurement output | Jing Chen - [ReactNative] Clean up Touchable PropTypes | Christopher Chedeau - [ReactKit] Fail tests when redbox shows up | Alex Kotliarskyi
70 lines
1.6 KiB
JavaScript
70 lines
1.6 KiB
JavaScript
/**
|
|
* 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 enabled = false;
|
|
|
|
var RCTRenderingPerf = {
|
|
// Once perf is enabled, it stays enabled
|
|
toggle: function() {
|
|
console.log('Render perfomance measurements enabled');
|
|
enabled = true;
|
|
},
|
|
|
|
start: function() {
|
|
if (!enabled) {
|
|
return;
|
|
}
|
|
|
|
ReactDefaultPerf.start();
|
|
perfModules.forEach((module) => module.start());
|
|
},
|
|
|
|
stop: function() {
|
|
if (!enabled) {
|
|
return;
|
|
}
|
|
|
|
ReactDefaultPerf.stop();
|
|
ReactDefaultPerf.printInclusive();
|
|
ReactDefaultPerf.printWasted();
|
|
|
|
var totalRender = 0;
|
|
var totalTime = 0;
|
|
var measurements = ReactDefaultPerf.getLastMeasurements();
|
|
for (var ii = 0; ii < measurements.length; ii++) {
|
|
var render = measurements[ii].render;
|
|
for (var nodeName in render) {
|
|
totalRender += render[nodeName];
|
|
}
|
|
totalTime += measurements[ii].totalTime;
|
|
}
|
|
console.log('Total time spent in render(): ' + totalRender + 'ms');
|
|
|
|
perfModules.forEach((module) => module.stop());
|
|
},
|
|
|
|
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;
|