diff --git a/React/Base/RCTJavaScriptLoader.m b/React/Base/RCTJavaScriptLoader.m index 6af63ac71..889f136a0 100755 --- a/React/Base/RCTJavaScriptLoader.m +++ b/React/Base/RCTJavaScriptLoader.m @@ -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); }]; diff --git a/React/Base/RCTPerformanceLogger.h b/React/Base/RCTPerformanceLogger.h index d2f8d7b50..4e123bbfd 100644 --- a/React/Base/RCTPerformanceLogger.h +++ b/React/Base/RCTPerformanceLogger.h @@ -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); diff --git a/React/Base/RCTPerformanceLogger.m b/React/Base/RCTPerformanceLogger.m index 1a7a94362..67156f3de 100644 --- a/React/Base/RCTPerformanceLogger.m +++ b/React/Base/RCTPerformanceLogger.m @@ -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", ], ]]; }