2015-06-23 22:30:54 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
|
|
|
* @providesModule PerformanceOverlay
|
|
|
|
* @flow
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var PerformanceLogger = require('PerformanceLogger');
|
|
|
|
var React = require('React');
|
|
|
|
var StyleSheet = require('StyleSheet');
|
|
|
|
var Text = require('Text');
|
|
|
|
var View = require('View');
|
|
|
|
|
2016-07-26 08:00:02 +00:00
|
|
|
class PerformanceOverlay extends React.Component {
|
|
|
|
render() {
|
2015-06-23 22:30:54 +00:00
|
|
|
var perfLogs = PerformanceLogger.getTimespans();
|
|
|
|
var items = [];
|
|
|
|
|
|
|
|
for (var key in perfLogs) {
|
|
|
|
if (perfLogs[key].totalTime) {
|
2016-02-26 12:53:38 +00:00
|
|
|
var 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>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
{items}
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
2015-06-23 22:30:54 +00:00
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
height: 100,
|
|
|
|
paddingTop: 10,
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
row: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
paddingHorizontal: 10,
|
|
|
|
},
|
|
|
|
text: {
|
|
|
|
color: 'white',
|
|
|
|
fontSize: 12,
|
|
|
|
},
|
|
|
|
totalTime: {
|
|
|
|
paddingRight: 100,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = PerformanceOverlay;
|