fix RCTPerfMonitor display unit error

Summary:The  RCTPerformanceLogger log the time in ms not us. Especially the unit of RCTPLBundleSize is byte.
Closes https://github.com/facebook/react-native/pull/5919

Differential Revision: D2982116

Pulled By: nicklockwood

fb-gh-sync-id: 18aad5ff2eb83c6f302b2c10382bf214b51df133
shipit-source-id: 18aad5ff2eb83c6f302b2c10382bf214b51df133
This commit is contained in:
wenzhao.yin 2016-02-26 04:53:38 -08:00 committed by Facebook Github Bot 9
parent 251d5a5959
commit 50141f9d3f
2 changed files with 7 additions and 5 deletions

View File

@ -24,11 +24,12 @@ var PerformanceOverlay = React.createClass({
for (var key in perfLogs) {
if (perfLogs[key].totalTime) {
var unit = (key === 'BundleSize') ? 'b' : 'ms';
items.push(
<View style={styles.row}>
<Text style={[styles.text, styles.label]}>{key}</Text>
<Text style={[styles.text, styles.totalTime]}>
{perfLogs[key].totalTime + 'ms'}
{perfLogs[key].totalTime + unit}
</Text>
</View>
);

View File

@ -501,12 +501,13 @@ RCT_EXPORT_MODULE()
- (void)loadPerformanceLoggerData
{
NSMutableArray *data = [NSMutableArray new];
NSArray *times = RCTPerformanceLoggerOutput();
NSUInteger i = 0;
NSMutableArray<NSString *> *data = [NSMutableArray new];
NSArray<NSNumber *> *values = RCTPerformanceLoggerOutput();
for (NSString *label in RCTPerformanceLoggerLabels()) {
[data addObject:[NSString stringWithFormat:@"%@: %lldus", label,
[times[i+1] longLongValue] - [times[i] longLongValue]]];
long long value = values[i+1].longLongValue - values[i].longLongValue;
NSString *unit = [label isEqualToString:@"BundleSize"] ? @"b" : @"ms";
[data addObject:[NSString stringWithFormat:@"%@: %lld%@", label, value, unit]];
i += 2;
}
_perfLoggerMarks = [data copy];