Improve systrace markers
Reviewed By: jspahrsummers Differential Revision: D2851737 fb-gh-sync-id: 4aa0872e7d56d59de2fa42b87a795b2d64e0faa0
This commit is contained in:
parent
fff4688423
commit
41f5a21b56
|
@ -189,7 +189,7 @@ RCT_EXTERN NSArray<Class> *RCTGetModuleClasses(void);
|
|||
(void)cookie;
|
||||
|
||||
RCTSourceLoadBlock onSourceLoad = ^(NSError *error, NSData *source) {
|
||||
RCTProfileEndAsyncEvent(0, @"init,download", cookie, @"JavaScript download", nil);
|
||||
RCTProfileEndAsyncEvent(0, @"native", cookie, @"JavaScript download", @"JS async", nil);
|
||||
RCTPerformanceLoggerEnd(RCTPLScriptDownload);
|
||||
|
||||
_onSourceLoad(error, source);
|
||||
|
@ -629,6 +629,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
|||
* AnyThread
|
||||
*/
|
||||
|
||||
RCT_PROFILE_BEGIN_EVENT(0, @"-[RCTBatchedBridge enqueueJSCall:]", nil);
|
||||
|
||||
NSArray<NSString *> *ids = [moduleDotMethod componentsSeparatedByString:@"."];
|
||||
|
||||
NSString *module = ids[0];
|
||||
|
@ -654,6 +656,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
|||
[strongSelf _actuallyInvokeAndProcessModule:module method:method arguments:args ?: @[]];
|
||||
}
|
||||
}];
|
||||
|
||||
RCT_PROFILE_END_EVENT(0, @"", nil);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -843,8 +847,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
|||
|
||||
dispatch_block_t block = ^{
|
||||
RCTProfileEndFlowEvent();
|
||||
|
||||
RCT_PROFILE_BEGIN_EVENT(0, RCTCurrentThreadName(), nil);
|
||||
RCT_PROFILE_BEGIN_EVENT(0, @"-[RCTBatchedBridge handleBuffer:]", nil);
|
||||
|
||||
NSOrderedSet *calls = [buckets objectForKey:queue];
|
||||
@autoreleasepool {
|
||||
|
@ -940,14 +943,13 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
|||
- (void)_jsThreadUpdate:(CADisplayLink *)displayLink
|
||||
{
|
||||
RCTAssertJSThread();
|
||||
RCT_PROFILE_BEGIN_EVENT(0, @"DispatchFrameUpdate", nil);
|
||||
RCT_PROFILE_BEGIN_EVENT(0, @"-[RCTBatchedBridge _jsThreadUpdate:]", nil);
|
||||
|
||||
RCTFrameUpdate *frameUpdate = [[RCTFrameUpdate alloc] initWithDisplayLink:displayLink];
|
||||
for (RCTModuleData *moduleData in _frameUpdateObservers) {
|
||||
id<RCTFrameUpdateObserver> observer = (id<RCTFrameUpdateObserver>)moduleData.instance;
|
||||
if (!observer.paused) {
|
||||
RCTProfileBeginFlowEvent();
|
||||
|
||||
[self dispatchBlock:^{
|
||||
RCTProfileEndFlowEvent();
|
||||
[observer didUpdateFrame:frameUpdate];
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#import "RCTUtils.h"
|
||||
#import "RCTView.h"
|
||||
#import "UIView+React.h"
|
||||
#import "RCTProfile.h"
|
||||
|
||||
NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotification";
|
||||
|
||||
|
@ -60,6 +61,8 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotificat
|
|||
RCTAssert(bridge, @"A bridge instance is required to create an RCTRootView");
|
||||
RCTAssert(moduleName, @"A moduleName is required to create an RCTRootView");
|
||||
|
||||
RCT_PROFILE_BEGIN_EVENT(0, @"-[RCTRootView init]", nil);
|
||||
|
||||
if ((self = [super initWithFrame:CGRectZero])) {
|
||||
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
|
@ -86,6 +89,9 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotificat
|
|||
|
||||
[self showLoadingView];
|
||||
}
|
||||
|
||||
RCT_PROFILE_END_EVENT(0, @"", nil);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -174,10 +180,10 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
|||
|
||||
[_contentView removeFromSuperview];
|
||||
_contentView = [[RCTRootContentView alloc] initWithFrame:self.bounds bridge:bridge];
|
||||
[self runApplication:bridge];
|
||||
|
||||
_contentView.backgroundColor = self.backgroundColor;
|
||||
[self insertSubview:_contentView atIndex:0];
|
||||
|
||||
[self runApplication:bridge];
|
||||
}
|
||||
|
||||
- (void)runApplication:(RCTBridge *)bridge
|
||||
|
|
|
@ -261,12 +261,11 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||
return nil;
|
||||
}
|
||||
|
||||
RCT_PROFILE_BEGIN_EVENT(0, @"nativeRequireModuleConfig", nil);
|
||||
NSArray *config = [strongSelf->_bridge configForModuleName:moduleName];
|
||||
if (config) {
|
||||
return RCTJSONStringify(config, NULL);
|
||||
}
|
||||
|
||||
return nil;
|
||||
NSString *result = config ? RCTJSONStringify(config, NULL) : nil;
|
||||
RCT_PROFILE_END_EVENT(0, @"js_call,config", @{ @"moduleName": moduleName });
|
||||
return result;
|
||||
}];
|
||||
|
||||
[self addSynchronousHookWithName:@"nativeFlushQueueImmediate" usingBlock:^(NSArray<NSArray *> *calls){
|
||||
|
@ -275,7 +274,9 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||
return;
|
||||
}
|
||||
|
||||
RCT_PROFILE_BEGIN_EVENT(0, @"nativeFlushQueueImmediate", nil);
|
||||
[strongSelf->_bridge handleBuffer:calls batchEnded:NO];
|
||||
RCT_PROFILE_END_EVENT(0, @"js_call", nil);
|
||||
}];
|
||||
|
||||
[self addSynchronousHookWithName:@"nativePerformanceNow" usingBlock:^{
|
||||
|
@ -296,7 +297,7 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||
|
||||
[self addSynchronousHookWithName:@"nativeTraceEndAsyncSection" usingBlock:^(uint64_t tag, NSString *name, NSUInteger cookie) {
|
||||
NSUInteger newCookie = (NSUInteger)CFDictionaryGetValue(cookieMap, (const void *)cookie);
|
||||
RCTProfileEndAsyncEvent(tag, @"js,async", newCookie, name, nil);
|
||||
RCTProfileEndAsyncEvent(tag, @"js,async", newCookie, name, @"JS async", nil);
|
||||
CFDictionaryRemoveValue(cookieMap, (const void *)cookie);
|
||||
}];
|
||||
|
||||
|
|
|
@ -69,10 +69,10 @@ RCT_EXTERN void _RCTProfileBeginEvent(NSThread *calleeThread,
|
|||
#define RCT_PROFILE_BEGIN_EVENT(...) \
|
||||
do { \
|
||||
if (RCTProfileIsProfiling()) { \
|
||||
NSThread *calleeThread = [NSThread currentThread]; \
|
||||
NSTimeInterval time = CACurrentMediaTime(); \
|
||||
NSThread *__calleeThread = [NSThread currentThread]; \
|
||||
NSTimeInterval __time = CACurrentMediaTime(); \
|
||||
dispatch_async(RCTProfileGetQueue(), ^{ \
|
||||
_RCTProfileBeginEvent(calleeThread, time, __VA_ARGS__); \
|
||||
_RCTProfileBeginEvent(__calleeThread, __time, __VA_ARGS__); \
|
||||
}); \
|
||||
} \
|
||||
} while(0)
|
||||
|
@ -92,11 +92,11 @@ RCT_EXTERN void _RCTProfileEndEvent(NSThread *calleeThread,
|
|||
#define RCT_PROFILE_END_EVENT(...) \
|
||||
do { \
|
||||
if (RCTProfileIsProfiling()) { \
|
||||
NSThread *calleeThread = [NSThread currentThread]; \
|
||||
NSString *threadName = RCTCurrentThreadName(); \
|
||||
NSTimeInterval time = CACurrentMediaTime(); \
|
||||
NSThread *__calleeThread = [NSThread currentThread]; \
|
||||
NSString *__threadName = RCTCurrentThreadName(); \
|
||||
NSTimeInterval __time = CACurrentMediaTime(); \
|
||||
dispatch_async(RCTProfileGetQueue(), ^{ \
|
||||
_RCTProfileEndEvent(calleeThread, threadName, time, __VA_ARGS__); \
|
||||
_RCTProfileEndEvent(__calleeThread, __threadName, __time, __VA_ARGS__); \
|
||||
}); \
|
||||
} \
|
||||
} while(0)
|
||||
|
@ -117,6 +117,7 @@ RCT_EXTERN void RCTProfileEndAsyncEvent(uint64_t tag,
|
|||
NSString *category,
|
||||
NSUInteger cookie,
|
||||
NSString *name,
|
||||
NSString *threadName,
|
||||
NSDictionary *args);
|
||||
|
||||
/**
|
||||
|
|
|
@ -472,7 +472,6 @@ void _RCTProfileBeginEvent(
|
|||
NSMutableArray *events = RCTProfileGetThreadEvents(calleeThread);
|
||||
[events addObject:@[
|
||||
RCTProfileTimestamp(time),
|
||||
@(tag),
|
||||
name,
|
||||
RCTNullIfNil(args),
|
||||
]];
|
||||
|
@ -507,12 +506,12 @@ void _RCTProfileEndEvent(
|
|||
|
||||
RCTProfileAddEvent(RCTProfileTraceEvents,
|
||||
@"tid": threadName,
|
||||
@"name": event[2],
|
||||
@"name": event[1],
|
||||
@"cat": category,
|
||||
@"ph": @"X",
|
||||
@"ts": start,
|
||||
@"dur": @(RCTProfileTimestamp(time).doubleValue - start.doubleValue),
|
||||
@"args": RCTProfileMergeArgs(event[3], args),
|
||||
@"args": RCTProfileMergeArgs(event[2], args),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -548,6 +547,7 @@ void RCTProfileEndAsyncEvent(
|
|||
NSString *category,
|
||||
NSUInteger cookie,
|
||||
NSString *name,
|
||||
NSString *threadName,
|
||||
NSDictionary *args
|
||||
) {
|
||||
CHECK();
|
||||
|
@ -558,7 +558,6 @@ void RCTProfileEndAsyncEvent(
|
|||
}
|
||||
|
||||
NSTimeInterval time = CACurrentMediaTime();
|
||||
NSString *threadName = RCTCurrentThreadName();
|
||||
|
||||
dispatch_async(RCTProfileGetQueue(), ^{
|
||||
NSArray *event = RCTProfileOngoingEvents[@(cookie)];
|
||||
|
|
Loading…
Reference in New Issue