Log bundle size.

Reviewed By: javache

Differential Revision: D2564757

fb-gh-sync-id: c4429b735482ee6405b936e2dcdf610e9c6ad35f
This commit is contained in:
Alexey Lang 2015-10-21 10:53:35 -07:00 committed by facebook-github-bot-6
parent 394dfae868
commit 8ad09987e5
3 changed files with 14 additions and 1 deletions

View File

@ -13,6 +13,7 @@
#import "RCTConvert.h"
#import "RCTSourceCode.h"
#import "RCTUtils.h"
#import "RCTPerformanceLogger.h"
@implementation RCTJavaScriptLoader
@ -39,6 +40,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
NSData *source = [NSData dataWithContentsOfFile:filePath
options:NSDataReadingMappedIfSafe
error:&error];
RCTPerformanceLoggerSet(RCTPLBundleSize, source.length);
onComplete(error, source);
});
return;
@ -73,7 +75,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
encoding = CFStringConvertEncodingToNSStringEncoding(cfEncoding);
}
}
// Handle HTTP errors
if ([response isKindOfClass:[NSHTTPURLResponse class]] && ((NSHTTPURLResponse *)response).statusCode != 200) {
NSString *rawText = [[NSString alloc] initWithData:data encoding:encoding];
@ -103,6 +104,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
onComplete(error, nil);
return;
}
RCTPerformanceLoggerSet(RCTPLBundleSize, data.length);
onComplete(nil, data);
}];

View File

@ -18,9 +18,11 @@ typedef NS_ENUM(NSUInteger, RCTPLTag) {
RCTPLNativeModulePrepareConfig,
RCTPLNativeModuleInjectConfig,
RCTPLTTI,
RCTPLBundleSize,
RCTPLSize
};
void RCTPerformanceLoggerStart(RCTPLTag tag);
void RCTPerformanceLoggerEnd(RCTPLTag tag);
void RCTPerformanceLoggerSet(RCTPLTag tag, int64_t value);
NSArray *RCTPerformanceLoggerOutput(void);

View File

@ -30,6 +30,12 @@ void RCTPerformanceLoggerEnd(RCTPLTag tag)
}
}
void RCTPerformanceLoggerSet(RCTPLTag tag, int64_t value)
{
RCTPLData[tag][0] = 0;
RCTPLData[tag][1] = value;
}
NSArray *RCTPerformanceLoggerOutput(void)
{
return @[
@ -45,6 +51,8 @@ NSArray *RCTPerformanceLoggerOutput(void)
@(RCTPLData[RCTPLNativeModuleInjectConfig][1]),
@(RCTPLData[RCTPLTTI][0]),
@(RCTPLData[RCTPLTTI][1]),
@(RCTPLData[RCTPLBundleSize][0]),
@(RCTPLData[RCTPLBundleSize][1]),
];
}
@ -87,6 +95,7 @@ RCT_EXPORT_MODULE()
@"NativeModulePrepareConfig",
@"NativeModuleInjectConfig",
@"TTI",
@"BundleSize",
],
]];
}