Support flow events in RCTProfile

Summary: Add begin/end async flow to the callbacks for external profiling

Reviewed By: tadeuzagallo

Differential Revision: D3234812

fbshipit-source-id: cdbe46883fd566d50a04de9ad67f947876a78a0c
This commit is contained in:
Marc Horowitz 2016-05-13 17:14:55 -07:00 committed by Facebook Github Bot 8
parent 05832c3469
commit 418e16f711
2 changed files with 9 additions and 3 deletions

View File

@ -187,6 +187,9 @@ typedef struct {
void (*end_async_section)(uint64_t tag, const char *name, int cookie, size_t numArgs, systrace_arg_t *args);
void (*instant_section)(uint64_t tag, const char *name, char scope);
void (*begin_async_flow)(uint64_t tag, const char *name, int cookie);
void (*end_async_flow)(uint64_t tag, const char *name, int cookie);
} RCTProfileCallbacks;
RCT_EXTERN void RCTProfileRegisterCallbacks(RCTProfileCallbacks *);

View File

@ -696,13 +696,15 @@ NSNumber *_RCTProfileBeginFlowEvent(void)
CHECK(@0);
unsigned int cookie = ++flowID;
NSNumber *currentID = @(cookie);
if (callbacks != NULL) {
// flow events not supported yet
return @0;
callbacks->begin_async_flow(1, "flow", cookie);
return currentID;
}
NSTimeInterval time = CACurrentMediaTime();
NSNumber *currentID = @(++flowID);
NSString *threadName = RCTCurrentThreadName();
dispatch_async(RCTProfileGetQueue(), ^{
@ -725,6 +727,7 @@ void _RCTProfileEndFlowEvent(NSNumber *flowID)
CHECK();
if (callbacks != NULL) {
callbacks->end_async_flow(1, "flow", [flowID integerValue]);
return;
}