2015-06-23 22:30:54 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-06-23 22:30:54 +00:00
|
|
|
*
|
2018-05-11 02:06:46 +00:00
|
|
|
* @format
|
2015-06-23 22:30:54 +00:00
|
|
|
* @flow
|
|
|
|
*/
|
2018-05-11 02:06:46 +00:00
|
|
|
|
2015-06-23 22:30:54 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-05-10 22:44:52 +00:00
|
|
|
const PerformanceLogger = require('PerformanceLogger');
|
|
|
|
const React = require('React');
|
|
|
|
const StyleSheet = require('StyleSheet');
|
|
|
|
const Text = require('Text');
|
|
|
|
const View = require('View');
|
2015-06-23 22:30:54 +00:00
|
|
|
|
2017-08-18 01:36:54 +00:00
|
|
|
class PerformanceOverlay extends React.Component<{}> {
|
2016-07-26 08:00:02 +00:00
|
|
|
render() {
|
2018-05-10 22:44:52 +00:00
|
|
|
const perfLogs = PerformanceLogger.getTimespans();
|
|
|
|
const items = [];
|
2015-06-23 22:30:54 +00:00
|
|
|
|
2018-05-10 22:44:52 +00:00
|
|
|
for (const key in perfLogs) {
|
2015-06-23 22:30:54 +00:00
|
|
|
if (perfLogs[key].totalTime) {
|
2018-05-11 02:06:46 +00:00
|
|
|
const unit = key === 'BundleSize' ? 'b' : 'ms';
|
2015-06-23 22:30:54 +00:00
|
|
|
items.push(
|
2016-04-08 06:37:48 +00:00
|
|
|
<View style={styles.row} key={key}>
|
2015-06-23 22:30:54 +00:00
|
|
|
<Text style={[styles.text, styles.label]}>{key}</Text>
|
|
|
|
<Text style={[styles.text, styles.totalTime]}>
|
2016-02-26 12:53:38 +00:00
|
|
|
{perfLogs[key].totalTime + unit}
|
2015-06-23 22:30:54 +00:00
|
|
|
</Text>
|
2018-05-11 02:06:46 +00:00
|
|
|
</View>,
|
2015-06-23 22:30:54 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-11 02:06:46 +00:00
|
|
|
return <View style={styles.container}>{items}</View>;
|
2015-06-23 22:30:54 +00:00
|
|
|
}
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
2015-06-23 22:30:54 +00:00
|
|
|
|
2018-05-10 22:44:52 +00:00
|
|
|
const styles = StyleSheet.create({
|
2015-06-23 22:30:54 +00:00
|
|
|
container: {
|
|
|
|
height: 100,
|
|
|
|
paddingTop: 10,
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
row: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
paddingHorizontal: 10,
|
|
|
|
},
|
|
|
|
text: {
|
|
|
|
color: 'white',
|
|
|
|
fontSize: 12,
|
|
|
|
},
|
|
|
|
totalTime: {
|
|
|
|
paddingRight: 100,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = PerformanceOverlay;
|